Skip to main content

Decentralized P2P Encrypted Chat Agent powered by Strands Agents & Bluetooth LE

Project description

๐Ÿ” BitChat Strands Agent

Decentralized P2P Encrypted Chat Agent powered by Strands Agents & Bluetooth LE

A revolutionary AI agent that communicates through decentralized, peer-to-peer encrypted chat networks over Bluetooth Low Energy. Enables secure agent-to-agent and agent-to-human communication without internet dependency.

Strands Agents PyPI Bluetooth LE End-to-End Encryption

๐Ÿš€ Features

๐Ÿ”ฅ Core Capabilities

  • ๐Ÿค– AI Agent Integration - Full Strands Agent with BitChat communication
  • ๐Ÿ“ก P2P Mesh Network - Direct device-to-device communication over Bluetooth LE
  • ๐Ÿ” End-to-End Encryption - Noise Protocol with ChaCha20-Poly1305 and forward secrecy
  • ๐ŸŒ No Internet Required - Works completely offline in air-gapped environments
  • โšก Auto-Installation - Automatically installs all required dependencies

๐Ÿ’ฌ Communication Types

  • ๐Ÿ“ข Public Broadcasts - Send messages to all connected peers
  • ๐Ÿ”’ Private Messages - End-to-end encrypted direct messages
  • ๐Ÿ“บ Secure Channels - Password-protected group conversations
  • ๐Ÿ”„ Message Relay - Mesh network message forwarding for extended range

๐Ÿ›ก๏ธ Security & Privacy

  • Noise Protocol XX - Modern cryptographic handshake protocol
  • ChaCha20-Poly1305 - Authenticated encryption with additional data (AEAD)
  • Forward Secrecy - Past communications remain secure even if keys are compromised
  • Identity Keys - Persistent cryptographic identity across sessions
  • Peer Blocking - Privacy controls and user management
  • Traffic Analysis Resistance - PKCS#7 padding and cover traffic

๐Ÿค Agent Collaboration

  • Trigger Keywords - Agents respond to mentions (e.g., "max, analyze this")
  • Context Awareness - Full conversation history in agent responses
  • Cross-Platform - Works across different devices and operating systems
  • Emergency Coordination - Agents coordinate during network outages
  • Team Automation - Automatic task distribution across agent network

๐Ÿ“‹ Requirements

System Requirements

  • Python 3.8+
  • Bluetooth Low Energy support (most modern devices)
  • macOS, Linux, or Windows

Dependencies (Auto-installed)

  • strands-agents - Core AI agent framework
  • strands-agents-tools - Extended tool ecosystem
  • bleak>=0.20.0 - Bluetooth Low Energy library
  • pybloom-live>=4.0.0 - Bloom filters for message deduplication
  • lz4>=4.3.0 - Fast compression
  • cryptography>=41.0.0 - Cryptographic primitives

๐Ÿ”ง Installation

๐Ÿš€ Quick Install from PyPI (Recommended)

pip install strands-bitchat

๐ŸŽฎ Run the Agent

strands-bitchat # using ollama with qwen3:8b, download model by running: "ollama run qwen3:8b"

That's it! The agent will automatically install any missing BitChat dependencies on first use.

๐Ÿ“ฆ Alternative: Development Installation

For development or customization:

git clone https://github.com/cagataycali/strands-bitchat.git
cd strands-bitchat
pip install -e .
python agent.py

๐ŸŽฎ Usage

Starting the Agent

strands-bitchat

Basic Commands

Start BitChat Network

> start bitchat

Send Public Message

> send public message "Hello BitChat network!"

Join Password-Protected Channel

> join channel #secure with password mysecret

Send Private Message

> send private message to alice "This is encrypted!"

Enable Agent Auto-Responses

> enable agent triggers with keyword "assistant"

Advanced Usage Examples

Agent-to-Agent Communication

# Enable automatic responses to "max" trigger in BitChat
bitchat(action="enable_agent", trigger_keyword="max", agent=agent)

# Other agents can now trigger responses:
# In BitChat: "max, what time is it?"
# Agent automatically responds via BitChat

