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 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

1. Clone the Repository

git clone https://github.com/cagataycali/strands-bitchat.git
cd strands-bitchat

2. Install Dependencies

pip install -r requirements.txt

3. Run the Agent

python agent.py

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

๐ŸŽฎ Usage

Starting the Agent

python agent.py

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 src.tools import bitchat

agent = Agent(tools=[bitchat])

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

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

# 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.tool.bitchat(action="join_channel", channel="#public") 

# 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

python agent.py

> 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.0.tar.gz (38.0 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.0-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strands_bitchat-1.0.0.tar.gz
  • Upload date:
  • Size: 38.0 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.0.tar.gz
Algorithm Hash digest
SHA256 04d964747725d8dded21831e1362b2e39176d3d6d75d822b04f0f80a87569f3d
MD5 41aa7257fcc643f922dd3eb409525285
BLAKE2b-256 82d605f9a338fba278070bd63bea49f4d66c4020cad80703a33040ac0dd07a6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strands_bitchat-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eded6ff5456ae3ad0f99a7bf163ec1fa3fea55e32f06fae8cc23e642160e5c4c
MD5 74932fc0d76ab030ed3235de985e5496
BLAKE2b-256 4f9fd49627fde5bc9f06a8ee677c50a5cd827bfd5c34a6a20af995c0829ec5b7

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