Skip to main content

Outbound routing, chunking, and delivery planning for multi-channel AI systems

Project description

nodus-delivery

Outbound routing, chunking, and delivery planning for multi-channel AI systems.

Resolves the right channel adapter for a response, splits long content into channel-appropriate chunks, and delivers each chunk in order. Depends on nodus-channels for the ChannelRegistry and ChannelAdapter protocol.

Status: v0.1.0 — prepared, not yet published.


Install

pip install nodus-delivery

Requires nodus-channels>=0.1.0.


What it provides

Component Purpose
DeliveryPlan Describes where and how to send a response
SizeChunker Split at word boundaries up to a max character count
ParagraphChunker Split on paragraph breaks, respecting a max size
MarkdownBlockChunker Preserve code blocks and headers across splits
strip_markdown Remove markdown formatting → plain text
DeliveryRouter Resolve adapter, chunk, and send; build plan from inbound message

Quick start

from nodus_channels import ChannelRegistry
from nodus_delivery import DeliveryRouter, DeliveryPlan, SizeChunker

registry = ChannelRegistry()
registry.register(my_slack_adapter)

router = DeliveryRouter(registry, default_chunker=SizeChunker(max_chars=2000))

plan = DeliveryPlan(
    channel_id="slack",
    peer_id="U123",
    content="A very long response that may need chunking...",
)

await router.deliver(plan)

DeliveryPlan

from nodus_delivery import DeliveryPlan

plan = DeliveryPlan(
    channel_id="slack",
    peer_id="U123",
    content="Response text",
    thread_id="T456",       # optional: reply in a thread
    reply_to_id="M789",     # optional: reply to a specific message
    strip_md=False,         # strip markdown before chunking (default False)
    chunker=None,           # override router's default chunker
)

Chunking strategies

SizeChunker

Splits at word boundaries. Safe for any channel.

from nodus_delivery import SizeChunker
chunker = SizeChunker(max_chars=2000)
chunks = chunker.chunk("Long text...")   # list[str]

ParagraphChunker

Splits on \n\n paragraph breaks first; falls back to size if a paragraph exceeds max_chars.

from nodus_delivery import ParagraphChunker
chunker = ParagraphChunker(max_chars=2000)

MarkdownBlockChunker

Keeps code fences (```) and headers (#, ##) intact. Never splits inside a code block.

from nodus_delivery import MarkdownBlockChunker
chunker = MarkdownBlockChunker(max_chars=2000)

DeliveryRouter

from nodus_delivery import DeliveryRouter

router = DeliveryRouter(
    registry,
    default_chunker=ParagraphChunker(max_chars=2000),
)

# Build a plan from an inbound Message (replies to sender on same channel)
plan = router.plan_from_message(inbound_message, content="Here is my response.")

# Deliver — sends all chunks in order, returns list of message IDs
msg_ids = await router.deliver(plan)

If no adapter is registered for channel_id, deliver raises KeyError.


strip_markdown

from nodus_delivery import strip_markdown

plain = strip_markdown("**bold** and `code` and [link](url)")
# → "bold and code and link"

Useful when delivering to channels that don't render markdown (e.g., SMS, voice).


Design

  • One required dependency: nodus-channels for ChannelRegistry, ChannelAdapter, and Message types.
  • Protocol-based chunking. Any callable satisfying ChunkStrategy (chunk(text) -> list[str]) works — no inheritance needed.
  • Async delivery. DeliveryRouter.deliver() is async; each chunk is awaited in sequence to preserve ordering.

Development

pip install -e ".[dev]"
# Also install nodus-channels for tests:
pip install -e "C:/dev/nodus-channels"
pytest tests/ -q

License

MIT — see LICENSE.

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

nodus_delivery-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

nodus_delivery-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file nodus_delivery-0.1.0.tar.gz.

File metadata

  • Download URL: nodus_delivery-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for nodus_delivery-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e4093dc432e480678e28cef1fd01bd425b874790e27c7ed5dcd0265a22268c76
MD5 253e279c42f0921b63e1b7bd27ab002c
BLAKE2b-256 f619289937580be351d91dc1e7a9f79961c38d17b9c33f14d43e365f416ddb1d

See more details on using hashes here.

File details

Details for the file nodus_delivery-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nodus_delivery-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for nodus_delivery-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6543297ef1a16e60412def43220892b11f6aa15d70cefbe8258c5d7318a3cb21
MD5 541f142106a9845c560414267271f3ff
BLAKE2b-256 786e2bcfa35dc55531972ffa1b50521202608069790d96ab4bfe843cbed60aa8

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