Secure Team Coordination

# Join secure team channel
bitchat(action="join_channel", channel="#operations", password="team2024")

# Send encrypted team message
bitchat(action="send_channel", message="Task completed successfully", channel="#operations")

Emergency Network Operations

# Works without internet - pure P2P mesh
bitchat(action="start")  # Connects to local Bluetooth LE mesh
bitchat(action="send_public", message="Emergency coordination active")

๐Ÿ› ๏ธ BitChat Tool API

Available Actions

Action Description Parameters
start Start BitChat client None
stop Stop BitChat client None
status Get connection status None
send_public Send public broadcast message
send_private Send encrypted DM message, recipient
send_channel Send channel message message, channel
join_channel Join/create channel channel, password (optional)
leave_channel Leave current channel None
list_peers List connected peers None
list_channels List discovered channels None
block_user Block a user nickname
unblock_user Unblock a user nickname
set_nickname Change nickname nickname
get_messages Get message history None
enable_agent Enable auto-responses trigger_keyword, agent
disable_agent Disable auto-responses None
agent_status Check agent integration None

Python API Examples

Basic Usage

from strands import Agent
from strands_bitchat import bitchat

agent = Agent(tools=[bitchat])

# Start BitChat
result = agent.tool.bitchat(action="start", agent=agent)

# Send message
result = agent.tool.bitchat(action="send_public", message="Hello world!", agent=agent)

# Enable agent integration
result = agent.tool.bitchat(action="enable_agent", trigger_keyword="max", agent=agent)

Advanced Integration

# Multi-channel coordination
agent.tool.bitchat(action="join_channel", channel="#team", password="secret", agent=agent)
agent.tool.bitchat(action="join_channel", channel="#public", agent=agent)

# Automated responses across channels
agent.tool.bitchat(action="enable_agent", trigger_keyword="assistant", agent=agent)

# Now other users can interact:
# - Public: "assistant, analyze this data"  
# - Team channel: "assistant, status report"
# - Direct message: "assistant, help with task"

๐Ÿ” Security Architecture

Encryption Details

  • Handshake: Noise Protocol XX pattern
  • Transport: ChaCha20-Poly1305 AEAD cipher
  • Key Exchange: Curve25519 ECDH
  • Hash Function: SHA-256
  • Forward Secrecy: Automatic key rotation

Network Security

  • Mesh Topology: No single point of failure
  • Message Deduplication: Bloom filters prevent replay attacks
  • TTL (Time To Live): Prevents infinite message loops
  • Fragmentation: Large messages split and reassembled securely

Privacy Features

  • Pseudonymous Identity: No real identity required
  • Local Storage: All data stored locally
  • No Cloud Dependencies: Pure P2P architecture
  • Cover Traffic: Traffic analysis resistance

๐ŸŒ Network Topology

Device A โ†โ†’ Device B โ†โ†’ Device C
    โ†‘           โ†‘           โ†‘
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Device D โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    
โ€ข Each device can relay messages
โ€ข No central server required  
โ€ข Works in isolated environments
โ€ข Automatic peer discovery
โ€ข Mesh healing capabilities

๐ŸŽฏ Use Cases

๐Ÿค– Agent Networks

  • Multi-agent collaboration on complex tasks
  • Distributed AI processing across devices
  • Agent-to-agent knowledge sharing
  • Coordinated autonomous operations

๐Ÿ›ก๏ธ Security & Privacy

  • Air-gapped secure communications
  • Emergency response coordination
  • Sensitive data discussions
  • Privacy-focused team communication

๐ŸŒ Offline Operations

  • Remote area communications
  • Internet outage scenarios
  • Conference/event networking
  • IoT device coordination

๐Ÿ’ผ Enterprise Applications

  • Secure team coordination
  • Agent-assisted workflows
  • Distributed system monitoring
  • Edge computing coordination

๐Ÿš€ Getting Started Examples

Example 1: Basic Agent Chat

strands-bitchat

> start bitchat
โœ… BitChat started! Status: connecting

> set nickname to "MyAgent"  
๐Ÿ“› Nickname changed to: MyAgent

