Skip to main content

Inter-agent messaging for Blueprint ecosystem

Project description

bp-tunnel

Inter-agent messaging for the Blueprint ecosystem.

Lightweight tunnel system that lets AI agents (or any process) communicate through named channels with pluggable transport backends.

Install

pip install bp-tunnel

Quick Start

Python API

from bp_tunnel import FileTransport, Tunnel

transport = FileTransport()  # defaults to /tmp/bp-tunnel

# Agent 1: create tunnel and send
transport.create("my-tunnel", "alice")
alice = Tunnel("my-tunnel", "alice", transport)
alice.send("hello everyone")          # broadcast
alice.send("hey bob", to="bob")       # direct message

# Agent 2: join and receive
transport.join("my-tunnel", "bob")
bob = Tunnel("my-tunnel", "bob", transport)
msg = bob.receive()                   # non-blocking
msg = bob.wait_for(from_="alice")     # blocking wait

AI Tool Interface

Stateless dict-based functions for AI agent integration:

from bp_tunnel.tools import create_tunnel, join_tunnel, send_message, wait_for_message

# Agent creates a tunnel
result = create_tunnel("manager")
# {"tunnel_id": "a1b2c3d4", "agent": "manager", "role": "admin"}

# Another agent joins
join_tunnel("a1b2c3d4", "worker")

# Send and receive
send_message("a1b2c3d4", "manager", "build the feature", to="worker")
msg = wait_for_message("a1b2c3d4", "worker", from_agent="manager", timeout=30)
# {"status": "message", "from": "manager", "message": "build the feature", "ts": ...}

CLI

# Create a tunnel
bp-tunnel create --as alice
# prints: a1b2c3d4

# Join from another terminal
bp-tunnel join a1b2c3d4 --as bob

# Send messages
bp-tunnel send a1b2c3d4 "hello" --as alice
bp-tunnel send a1b2c3d4 "hey bob" --as alice --to bob

# Receive
bp-tunnel recv a1b2c3d4 --as bob
bp-tunnel recv a1b2c3d4 --as bob --from alice

# Listen continuously
bp-tunnel listen a1b2c3d4 --as bob

# Admin operations
bp-tunnel promote a1b2c3d4 bob --as alice
bp-tunnel demote a1b2c3d4 bob --as alice

# Info
bp-tunnel info a1b2c3d4
bp-tunnel ls

Features

  • Multi-agent tunnels - any number of agents can join a channel
  • Broadcast & direct messaging - to=None broadcasts, to="agent" sends direct
  • Blocking patterns - wait_for() and send_wait() for turn-based workflows
  • Admin system - creator is auto-admin, can promote/demote others
  • Pluggable transport - abstract Transport base class, file-based included
  • Selective filtering - from_ parameter filters without consuming other messages
  • Atomic writes - tempfile + rename for crash safety
  • File locking - fcntl locks for concurrent access
  • Path traversal protection - strict name validation

Architecture

Python API / AI Tools / CLI
         |
    Tunnel (agent-centric wrapper)
         |
    Transport (abstract interface)
         |
    FileTransport (/tmp/bp-tunnel/)
         |
    Message (YAML format)

File Transport Layout

/tmp/bp-tunnel/
  {tunnel-id}/
    _meta.yaml        # {admins: [...], members: [...]}
    _meta.lock         # fcntl lock file
    {agent-name}/      # mailbox directory
      {timestamp}-{id}.yaml   # message files

License

MIT

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

bp_tunnel-0.2.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

bp_tunnel-0.2.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file bp_tunnel-0.2.0.tar.gz.

File metadata

  • Download URL: bp_tunnel-0.2.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for bp_tunnel-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ab22be2382e72a6f04b7a852ab4a582fa868e81d96cb56d74805f4c6f719dfe5
MD5 2b50edb42e825dfecd5bad365478983a
BLAKE2b-256 afdca2a23420e292f18d9da5d1cc8b69a74820474d2187ab888f653a07a407fe

See more details on using hashes here.

File details

Details for the file bp_tunnel-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bp_tunnel-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for bp_tunnel-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e8def3c617d320df9fd744cac6507dc492d3815da9fbfa37511607a13262cb4
MD5 435b451f25c1cb70304683ccac44f3d5
BLAKE2b-256 30b72c6d61814aa5f6c798d5a8301e1d274ce0903ced84746237a8d4ebe11bd4

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