Skip to main content

Python SDK for Intent Bus — a dead-simple distributed job bus

Project description

Intent Bus SDK 🚌

PyPI version License: MIT

The official Python client for the Intent Protocol.

Looking for the server?
This repository contains only the Python SDK.
To self-host the bus, see the main project:
https://github.com/dsecurity49/Intent-Bus


🚀 What is Intent Bus?

Intent Bus is a lightweight, decentralized job execution protocol.

  • Publish tasks from anywhere
  • Execute them on any machine
  • No queues, brokers, or infrastructure required

This SDK provides:

  • Secure request signing (HMAC-SHA256)
  • Automatic retries (where safe)
  • Polling + worker loop abstraction
  • Zero-config authentication

📦 Installation

pip install intent-bus

🔐 Zero-Config Authentication

The SDK automatically resolves your API key in this order:

  1. Explicit api_key argument
  2. INTENT_API_KEY environment variable
  3. Local file: ~/.apikey

Example:

echo "your_api_key_here" > ~/.apikey
chmod 600 ~/.apikey

⚡ Quickstart

from intent_bus import IntentClient

bus = IntentClient()

📤 1. Publishing an Intent (Producer)

result = bus.publish(
    goal="notify",
    payload={"message": "System backup complete."}
)

print(f"Dispatched Intent ID: {result['id']}")

📥 2. Listening for Intents (Worker)

def handle_notification(payload):
    print(f"Received: {payload['message']}")

bus.listen(goal="notify", handler=handle_notification)

🗃️ 3. Ephemeral Key-Value Store

bus.set("last_sync_time", "1682800000", ttl=600)
timestamp = bus.get("last_sync_time")

⚙️ Advanced Usage

Custom Hosts (Self-Hosting)

bus = IntentClient(
    base_url="https://your-private-bus.com",
    api_key="your_key"
)

Strict Idempotency

bus.publish(
    goal="process_payment",
    payload={"user": "alice", "amount": 50},
    idempotency_key="tx_987654321"
)

🔁 Retry Behavior

Operation Retries Reason
publish ✅ Yes Idempotent
set ✅ Yes Idempotent
get ✅ Yes Safe read
claim ❌ No State-changing
fulfill ❌ No Prevent duplicates
fail ❌ No Prevent duplicates

🔒 Security Model

Strict Authentication (HMAC-SHA256):

  • X-API-KEY
  • X-Timestamp
  • X-Nonce
  • X-Signature

Provides:

  • Replay protection
  • Integrity
  • Authenticity

⚠️ Worker Safety

  • Workers MUST be idempotent
  • Do NOT execute raw user input blindly
  • Prefer whitelisting
  • Avoid storing secrets in payloads

❗ Error Handling

from intent_bus import (
    IntentBusError,
    IntentBusAuthError,
    IntentBusRateLimitError
)

🧪 Minimal Example

from intent_bus import IntentClient

bus = IntentClient()

def handler(payload):
    print("Job:", payload)

bus.listen(goal="test", handler=handler)

🧠 Design Principles

  • Protocol First
  • Zero-Ops
  • At-Least-Once Delivery
  • Explicit Failures

📜 License

MIT License © 2026 Dsecurity

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

intent_bus-1.1.1.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.

intent_bus-1.1.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file intent_bus-1.1.1.tar.gz.

File metadata

  • Download URL: intent_bus-1.1.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/34.0 requests/2.32.5 requests-toolbelt/1.0.0 urllib3/2.6.3 tqdm/4.67.3 importlib-metadata/9.0.0 keyring/25.7.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.13.13

File hashes

Hashes for intent_bus-1.1.1.tar.gz
Algorithm Hash digest
SHA256 170e1dc6af5e565a101c7ff878f3dd5b02460e4af20e144f6282490d364bc45a
MD5 5025038ccea8da9a400955796ebbca2e
BLAKE2b-256 b610fd93d9bad9a92130a8864ce14bf4219af5697c57c723031bc379ea7b38a4

See more details on using hashes here.

File details

Details for the file intent_bus-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: intent_bus-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/34.0 requests/2.32.5 requests-toolbelt/1.0.0 urllib3/2.6.3 tqdm/4.67.3 importlib-metadata/9.0.0 keyring/25.7.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.13.13

File hashes

Hashes for intent_bus-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0a46690119aa5de10959098f002699a701c9307c2c6ae7ace19005aedd33fef
MD5 e94d3edb9ea85b24d149c2b0a3379334
BLAKE2b-256 9ec1088a1d91260f5a6eef7d4df94db820547ded58401f538cf72ccf2190780a

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