Files
a433c483c1 fix: document bootstrap entrypoints in examples (fixes #71) (#96)
* feat: standardize bootstrap entrypoint to 'aiui run app.py' across examples

Standardizes platform bootstrap patterns across examples per issue #71:

- Update examples README table to use 'aiui run app.py' consistently
- Update docstrings in examples 10, 12, 19-21 to show 'aiui run' instead of 'python app.py'
- Remove fragmented bootstrap approaches (uvicorn.run, asyncio patterns)
- Enforce single bootstrap SSOT as designed in CLI

Co-authored-by: Mervin Praison <[email protected]>

* feat: consolidate bootstrap entrypoints - auto-detect gateway apps (fixes #71)

- Add bootstrap detection in CLI run command
- Auto-detect gateway pattern (async main + AIUIGateway imports)
- Auto-switch to praisonai backend for gateway apps
- Delegate to user-defined main() when present
- Remove sys.path hacks from example 14
- Update examples README to show unified aiui run entrypoint
- Add BOOTSTRAP.md documentation for migration patterns

Co-authored-by: Mervin Praison <[email protected]>

* fix: resolve critical bootstrap entrypoint issues

- Fix AST parsing bug in gateway auto-detection (cli.py:1419)
- Revert background bots (email-bot, agentmail-bot) to python app.py
- Revert custom UI apps (agent-dashboard) to python app.py
- Update README.md to reflect correct run commands
- Fix import formatting and remove unused imports

These changes ensure that:
1. Gateway auto-detection works correctly by properly checking ast.alias.name
2. Background bots execute their __main__ blocks and don't start unnecessary web servers
3. Custom UI apps register their custom routes in __main__ blocks
4. Documentation matches actual working run commands

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Mervin Praison <[email protected]>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mervin Praison <[email protected]>
Co-authored-by: Mervin Praison <[email protected]>
Co-authored-by: Cursor <[email protected]>
2026-06-15 16:36:35 +01:00

1.8 KiB

Bootstrap Architecture

PraisonAIUI provides a unified bootstrap entrypoint through aiui run app.py that automatically detects and handles different application patterns.

Supported Patterns

1. Chat Applications

import praisonaiui as aiui

@aiui.reply
async def on_message(message: str):
    await aiui.say(f"You said: {message}")

Run: aiui run app.py

2. Dashboard Applications

from praisonaiui.server import create_app
import uvicorn

if __name__ == "__main__":
    app = create_app()
    uvicorn.run(app, host="0.0.0.0", port=8082)

Run: aiui run app.py (automatically detects create_app() pattern)

3. Gateway Applications

import asyncio
from praisonaiui.integration import AIUIGateway

async def main():
    gateway = AIUIGateway(host="0.0.0.0", port=8083)
    # ... register agents
    await gateway.start()

if __name__ == "__main__":
    asyncio.run(main())

Run: aiui run app.py (auto-detects gateway pattern and switches to praisonai backend)

Bootstrap Detection

The CLI automatically detects application types:

  • Gateway Pattern: Async main() function + AIUIGateway imports → Uses praisonai backend
  • Dashboard Pattern: create_app() usage → Uses standalone backend
  • Chat Pattern: @reply decorators → Uses standalone backend

Migration Guide

From Manual Bootstrap

Before:

python app.py

After:

aiui run app.py

Benefits

  • Consistent configuration loading
  • Unified port/host management
  • Doctor compatibility
  • Reload support via --reload
  • Backend auto-detection

Escape Hatch

For special cases, explicit backend selection is still supported:

aiui run app.py --backend praisonai  # Force gateway backend
aiui run app.py --backend standalone # Force standalone backend