> send public message "Hello from Strands Agent!"
๐Ÿ“ข Public message sent: Hello from Strands Agent!

Example 2: Agent Auto-Response Setup

> enable agent triggers with keyword "assistant"
๐Ÿค– Agent trigger enabled! Will respond to 'assistant' in BitChat messages

# Now other users can trigger agent responses:
# Other user: "assistant, what's 2+2?"
# Agent automatically responds: "The answer is 4"

Example 3: Secure Channel Operations

> join channel #team with password secretkey
๐Ÿ  Joined channel #team (with password)

> send to channel "Secure team message"
๐Ÿ“บ Channel message sent to #team: Secure team message

> list channels
๐Ÿ“บ Discovered Channels:
  โ€ข #team ๐Ÿ”’ โœ…
  โ€ข #public
  
๐Ÿ”’ = Password protected, โœ… = Joined

๐Ÿ”ง Troubleshooting

Connection Issues

# Check Bluetooth status
> status bitchat
๐Ÿ“Š BitChat Status: Connected โœ…

# Restart if needed
> stop bitchat
> start bitchat

Permission Issues

  • macOS: Grant Bluetooth permission in System Preferences
  • Linux: Ensure user is in bluetooth group
  • Windows: Enable Bluetooth in Device Manager

Common Problems

  1. No peers found: Check Bluetooth is enabled on all devices
  2. Failed to connect: Restart BitChat and try again
  3. Messages not decrypting: Verify channel password is correct
  4. Agent not responding: Check trigger keyword and agent status

๐Ÿ“š Documentation

Protocol Specification

  • Based on Noise Protocol Framework XX pattern
  • Bluetooth LE GATT service implementation
  • Message fragmentation for large payloads
  • Delivery acknowledgments for reliability

Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Strands       โ”‚    โ”‚    BitChat       โ”‚    โ”‚   Bluetooth     โ”‚
โ”‚   Agent         โ”‚โ—„โ”€โ”€โ–บโ”‚    Protocol      โ”‚โ—„โ”€โ”€โ–บโ”‚   LE Mesh       โ”‚
โ”‚                 โ”‚    โ”‚                  โ”‚    โ”‚                 โ”‚
โ”‚ โ€ข AI Processing โ”‚    โ”‚ โ€ข Encryption     โ”‚    โ”‚ โ€ข P2P Network   โ”‚
โ”‚ โ€ข Tool Calling  โ”‚    โ”‚ โ€ข Message Relay  โ”‚    โ”‚ โ€ข Device Discoveryโ”‚  
โ”‚ โ€ข Context Mgmt  โ”‚    โ”‚ โ€ข Channel Mgmt   โ”‚    โ”‚ โ€ข Data Transportโ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿค Contributing

Contributions welcome! Areas for improvement:

  • Performance optimization for large networks
  • Additional encryption algorithms
  • Protocol extensions for new message types
  • Integration with other Strands tools
  • Documentation and examples

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ™ Acknowledgments


๐Ÿš€ Ready to build the future of decentralized AI communication!

Create autonomous agent networks that work anywhere, anytime, without internet dependency.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strands_bitchat-1.0.1.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strands_bitchat-1.0.1-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file strands_bitchat-1.0.1.tar.gz.

File metadata

  • Download URL: strands_bitchat-1.0.1.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for strands_bitchat-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e96dedac170df65314de2e46cfe9dc8476ec32b84f4fc5d95edb5bbe5149262c
MD5 4b165aaa0d1ebe015c59ef68b5487ae4
BLAKE2b-256 29a7a464a3db14d97109cb24147d7a225f05e65f8d027e1aa7762429a116dac4

See more details on using hashes here.

File details

Details for the file strands_bitchat-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for strands_bitchat-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 540287d4ef6391f1d37913df4d06ae42d7de92cb619028d44d0861ad1e26438c
MD5 bb72c7caa9fb6ed6b204206440b6f83b
BLAKE2b-256 58eb5f2c54691a5855beec5b2d4d8e3393fd0aa6fb635fcd4af7ca3aa4b70d79

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page