xml-pipeline/examples/console/__main__.py
dullfig e653d63bc1 Rename agentserver to xml_pipeline, add console example
OSS restructuring for open-core model:
- Rename package from agentserver/ to xml_pipeline/
- Update all imports (44 Python files, 31 docs/configs)
- Update pyproject.toml for OSS distribution (v0.3.0)
- Move prompt_toolkit from core to optional [console] extra
- Remove auth/server/lsp from core optional deps (-> Nextra)

New console example in examples/console/:
- Self-contained demo with handlers and config
- Uses prompt_toolkit (optional, falls back to input())
- No password auth, no TUI, no LSP — just the basics
- Shows how to use xml-pipeline as a library

Import changes:
- from agentserver.* -> from xml_pipeline.*
- CLI entry points updated: xml_pipeline.cli:main

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

60 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""
Run the console example.
Usage:
python -m examples.console [config.yaml]
If no config is specified, uses the bundled organism.yaml.
"""
import asyncio
import sys
from pathlib import Path
async def main(config_path: str) -> None:
"""Boot organism and run console."""
from xml_pipeline.message_bus import bootstrap
from .console import Console
# Bootstrap the pump
pump = await bootstrap(config_path)
# Create and run console
console = Console(pump)
# Start pump in background
pump_task = asyncio.create_task(pump.run())
try:
await console.run()
finally:
# Cleanup
pump_task.cancel()
try:
await pump_task
except asyncio.CancelledError:
pass
await pump.shutdown()
print("Goodbye!")
if __name__ == "__main__":
# Find config
args = sys.argv[1:]
if args:
config_path = args[0]
else:
# Use bundled config
config_path = str(Path(__file__).parent / "organism.yaml")
if not Path(config_path).exists():
print(f"Config not found: {config_path}")
sys.exit(1)
try:
asyncio.run(main(config_path))
except KeyboardInterrupt:
print("\nInterrupted")