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 Tunnel

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

# Agent 2: join and receive
bob = Tunnel.join("my-tunnel", "bob")
msg = bob.receive()                    # non-blocking, single message
msgs = bob.receive_all()              # drain all messages
msg = bob.wait_for(from_="alice")      # blocking wait
msg = bob.wait_for(timeout=10)         # with timeout

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

result = create_tunnel("manager", name="team")
# {"tunnel_id": "team", "agent": "manager", "role": "admin"}

join_tunnel("team", "worker")
send_message("team", "manager", "build the feature", to="worker")

msg = wait_for_message("team", "worker", from_agent="manager", timeout=30)
# {"status": "message", "from": "manager", "message": "build the feature", "ts": ...}

CLI

# Set your identity once (or use --as every time)
export BP_TUNNEL_AGENT=alice

# Create a tunnel (named or random)
bp-tunnel create my-tunnel
bp-tunnel create                   # random hex ID

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

# Send messages
bp-tunnel send my-tunnel "hello"
bp-tunnel send my-tunnel "hey bob" --to bob

# Receive
bp-tunnel recv my-tunnel --as bob
bp-tunnel recv my-tunnel --as bob --all          # drain all
bp-tunnel recv my-tunnel --as bob --wait         # block until message
bp-tunnel recv my-tunnel --as bob --from alice

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

# JSON output for scripting
bp-tunnel ls --json
bp-tunnel recv my-tunnel --as bob --json

# Admin operations
bp-tunnel promote my-tunnel bob
bp-tunnel demote my-tunnel bob
bp-tunnel destroy my-tunnel

# Info
bp-tunnel info my-tunnel
bp-tunnel ls

Features

  • Multi-agent tunnels — any number of agents can join a channel
  • Named tunnels — human-readable names or auto-generated hex IDs
  • Broadcast & direct messagingto=None broadcasts, to="agent" sends direct
  • Blocking patternswait_for(), send_wait(), receive_all() for workflows
  • Admin system — creator is auto-admin, can promote/demote/destroy
  • Pluggable transport — abstract Transport base class, file-based included
  • AI tool interface — stateless dict in/out functions for LLM tool calling
  • Selective filteringfrom_ parameter filters without consuming other messages
  • Atomic writes — tempfile + rename for crash safety
  • File locking — fcntl locks for concurrent access
  • JSON output--json flag for machine-readable CLI output
  • Env var identityBP_TUNNEL_AGENT to avoid --as on every command

Architecture

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

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.3.0.tar.gz (9.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.3.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bp_tunnel-0.3.0.tar.gz
  • Upload date:
  • Size: 9.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.3.0.tar.gz
Algorithm Hash digest
SHA256 ab4315c2af34736dbbac20c0bdf6861c15c8cc4c101a6ea4b21baa2cc2ee8260
MD5 ba48da8867158fcf9e2cf4da36942159
BLAKE2b-256 bcc02e4356432c096516b6ac1ca221b0baf43d0c2a134932b5e4047e810e7eb8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bp_tunnel-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21d39947fdda4afe30cb4ee39ea34ee9a578e3206f3b6435bd69864c8242edbf
MD5 6e8799d82a036215f1d5e6b86a75d657
BLAKE2b-256 5a287bff05e820aaf04c5d0778cce52d6046f79cbd111d571ddda1b78c597e50

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