xml-pipeline/agentserver/message_bus/__init__.py
dullfig 82b5fcdd78 Replace MessageBus with aiostream-based StreamPump
Major refactor of the message pump architecture:

- Replace bus.py with stream_pump.py using aiostream for composable
  stream processing with natural fan-out via flatmap
- Add to_id field to MessageState for explicit routing
- Fix routing to use to_id.class format (e.g., "greeter.greeting")
- Generate XSD schemas from xmlified payload classes
- Fix xmlable imports (absolute -> relative) and parse_element ctx

New features:
- handlers/hello.py: Sample Greeting/GreetingResponse handler
- config/organism.yaml: Sample organism configuration
- 41 tests (31 unit + 10 integration) all passing

Schema changes:
- envelope.xsd: Allow any namespace payloads (##other -> ##any)

Dependencies added to pyproject.toml:
- aiostream>=0.5 (core dependency)
- pyhumps, termcolor (for xmlable)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 10:41:17 -08:00

44 lines
1.1 KiB
Python

"""
message_bus — Stream-based message pump for AgentServer v2.1
The message pump handles message flow through the organism:
- YAML config → bootstrap → pump → handlers → responses → loop
Key classes:
StreamPump Main pump class (queue-backed, aiostream-powered)
ConfigLoader Load organism.yaml and resolve imports
Listener Runtime listener with handler and routing info
MessageState Message flowing through pipeline steps
Usage:
from agentserver.message_bus import StreamPump, bootstrap
pump = await bootstrap("config/organism.yaml")
await pump.inject(initial_message, thread_id, from_id)
await pump.run()
"""
from agentserver.message_bus.stream_pump import (
StreamPump,
ConfigLoader,
Listener,
ListenerConfig,
OrganismConfig,
bootstrap,
)
from agentserver.message_bus.message_state import (
MessageState,
HandlerMetadata,
)
__all__ = [
"StreamPump",
"ConfigLoader",
"Listener",
"ListenerConfig",
"OrganismConfig",
"MessageState",
"HandlerMetadata",
"bootstrap",
]