praisonai-code 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- praisonai_code/__init__.py +17 -0
- praisonai_code/cli/__init__.py +12 -0
- praisonai_code/cli/_forward_shim.py +10 -0
- praisonai_code/cli/_paths.py +88 -0
- praisonai_code/cli/_warnings.py +58 -0
- praisonai_code/cli/app.py +757 -0
- praisonai_code/cli/approval_backend.py +272 -0
- praisonai_code/cli/branding.py +94 -0
- praisonai_code/cli/commands/__init__.py +114 -0
- praisonai_code/cli/commands/acp.py +80 -0
- praisonai_code/cli/commands/agent.py +116 -0
- praisonai_code/cli/commands/agents.py +80 -0
- praisonai_code/cli/commands/app.py +139 -0
- praisonai_code/cli/commands/attach.py +95 -0
- praisonai_code/cli/commands/audit.py +102 -0
- praisonai_code/cli/commands/auth.py +508 -0
- praisonai_code/cli/commands/batch.py +848 -0
- praisonai_code/cli/commands/benchmark.py +286 -0
- praisonai_code/cli/commands/browser.py +299 -0
- praisonai_code/cli/commands/call.py +45 -0
- praisonai_code/cli/commands/chat.py +332 -0
- praisonai_code/cli/commands/checkpoint.py +170 -0
- praisonai_code/cli/commands/code.py +276 -0
- praisonai_code/cli/commands/command.py +114 -0
- praisonai_code/cli/commands/commit.py +47 -0
- praisonai_code/cli/commands/completion.py +333 -0
- praisonai_code/cli/commands/config.py +681 -0
- praisonai_code/cli/commands/context.py +414 -0
- praisonai_code/cli/commands/daemon.py +203 -0
- praisonai_code/cli/commands/debug.py +142 -0
- praisonai_code/cli/commands/deploy.py +71 -0
- praisonai_code/cli/commands/diag.py +55 -0
- praisonai_code/cli/commands/docs.py +1575 -0
- praisonai_code/cli/commands/doctor.py +332 -0
- praisonai_code/cli/commands/endpoints.py +51 -0
- praisonai_code/cli/commands/environment.py +179 -0
- praisonai_code/cli/commands/eval.py +131 -0
- praisonai_code/cli/commands/examples.py +953 -0
- praisonai_code/cli/commands/flow.py +436 -0
- praisonai_code/cli/commands/github.py +752 -0
- praisonai_code/cli/commands/hooks.py +74 -0
- praisonai_code/cli/commands/init.py +174 -0
- praisonai_code/cli/commands/knowledge.py +440 -0
- praisonai_code/cli/commands/langextract.py +120 -0
- praisonai_code/cli/commands/langfuse.py +984 -0
- praisonai_code/cli/commands/loop.py +211 -0
- praisonai_code/cli/commands/lsp.py +112 -0
- praisonai_code/cli/commands/managed.py +659 -0
- praisonai_code/cli/commands/mcp.py +763 -0
- praisonai_code/cli/commands/memory.py +298 -0
- praisonai_code/cli/commands/models.py +264 -0
- praisonai_code/cli/commands/n8n.py +326 -0
- praisonai_code/cli/commands/obs.py +19 -0
- praisonai_code/cli/commands/package.py +76 -0
- praisonai_code/cli/commands/paths.py +106 -0
- praisonai_code/cli/commands/permissions.py +272 -0
- praisonai_code/cli/commands/plugins.py +609 -0
- praisonai_code/cli/commands/port.py +530 -0
- praisonai_code/cli/commands/profile.py +466 -0
- praisonai_code/cli/commands/publish.py +193 -0
- praisonai_code/cli/commands/rag.py +913 -0
- praisonai_code/cli/commands/realtime.py +52 -0
- praisonai_code/cli/commands/recipe.py +684 -0
- praisonai_code/cli/commands/registry.py +59 -0
- praisonai_code/cli/commands/replay.py +830 -0
- praisonai_code/cli/commands/research.py +49 -0
- praisonai_code/cli/commands/retrieval.py +377 -0
- praisonai_code/cli/commands/rules.py +71 -0
- praisonai_code/cli/commands/run.py +1573 -0
- praisonai_code/cli/commands/sandbox.py +371 -0
- praisonai_code/cli/commands/schedule.py +529 -0
- praisonai_code/cli/commands/serve.py +690 -0
- praisonai_code/cli/commands/session.py +450 -0
- praisonai_code/cli/commands/setup.py +174 -0
- praisonai_code/cli/commands/skills.py +545 -0
- praisonai_code/cli/commands/standardise.py +711 -0
- praisonai_code/cli/commands/templates.py +54 -0
- praisonai_code/cli/commands/test.py +558 -0
- praisonai_code/cli/commands/todo.py +74 -0
- praisonai_code/cli/commands/tools.py +205 -0
- praisonai_code/cli/commands/traces.py +145 -0
- praisonai_code/cli/commands/tracker.py +852 -0
- praisonai_code/cli/commands/train.py +613 -0
- praisonai_code/cli/commands/ui.py +172 -0
- praisonai_code/cli/commands/up.py +354 -0
- praisonai_code/cli/commands/validate.py +291 -0
- praisonai_code/cli/commands/version.py +101 -0
- praisonai_code/cli/commands/workflow.py +97 -0
- praisonai_code/cli/config_loader.py +437 -0
- praisonai_code/cli/configuration/__init__.py +27 -0
- praisonai_code/cli/configuration/config.schema.json +57 -0
- praisonai_code/cli/configuration/credentials.py +446 -0
- praisonai_code/cli/configuration/loader.py +364 -0
- praisonai_code/cli/configuration/model_resolver.py +161 -0
- praisonai_code/cli/configuration/oauth.py +389 -0
- praisonai_code/cli/configuration/paths.py +224 -0
- praisonai_code/cli/configuration/resolver.py +687 -0
- praisonai_code/cli/configuration/schema.py +317 -0
- praisonai_code/cli/execution/__init__.py +99 -0
- praisonai_code/cli/execution/core.py +208 -0
- praisonai_code/cli/execution/profiler.py +898 -0
- praisonai_code/cli/execution/request.py +85 -0
- praisonai_code/cli/execution/result.py +74 -0
- praisonai_code/cli/fallback_schema.py +416 -0
- praisonai_code/cli/features/__init__.py +278 -0
- praisonai_code/cli/features/_endpoint_registry.py +64 -0
- praisonai_code/cli/features/_search_registry.py +43 -0
- praisonai_code/cli/features/acp.py +236 -0
- praisonai_code/cli/features/action_orchestrator.py +576 -0
- praisonai_code/cli/features/agent_scheduler.py +773 -0
- praisonai_code/cli/features/agent_tools.py +603 -0
- praisonai_code/cli/features/agents.py +397 -0
- praisonai_code/cli/features/at_mentions.py +471 -0
- praisonai_code/cli/features/audit_cli.py +270 -0
- praisonai_code/cli/features/auto_memory.py +182 -0
- praisonai_code/cli/features/auto_mode.py +552 -0
- praisonai_code/cli/features/autonomy_mode.py +546 -0
- praisonai_code/cli/features/background.py +356 -0
- praisonai_code/cli/features/base.py +168 -0
- praisonai_code/cli/features/benchmark.py +1462 -0
- praisonai_code/cli/features/capabilities.py +1326 -0
- praisonai_code/cli/features/checkpoints.py +345 -0
- praisonai_code/cli/features/cli_profiler.py +335 -0
- praisonai_code/cli/features/code_intelligence.py +666 -0
- praisonai_code/cli/features/compaction.py +294 -0
- praisonai_code/cli/features/compare.py +534 -0
- praisonai_code/cli/features/config_hierarchy.py +366 -0
- praisonai_code/cli/features/context_manager.py +597 -0
- praisonai_code/cli/features/cost_tracker.py +514 -0
- praisonai_code/cli/features/csv_test_runner.py +736 -0
- praisonai_code/cli/features/custom_definitions.py +790 -0
- praisonai_code/cli/features/debug.py +810 -0
- praisonai_code/cli/features/deploy.py +605 -0
- praisonai_code/cli/features/diag.py +289 -0
- praisonai_code/cli/features/display_jsonl.py +173 -0
- praisonai_code/cli/features/doctor/__init__.py +63 -0
- praisonai_code/cli/features/doctor/checks/__init__.py +29 -0
- praisonai_code/cli/features/doctor/checks/acp_checks.py +220 -0
- praisonai_code/cli/features/doctor/checks/bot_checks.py +340 -0
- praisonai_code/cli/features/doctor/checks/config_checks.py +373 -0
- praisonai_code/cli/features/doctor/checks/db_checks.py +366 -0
- praisonai_code/cli/features/doctor/checks/env_checks.py +637 -0
- praisonai_code/cli/features/doctor/checks/gateway_checks.py +387 -0
- praisonai_code/cli/features/doctor/checks/lsp_checks.py +231 -0
- praisonai_code/cli/features/doctor/checks/mcp_checks.py +367 -0
- praisonai_code/cli/features/doctor/checks/memory_checks.py +268 -0
- praisonai_code/cli/features/doctor/checks/network_checks.py +251 -0
- praisonai_code/cli/features/doctor/checks/obs_checks.py +328 -0
- praisonai_code/cli/features/doctor/checks/packaging_checks.py +422 -0
- praisonai_code/cli/features/doctor/checks/performance_checks.py +235 -0
- praisonai_code/cli/features/doctor/checks/permissions_checks.py +259 -0
- praisonai_code/cli/features/doctor/checks/runtime_checks.py +650 -0
- praisonai_code/cli/features/doctor/checks/runtime_migration_checks.py +220 -0
- praisonai_code/cli/features/doctor/checks/selftest_checks.py +322 -0
- praisonai_code/cli/features/doctor/checks/serve_checks.py +426 -0
- praisonai_code/cli/features/doctor/checks/skills_checks.py +327 -0
- praisonai_code/cli/features/doctor/checks/tools_checks.py +371 -0
- praisonai_code/cli/features/doctor/engine.py +266 -0
- praisonai_code/cli/features/doctor/formatters.py +377 -0
- praisonai_code/cli/features/doctor/handler.py +564 -0
- praisonai_code/cli/features/doctor/models.py +276 -0
- praisonai_code/cli/features/doctor/registry.py +239 -0
- praisonai_code/cli/features/endpoints.py +1016 -0
- praisonai_code/cli/features/eval.py +559 -0
- praisonai_code/cli/features/examples.py +707 -0
- praisonai_code/cli/features/external_agents.py +231 -0
- praisonai_code/cli/features/fast_context.py +410 -0
- praisonai_code/cli/features/file_history.py +320 -0
- praisonai_code/cli/features/flow_display.py +566 -0
- praisonai_code/cli/features/git_attribution.py +159 -0
- praisonai_code/cli/features/git_integration.py +651 -0
- praisonai_code/cli/features/guardrail.py +171 -0
- praisonai_code/cli/features/handoff.py +252 -0
- praisonai_code/cli/features/hooks.py +583 -0
- praisonai_code/cli/features/hybrid_workflow.py +391 -0
- praisonai_code/cli/features/image.py +384 -0
- praisonai_code/cli/features/interactive_core_headless.py +450 -0
- praisonai_code/cli/features/interactive_runtime.py +600 -0
- praisonai_code/cli/features/interactive_test_harness.py +537 -0
- praisonai_code/cli/features/interactive_tools.py +428 -0
- praisonai_code/cli/features/interactive_tui.py +603 -0
- praisonai_code/cli/features/job_workflow.py +906 -0
- praisonai_code/cli/features/jobs.py +632 -0
- praisonai_code/cli/features/knowledge.py +531 -0
- praisonai_code/cli/features/knowledge_cli.py +438 -0
- praisonai_code/cli/features/lite.py +244 -0
- praisonai_code/cli/features/logs.py +200 -0
- praisonai_code/cli/features/lsp_cli.py +225 -0
- praisonai_code/cli/features/lsp_diagnostics.py +185 -0
- praisonai_code/cli/features/mcp.py +344 -0
- praisonai_code/cli/features/message_queue.py +587 -0
- praisonai_code/cli/features/metrics.py +210 -0
- praisonai_code/cli/features/migrate.py +1329 -0
- praisonai_code/cli/features/migration_flow.py +463 -0
- praisonai_code/cli/features/migration_spec.py +276 -0
- praisonai_code/cli/features/n8n.py +703 -0
- praisonai_code/cli/features/observability.py +293 -0
- praisonai_code/cli/features/ollama.py +361 -0
- praisonai_code/cli/features/output_modes.py +155 -0
- praisonai_code/cli/features/output_style.py +273 -0
- praisonai_code/cli/features/package.py +631 -0
- praisonai_code/cli/features/performance.py +308 -0
- praisonai_code/cli/features/persistence.py +636 -0
- praisonai_code/cli/features/profiler/__init__.py +81 -0
- praisonai_code/cli/features/profiler/core.py +558 -0
- praisonai_code/cli/features/profiler/optimizations.py +652 -0
- praisonai_code/cli/features/profiler/suite.py +386 -0
- praisonai_code/cli/features/queue/__init__.py +73 -0
- praisonai_code/cli/features/queue/manager.py +435 -0
- praisonai_code/cli/features/queue/models.py +289 -0
- praisonai_code/cli/features/queue/persistence.py +564 -0
- praisonai_code/cli/features/queue/scheduler.py +529 -0
- praisonai_code/cli/features/queue/worker.py +400 -0
- praisonai_code/cli/features/recipe.py +2187 -0
- praisonai_code/cli/features/recipe_creator.py +996 -0
- praisonai_code/cli/features/recipe_optimizer.py +1364 -0
- praisonai_code/cli/features/recipe_prompts.py +226 -0
- praisonai_code/cli/features/registry.py +229 -0
- praisonai_code/cli/features/repo_map.py +860 -0
- praisonai_code/cli/features/router.py +466 -0
- praisonai_code/cli/features/safe_shell.py +427 -0
- praisonai_code/cli/features/sandbox_cli.py +283 -0
- praisonai_code/cli/features/sandbox_executor.py +536 -0
- praisonai_code/cli/features/sdk_knowledge.py +500 -0
- praisonai_code/cli/features/session.py +222 -0
- praisonai_code/cli/features/session_checkpoints.py +208 -0
- praisonai_code/cli/features/setup/__init__.py +9 -0
- praisonai_code/cli/features/setup/handler.py +355 -0
- praisonai_code/cli/features/setup/templates.py +62 -0
- praisonai_code/cli/features/skills.py +940 -0
- praisonai_code/cli/features/slash_commands.py +692 -0
- praisonai_code/cli/features/telemetry.py +179 -0
- praisonai_code/cli/features/templates.py +1390 -0
- praisonai_code/cli/features/thinking.py +343 -0
- praisonai_code/cli/features/todo.py +334 -0
- praisonai_code/cli/features/tools.py +680 -0
- praisonai_code/cli/features/tui/__init__.py +83 -0
- praisonai_code/cli/features/tui/app.py +871 -0
- praisonai_code/cli/features/tui/cli.py +580 -0
- praisonai_code/cli/features/tui/config.py +150 -0
- praisonai_code/cli/features/tui/debug.py +526 -0
- praisonai_code/cli/features/tui/events.py +99 -0
- praisonai_code/cli/features/tui/mock_provider.py +328 -0
- praisonai_code/cli/features/tui/orchestrator.py +652 -0
- praisonai_code/cli/features/tui/screens/__init__.py +50 -0
- praisonai_code/cli/features/tui/screens/help.py +157 -0
- praisonai_code/cli/features/tui/screens/main.py +568 -0
- praisonai_code/cli/features/tui/screens/queue.py +174 -0
- praisonai_code/cli/features/tui/screens/session.py +124 -0
- praisonai_code/cli/features/tui/screens/settings.py +148 -0
- praisonai_code/cli/features/tui/session_store.py +198 -0
- praisonai_code/cli/features/tui/widgets/__init__.py +56 -0
- praisonai_code/cli/features/tui/widgets/chat.py +263 -0
- praisonai_code/cli/features/tui/widgets/command_popup.py +258 -0
- praisonai_code/cli/features/tui/widgets/composer.py +292 -0
- praisonai_code/cli/features/tui/widgets/file_popup.py +207 -0
- praisonai_code/cli/features/tui/widgets/queue_panel.py +223 -0
- praisonai_code/cli/features/tui/widgets/status.py +181 -0
- praisonai_code/cli/features/tui/widgets/tool_panel.py +307 -0
- praisonai_code/cli/features/wizard.py +289 -0
- praisonai_code/cli/features/workflow.py +802 -0
- praisonai_code/cli/features/yaml_utils.py +321 -0
- praisonai_code/cli/interactive/__init__.py +48 -0
- praisonai_code/cli/interactive/async_tui.py +1218 -0
- praisonai_code/cli/interactive/config.py +139 -0
- praisonai_code/cli/interactive/core.py +618 -0
- praisonai_code/cli/interactive/events.py +131 -0
- praisonai_code/cli/interactive/frontends/__init__.py +31 -0
- praisonai_code/cli/interactive/frontends/rich_frontend.py +462 -0
- praisonai_code/cli/interactive/frontends/textual_frontend.py +157 -0
- praisonai_code/cli/interactive/praison_io.py +502 -0
- praisonai_code/cli/interactive/repl.py +297 -0
- praisonai_code/cli/interactive/split_tui.py +456 -0
- praisonai_code/cli/interactive/tui_app.py +457 -0
- praisonai_code/cli/langfuse_client.py +360 -0
- praisonai_code/cli/main.py +7421 -0
- praisonai_code/cli/output/__init__.py +25 -0
- praisonai_code/cli/output/console.py +456 -0
- praisonai_code/cli/output/event_bridge.py +191 -0
- praisonai_code/cli/schedule_cli.py +54 -0
- praisonai_code/cli/schema_provider.py +23 -0
- praisonai_code/cli/session/__init__.py +16 -0
- praisonai_code/cli/session/resume.py +148 -0
- praisonai_code/cli/session/unified.py +548 -0
- praisonai_code/cli/state/__init__.py +31 -0
- praisonai_code/cli/state/identifiers.py +161 -0
- praisonai_code/cli/state/project_sessions.py +383 -0
- praisonai_code/cli/state/sessions.py +390 -0
- praisonai_code/cli/ui/__init__.py +160 -0
- praisonai_code/cli/ui/config.py +46 -0
- praisonai_code/cli/ui/events.py +61 -0
- praisonai_code/cli/ui/mg_backend.py +342 -0
- praisonai_code/cli/ui/plain.py +133 -0
- praisonai_code/cli/ui/rich_backend.py +162 -0
- praisonai_code/cli/unified_schema.py +655 -0
- praisonai_code/cli/utils/env_utils.py +126 -0
- praisonai_code/cli/utils/project.py +131 -0
- praisonai_code/cli_backends/__init__.py +73 -0
- praisonai_code/cli_backends/claude.py +373 -0
- praisonai_code/cli_backends/registry.py +113 -0
- praisonai_code/runtime/__init__.py +36 -0
- praisonai_code/runtime/__main__.py +81 -0
- praisonai_code/runtime/client.py +131 -0
- praisonai_code/runtime/descriptor.py +209 -0
- praisonai_code/runtime/server.py +356 -0
- praisonai_code-0.0.1.dist-info/METADATA +80 -0
- praisonai_code-0.0.1.dist-info/RECORD +309 -0
- praisonai_code-0.0.1.dist-info/WHEEL +5 -0
- praisonai_code-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Serve command group for PraisonAI CLI.
|
|
3
|
+
|
|
4
|
+
Provides unified server management for ALL PraisonAI server types.
|
|
5
|
+
All server commands are consolidated under `praisonai serve <type>`.
|
|
6
|
+
|
|
7
|
+
Server Types:
|
|
8
|
+
- agents: HTTP REST API for agents
|
|
9
|
+
- gateway: WebSocket multi-agent coordination
|
|
10
|
+
- mcp: MCP server (Model Context Protocol)
|
|
11
|
+
- acp: ACP server (Agent Client Protocol for IDEs)
|
|
12
|
+
- lsp: Language Server Protocol
|
|
13
|
+
- ui: Web UI (aiui)
|
|
14
|
+
- rag: RAG query server
|
|
15
|
+
- registry: Package registry server
|
|
16
|
+
- docs: Documentation preview server
|
|
17
|
+
- scheduler: Background job scheduler
|
|
18
|
+
- recipe: Recipe runner server
|
|
19
|
+
- a2a: Agent-to-Agent protocol
|
|
20
|
+
- a2u: Agent-to-User event stream
|
|
21
|
+
- unified: All providers combined
|
|
22
|
+
- openai: OpenAI API compatibility layer
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from typing import Optional
|
|
26
|
+
import re
|
|
27
|
+
|
|
28
|
+
import typer
|
|
29
|
+
|
|
30
|
+
from ..output.console import get_output_controller
|
|
31
|
+
|
|
32
|
+
app = typer.Typer(
|
|
33
|
+
help="Unified server management - start any PraisonAI server",
|
|
34
|
+
no_args_is_help=False,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@app.command("start")
|
|
39
|
+
def serve_start(
|
|
40
|
+
host: str = typer.Option("0.0.0.0", "--host", "-h", help="Host to bind to"),
|
|
41
|
+
port: int = typer.Option(8000, "--port", "-p", help="Port to bind to"),
|
|
42
|
+
agents_file: Optional[str] = typer.Option(None, "--agents", "-a", help="Agents YAML file"),
|
|
43
|
+
reload: bool = typer.Option(False, "--reload", help="Enable auto-reload"),
|
|
44
|
+
workers: int = typer.Option(1, "--workers", "-w", help="Number of workers"),
|
|
45
|
+
):
|
|
46
|
+
"""Start API server."""
|
|
47
|
+
output = get_output_controller()
|
|
48
|
+
|
|
49
|
+
# Build args for existing handler
|
|
50
|
+
args = [
|
|
51
|
+
"start",
|
|
52
|
+
"--host", host,
|
|
53
|
+
"--port", str(port),
|
|
54
|
+
"--workers", str(workers),
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
if agents_file:
|
|
58
|
+
args.extend(["--agents", agents_file])
|
|
59
|
+
if reload:
|
|
60
|
+
args.append("--reload")
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
from praisonai.cli.features.serve import handle_serve_command
|
|
64
|
+
exit_code = handle_serve_command(args)
|
|
65
|
+
raise typer.Exit(exit_code)
|
|
66
|
+
except ImportError as e:
|
|
67
|
+
output.print_error(f"Serve module not available: {e}")
|
|
68
|
+
raise typer.Exit(4)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@app.command("stop")
|
|
72
|
+
def serve_stop():
|
|
73
|
+
"""Stop API server."""
|
|
74
|
+
output = get_output_controller()
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
from praisonai.cli.features.serve import handle_serve_command
|
|
78
|
+
exit_code = handle_serve_command(["stop"])
|
|
79
|
+
raise typer.Exit(exit_code)
|
|
80
|
+
except ImportError as e:
|
|
81
|
+
output.print_error(f"Serve module not available: {e}")
|
|
82
|
+
raise typer.Exit(4)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@app.command("status")
|
|
86
|
+
def serve_status(
|
|
87
|
+
json_output: bool = typer.Option(False, "--json", help="Output JSON"),
|
|
88
|
+
):
|
|
89
|
+
"""Show server status."""
|
|
90
|
+
output = get_output_controller()
|
|
91
|
+
|
|
92
|
+
args = ["status"]
|
|
93
|
+
if json_output:
|
|
94
|
+
args.append("--json")
|
|
95
|
+
|
|
96
|
+
try:
|
|
97
|
+
from praisonai.cli.features.serve import handle_serve_command
|
|
98
|
+
exit_code = handle_serve_command(args)
|
|
99
|
+
raise typer.Exit(exit_code)
|
|
100
|
+
except ImportError as e:
|
|
101
|
+
output.print_error(f"Serve module not available: {e}")
|
|
102
|
+
raise typer.Exit(4)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@app.callback(invoke_without_command=True)
|
|
106
|
+
def serve_callback(ctx: typer.Context):
|
|
107
|
+
"""Show all available serve commands."""
|
|
108
|
+
if ctx.invoked_subcommand is None:
|
|
109
|
+
help_text = """
|
|
110
|
+
[bold cyan]PraisonAI Serve - Unified Server Management[/bold cyan]
|
|
111
|
+
|
|
112
|
+
Start any PraisonAI server with: praisonai serve <type>
|
|
113
|
+
|
|
114
|
+
[bold]Server Types:[/bold]
|
|
115
|
+
[green]agents[/green] HTTP REST API for agents (port 8000)
|
|
116
|
+
[green]gateway[/green] WebSocket multi-agent coordination (port 8765)
|
|
117
|
+
[green]ui-gateway[/green] Integrated UI-Gateway (Pattern C) (port 8765)
|
|
118
|
+
[green]mcp[/green] MCP server for Claude/Cursor (port 8080)
|
|
119
|
+
[green]acp[/green] Agent Client Protocol for IDEs (STDIO)
|
|
120
|
+
[green]lsp[/green] Language Server Protocol (STDIO)
|
|
121
|
+
[green]ui[/green] aiui web interface (port 8082)
|
|
122
|
+
[green]rag[/green] RAG query server (port 9000)
|
|
123
|
+
[green]registry[/green] Package registry server (port 7777)
|
|
124
|
+
[green]docs[/green] Documentation preview (port 3000)
|
|
125
|
+
[green]scheduler[/green] Background job scheduler
|
|
126
|
+
[green]recipe[/green] Recipe runner server (port 8765)
|
|
127
|
+
[green]a2a[/green] Agent-to-Agent protocol (port 8001)
|
|
128
|
+
[green]a2u[/green] Agent-to-User events (port 8002)
|
|
129
|
+
[green]unified[/green] All providers combined (port 8765)
|
|
130
|
+
[green]openai[/green] OpenAI API compatibility layer (port 8765)
|
|
131
|
+
|
|
132
|
+
[bold]Management:[/bold]
|
|
133
|
+
[yellow]start[/yellow] Start legacy API server
|
|
134
|
+
[yellow]stop[/yellow] Stop running server
|
|
135
|
+
[yellow]status[/yellow] Show server status
|
|
136
|
+
|
|
137
|
+
[bold]Examples:[/bold]
|
|
138
|
+
praisonai serve agents --port 8000
|
|
139
|
+
praisonai serve gateway --port 8765
|
|
140
|
+
praisonai serve mcp --transport sse
|
|
141
|
+
praisonai serve unified
|
|
142
|
+
|
|
143
|
+
[bold]Discovery:[/bold]
|
|
144
|
+
All HTTP servers expose /__praisonai__/discovery for endpoint discovery.
|
|
145
|
+
"""
|
|
146
|
+
try:
|
|
147
|
+
from rich import print as rprint
|
|
148
|
+
rprint(help_text)
|
|
149
|
+
except ImportError:
|
|
150
|
+
plain = re.sub(r'\[/?[^\]]+\]', '', help_text)
|
|
151
|
+
print(plain)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# =============================================================================
|
|
155
|
+
# UNIFIED SERVER COMMANDS - All server types under `praisonai serve <type>`
|
|
156
|
+
# =============================================================================
|
|
157
|
+
|
|
158
|
+
@app.command("agents")
|
|
159
|
+
def serve_agents(
|
|
160
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
161
|
+
port: int = typer.Option(8000, "--port", "-p", help="Port to bind to"),
|
|
162
|
+
file: str = typer.Option("agents.yaml", "--file", "-f", help="Agents YAML file"),
|
|
163
|
+
reload: bool = typer.Option(False, "--reload", help="Enable auto-reload"),
|
|
164
|
+
api_key: Optional[str] = typer.Option(None, "--api-key", help="API key for authentication"),
|
|
165
|
+
):
|
|
166
|
+
"""Start agents as HTTP REST API server.
|
|
167
|
+
|
|
168
|
+
Examples:
|
|
169
|
+
praisonai serve agents
|
|
170
|
+
praisonai serve agents --file my-agents.yaml --port 8000
|
|
171
|
+
"""
|
|
172
|
+
try:
|
|
173
|
+
from praisonai.cli.features.serve import handle_serve_command
|
|
174
|
+
args = ["agents", "--host", host, "--port", str(port), "--file", file]
|
|
175
|
+
if reload:
|
|
176
|
+
args.append("--reload")
|
|
177
|
+
if api_key:
|
|
178
|
+
args.extend(["--api-key", api_key])
|
|
179
|
+
exit_code = handle_serve_command(args)
|
|
180
|
+
raise typer.Exit(exit_code)
|
|
181
|
+
except ImportError as e:
|
|
182
|
+
output = get_output_controller()
|
|
183
|
+
output.print_error(f"Serve module not available: {e}")
|
|
184
|
+
raise typer.Exit(4)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@app.command("gateway")
|
|
188
|
+
def serve_gateway(
|
|
189
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
190
|
+
port: int = typer.Option(8765, "--port", "-p", help="Port to bind to"),
|
|
191
|
+
agents_file: Optional[str] = typer.Option(None, "--agents", "-a", help="Agents YAML file"),
|
|
192
|
+
):
|
|
193
|
+
"""Start WebSocket gateway for multi-agent coordination.
|
|
194
|
+
|
|
195
|
+
The gateway provides real-time bidirectional communication for
|
|
196
|
+
multi-agent systems with session management.
|
|
197
|
+
|
|
198
|
+
Examples:
|
|
199
|
+
praisonai serve gateway
|
|
200
|
+
praisonai serve gateway --port 8765 --agents agents.yaml
|
|
201
|
+
"""
|
|
202
|
+
output = get_output_controller()
|
|
203
|
+
|
|
204
|
+
try:
|
|
205
|
+
from praisonai.cli.features.gateway import GatewayHandler
|
|
206
|
+
handler = GatewayHandler()
|
|
207
|
+
# ``start`` returns a sysexits-based exit code (0 OK, 75 restart,
|
|
208
|
+
# 78 fatal config) so supervisors react correctly; propagate it
|
|
209
|
+
# instead of swallowing fatal/transient failures as success (#2437).
|
|
210
|
+
exit_code = handler.start(host=host, port=port, agent_file=agents_file)
|
|
211
|
+
raise typer.Exit(exit_code or 0)
|
|
212
|
+
except ImportError as e:
|
|
213
|
+
output.print_error(f"Gateway module not available: {e}")
|
|
214
|
+
output.print("Install with: pip install praisonai[api]")
|
|
215
|
+
raise typer.Exit(4)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@app.command("mcp")
|
|
219
|
+
def serve_mcp(
|
|
220
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
221
|
+
port: int = typer.Option(8080, "--port", "-p", help="Port to bind to"),
|
|
222
|
+
transport: str = typer.Option("stdio", "--transport", "-T", help="Transport: stdio, sse, http-stream"),
|
|
223
|
+
name: Optional[str] = typer.Option(None, "--name", "-n", help="Server name from config"),
|
|
224
|
+
):
|
|
225
|
+
"""Start MCP server (Model Context Protocol).
|
|
226
|
+
|
|
227
|
+
Exposes tools to Claude Desktop, Cursor, and other MCP clients.
|
|
228
|
+
|
|
229
|
+
Examples:
|
|
230
|
+
praisonai serve mcp --transport stdio
|
|
231
|
+
praisonai serve mcp --transport sse --port 8080
|
|
232
|
+
praisonai serve mcp --name my-server
|
|
233
|
+
"""
|
|
234
|
+
output = get_output_controller()
|
|
235
|
+
|
|
236
|
+
if name:
|
|
237
|
+
# Run configured server
|
|
238
|
+
try:
|
|
239
|
+
from ..configuration.loader import get_config_loader
|
|
240
|
+
loader = get_config_loader()
|
|
241
|
+
config = loader.load()
|
|
242
|
+
|
|
243
|
+
if name not in config.mcp.servers:
|
|
244
|
+
output.print_error(f"Server not found: {name}")
|
|
245
|
+
raise typer.Exit(1)
|
|
246
|
+
|
|
247
|
+
server = config.mcp.servers[name]
|
|
248
|
+
import subprocess
|
|
249
|
+
import os
|
|
250
|
+
import sys
|
|
251
|
+
|
|
252
|
+
cmd = [server.command] + server.args
|
|
253
|
+
env = os.environ.copy()
|
|
254
|
+
if server.env:
|
|
255
|
+
env.update(server.env)
|
|
256
|
+
|
|
257
|
+
output.print_info(f"Starting MCP server: {name}")
|
|
258
|
+
output.print(f" Command: {server.command} {' '.join(server.args)}")
|
|
259
|
+
output.print(f" Transport: {transport}")
|
|
260
|
+
|
|
261
|
+
if transport == "stdio":
|
|
262
|
+
proc = subprocess.Popen(cmd, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, env=env)
|
|
263
|
+
proc.wait()
|
|
264
|
+
else:
|
|
265
|
+
from praisonaiagents.mcp import MCP, ToolsMCPServer
|
|
266
|
+
cmd_string = " ".join(cmd)
|
|
267
|
+
mcp = MCP(cmd_string, timeout=60, env=server.env or {})
|
|
268
|
+
tools = mcp.get_tools()
|
|
269
|
+
output.print(f" Exposing {len(tools)} tools via {transport}")
|
|
270
|
+
mcp_server = ToolsMCPServer(name=name, tools=tools)
|
|
271
|
+
mcp_server.run_sse(host=host, port=port)
|
|
272
|
+
|
|
273
|
+
except ImportError as e:
|
|
274
|
+
output.print_error(f"MCP module not available: {e}")
|
|
275
|
+
output.print("Install with: pip install praisonaiagents[mcp]")
|
|
276
|
+
raise typer.Exit(4)
|
|
277
|
+
else:
|
|
278
|
+
# Start default MCP server
|
|
279
|
+
try:
|
|
280
|
+
from praisonaiagents.mcp import ToolsMCPServer
|
|
281
|
+
output.print_info(f"Starting MCP server on {host}:{port}")
|
|
282
|
+
output.print(f" Transport: {transport}")
|
|
283
|
+
|
|
284
|
+
mcp_server = ToolsMCPServer(name="praisonai-mcp")
|
|
285
|
+
if transport == "stdio":
|
|
286
|
+
mcp_server.run()
|
|
287
|
+
else:
|
|
288
|
+
mcp_server.run_sse(host=host, port=port)
|
|
289
|
+
except ImportError as e:
|
|
290
|
+
output.print_error(f"MCP module not available: {e}")
|
|
291
|
+
output.print("Install with: pip install praisonaiagents[mcp]")
|
|
292
|
+
raise typer.Exit(4)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
@app.command("acp")
|
|
296
|
+
def serve_acp(
|
|
297
|
+
workspace: str = typer.Option(".", "--workspace", "-w", help="Workspace root directory"),
|
|
298
|
+
agent: str = typer.Option("default", "--agent", "-a", help="Agent name or config file"),
|
|
299
|
+
model: Optional[str] = typer.Option(None, "--model", "-m", help="LLM model to use"),
|
|
300
|
+
debug: bool = typer.Option(False, "--debug", help="Enable debug logging"),
|
|
301
|
+
):
|
|
302
|
+
"""Start ACP server (Agent Client Protocol for IDEs).
|
|
303
|
+
|
|
304
|
+
Provides IDE integration for Windsurf, Cursor, and other editors.
|
|
305
|
+
|
|
306
|
+
Examples:
|
|
307
|
+
praisonai serve acp
|
|
308
|
+
praisonai serve acp --workspace ./my-project
|
|
309
|
+
praisonai serve acp --model gpt-4o
|
|
310
|
+
"""
|
|
311
|
+
output = get_output_controller()
|
|
312
|
+
|
|
313
|
+
try:
|
|
314
|
+
from praisonai.cli.features.acp import ACPHandler
|
|
315
|
+
args_list = ["--workspace", workspace, "--agent", agent]
|
|
316
|
+
if model:
|
|
317
|
+
args_list.extend(["--model", model])
|
|
318
|
+
if debug:
|
|
319
|
+
args_list.append("--debug")
|
|
320
|
+
|
|
321
|
+
import argparse
|
|
322
|
+
parser = argparse.ArgumentParser()
|
|
323
|
+
ACPHandler.add_arguments(parser)
|
|
324
|
+
args = parser.parse_args(args_list)
|
|
325
|
+
exit_code = ACPHandler.handle(args)
|
|
326
|
+
raise typer.Exit(exit_code)
|
|
327
|
+
except ImportError as e:
|
|
328
|
+
output.print_error(f"ACP module not available: {e}")
|
|
329
|
+
output.print("Install with: pip install praisonai[acp]")
|
|
330
|
+
raise typer.Exit(4)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
@app.command("lsp")
|
|
334
|
+
def serve_lsp(
|
|
335
|
+
language: str = typer.Option("python", "--language", "-l", help="Language server type"),
|
|
336
|
+
):
|
|
337
|
+
"""Start Language Server Protocol server.
|
|
338
|
+
|
|
339
|
+
Examples:
|
|
340
|
+
praisonai serve lsp
|
|
341
|
+
praisonai serve lsp --language python
|
|
342
|
+
"""
|
|
343
|
+
output = get_output_controller()
|
|
344
|
+
|
|
345
|
+
try:
|
|
346
|
+
from praisonai.cli.features.lsp_cli import handle_lsp_command
|
|
347
|
+
import argparse
|
|
348
|
+
args = argparse.Namespace(lsp_command="start", language=language)
|
|
349
|
+
handle_lsp_command(args)
|
|
350
|
+
except ImportError as e:
|
|
351
|
+
output.print_error(f"LSP module not available: {e}")
|
|
352
|
+
raise typer.Exit(4)
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
@app.command("ui")
|
|
356
|
+
def serve_ui(
|
|
357
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
358
|
+
port: int = typer.Option(8082, "--port", "-p", help="Port to bind to"),
|
|
359
|
+
ui_type: str = typer.Option("agents", "--type", "-t", help="UI type: agents, chat, code, realtime"),
|
|
360
|
+
):
|
|
361
|
+
"""Start aiui web UI server.
|
|
362
|
+
|
|
363
|
+
Examples:
|
|
364
|
+
praisonai serve ui
|
|
365
|
+
praisonai serve ui --type chat --port 8084
|
|
366
|
+
praisonai serve ui --type code --port 8086
|
|
367
|
+
"""
|
|
368
|
+
output = get_output_controller()
|
|
369
|
+
|
|
370
|
+
try:
|
|
371
|
+
from .ui import _launch_aiui_app
|
|
372
|
+
_launch_aiui_app(f"ui_{ui_type}", f"ui_{ui_type}", port, host, None, False, ui_type)
|
|
373
|
+
except ImportError as e:
|
|
374
|
+
output.print_error(f"UI module not available: {e}")
|
|
375
|
+
output.print("Install with: pip install praisonai[ui]")
|
|
376
|
+
raise typer.Exit(4)
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
@app.command("ui-gateway")
|
|
380
|
+
def serve_ui_gateway(
|
|
381
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
382
|
+
port: int = typer.Option(8765, "--port", "-p", help="Port to bind to"),
|
|
383
|
+
title: str = typer.Option("PraisonAI", "--title", "-t", help="Application title"),
|
|
384
|
+
style: str = typer.Option("dashboard", "--style", "-s", help="UI style: dashboard, chat"),
|
|
385
|
+
agents_file: Optional[str] = typer.Option(None, "--agents", "-a", help="Agents YAML file"),
|
|
386
|
+
):
|
|
387
|
+
"""Start integrated UI-Gateway (Pattern C) - aiui with backend bridges.
|
|
388
|
+
|
|
389
|
+
Combines PraisonAI host integration with AIUIGateway for unified dashboard + chat.
|
|
390
|
+
|
|
391
|
+
Examples:
|
|
392
|
+
praisonai serve ui-gateway
|
|
393
|
+
praisonai serve ui-gateway --style chat --port 8765
|
|
394
|
+
praisonai serve ui-gateway --agents agents.yaml --title "My App"
|
|
395
|
+
"""
|
|
396
|
+
output = get_output_controller()
|
|
397
|
+
|
|
398
|
+
try:
|
|
399
|
+
from praisonai.integration.gateway_host import run_integrated_gateway
|
|
400
|
+
run_integrated_gateway(
|
|
401
|
+
host=host,
|
|
402
|
+
port=port,
|
|
403
|
+
title=title,
|
|
404
|
+
style=style
|
|
405
|
+
)
|
|
406
|
+
except ImportError as e:
|
|
407
|
+
output.print_error(f"UI-Gateway module not available: {e}")
|
|
408
|
+
output.print("Install with: pip install praisonai[ui]")
|
|
409
|
+
raise typer.Exit(4)
|
|
410
|
+
except Exception as e:
|
|
411
|
+
output.print_error(f"Failed to start UI-Gateway: {e}")
|
|
412
|
+
raise typer.Exit(1)
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
@app.command("rag")
|
|
416
|
+
def serve_rag(
|
|
417
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
418
|
+
port: int = typer.Option(9000, "--port", "-p", help="Port to bind to"),
|
|
419
|
+
collection: str = typer.Option("default", "--collection", "-c", help="Collection name"),
|
|
420
|
+
):
|
|
421
|
+
"""Start RAG query server.
|
|
422
|
+
|
|
423
|
+
Examples:
|
|
424
|
+
praisonai serve rag
|
|
425
|
+
praisonai serve rag --collection research --port 9000
|
|
426
|
+
"""
|
|
427
|
+
output = get_output_controller()
|
|
428
|
+
|
|
429
|
+
try:
|
|
430
|
+
from .rag import rag_serve
|
|
431
|
+
# Call the existing rag serve function
|
|
432
|
+
rag_serve(host=host, port=port, collection=collection)
|
|
433
|
+
except ImportError as e:
|
|
434
|
+
output.print_error(f"RAG module not available: {e}")
|
|
435
|
+
raise typer.Exit(4)
|
|
436
|
+
except Exception as e:
|
|
437
|
+
output.print_error(f"Failed to start RAG server: {e}")
|
|
438
|
+
raise typer.Exit(1)
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
@app.command("registry")
|
|
442
|
+
def serve_registry(
|
|
443
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
444
|
+
port: int = typer.Option(7777, "--port", "-p", help="Port to bind to"),
|
|
445
|
+
token: Optional[str] = typer.Option(None, "--token", "-t", help="Authentication token"),
|
|
446
|
+
read_only: bool = typer.Option(False, "--read-only", help="Read-only mode"),
|
|
447
|
+
):
|
|
448
|
+
"""Start package registry server.
|
|
449
|
+
|
|
450
|
+
Examples:
|
|
451
|
+
praisonai serve registry
|
|
452
|
+
praisonai serve registry --port 7777 --token mysecret
|
|
453
|
+
"""
|
|
454
|
+
output = get_output_controller()
|
|
455
|
+
|
|
456
|
+
try:
|
|
457
|
+
from praisonai.cli.features.registry import RegistryHandler
|
|
458
|
+
handler = RegistryHandler()
|
|
459
|
+
args = ["--host", host, "--port", str(port)]
|
|
460
|
+
if token:
|
|
461
|
+
args.extend(["--token", token])
|
|
462
|
+
if read_only:
|
|
463
|
+
args.append("--read-only")
|
|
464
|
+
exit_code = handler.cmd_serve(args)
|
|
465
|
+
raise typer.Exit(exit_code)
|
|
466
|
+
except ImportError as e:
|
|
467
|
+
output.print_error(f"Registry module not available: {e}")
|
|
468
|
+
raise typer.Exit(4)
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
@app.command("docs")
|
|
472
|
+
def serve_docs(
|
|
473
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
474
|
+
port: int = typer.Option(3000, "--port", "-p", help="Port to bind to"),
|
|
475
|
+
path: str = typer.Option(".", "--path", help="Documentation path"),
|
|
476
|
+
):
|
|
477
|
+
"""Start documentation preview server.
|
|
478
|
+
|
|
479
|
+
Examples:
|
|
480
|
+
praisonai serve docs
|
|
481
|
+
praisonai serve docs --port 3000 --path ./docs
|
|
482
|
+
"""
|
|
483
|
+
output = get_output_controller()
|
|
484
|
+
|
|
485
|
+
try:
|
|
486
|
+
from .docs import docs_serve
|
|
487
|
+
docs_serve(host=host, port=port, path=path)
|
|
488
|
+
except ImportError as e:
|
|
489
|
+
output.print_error(f"Docs module not available: {e}")
|
|
490
|
+
raise typer.Exit(4)
|
|
491
|
+
except Exception as e:
|
|
492
|
+
output.print_error(f"Failed to start docs server: {e}")
|
|
493
|
+
raise typer.Exit(1)
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
@app.command("scheduler")
|
|
497
|
+
def serve_scheduler(
|
|
498
|
+
config: Optional[str] = typer.Option(None, "--config", "-c", help="Scheduler config file"),
|
|
499
|
+
daemon: bool = typer.Option(False, "--daemon", "-d", help="Run as daemon"),
|
|
500
|
+
):
|
|
501
|
+
"""Start background job scheduler.
|
|
502
|
+
|
|
503
|
+
Examples:
|
|
504
|
+
praisonai serve scheduler
|
|
505
|
+
praisonai serve scheduler --config schedule.yaml --daemon
|
|
506
|
+
"""
|
|
507
|
+
output = get_output_controller()
|
|
508
|
+
|
|
509
|
+
try:
|
|
510
|
+
from .schedule import schedule_start
|
|
511
|
+
schedule_start(config=config, daemon=daemon)
|
|
512
|
+
except ImportError as e:
|
|
513
|
+
output.print_error(f"Scheduler module not available: {e}")
|
|
514
|
+
raise typer.Exit(4)
|
|
515
|
+
except Exception as e:
|
|
516
|
+
output.print_error(f"Failed to start scheduler: {e}")
|
|
517
|
+
raise typer.Exit(1)
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
@app.command("recipe")
|
|
521
|
+
def serve_recipe(
|
|
522
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
523
|
+
port: int = typer.Option(8765, "--port", "-p", help="Port to bind to"),
|
|
524
|
+
recipe: Optional[str] = typer.Option(None, "--recipe", "-r", help="Recipe name to execute"),
|
|
525
|
+
config: Optional[str] = typer.Option(None, "--config", "-c", help="Config file path"),
|
|
526
|
+
reload: bool = typer.Option(False, "--reload", help="Enable auto-reload"),
|
|
527
|
+
):
|
|
528
|
+
"""Start recipe runner server.
|
|
529
|
+
|
|
530
|
+
Examples:
|
|
531
|
+
praisonai serve recipe
|
|
532
|
+
praisonai serve recipe --port 8765 --reload
|
|
533
|
+
"""
|
|
534
|
+
try:
|
|
535
|
+
from praisonai.cli.features.serve import handle_serve_command
|
|
536
|
+
args = ["recipe", "--host", host, "--port", str(port)]
|
|
537
|
+
if recipe:
|
|
538
|
+
args.extend(["--recipe", recipe])
|
|
539
|
+
if config:
|
|
540
|
+
args.extend(["--config", config])
|
|
541
|
+
if reload:
|
|
542
|
+
args.append("--reload")
|
|
543
|
+
exit_code = handle_serve_command(args)
|
|
544
|
+
raise typer.Exit(exit_code)
|
|
545
|
+
except ImportError as e:
|
|
546
|
+
output = get_output_controller()
|
|
547
|
+
output.print_error(f"Recipe serve module not available: {e}")
|
|
548
|
+
raise typer.Exit(4)
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
@app.command("a2a")
|
|
552
|
+
def serve_a2a(
|
|
553
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
554
|
+
port: int = typer.Option(8001, "--port", "-p", help="Port to bind to"),
|
|
555
|
+
file: str = typer.Option("agents.yaml", "--file", "-f", help="Agents YAML file"),
|
|
556
|
+
):
|
|
557
|
+
"""Start Agent-to-Agent protocol server.
|
|
558
|
+
|
|
559
|
+
Enables agent-to-agent communication via JSON-RPC.
|
|
560
|
+
|
|
561
|
+
Examples:
|
|
562
|
+
praisonai serve a2a
|
|
563
|
+
praisonai serve a2a --port 8001
|
|
564
|
+
"""
|
|
565
|
+
try:
|
|
566
|
+
from praisonai.cli.features.serve import handle_serve_command
|
|
567
|
+
args = ["a2a", "--host", host, "--port", str(port), "--file", file]
|
|
568
|
+
exit_code = handle_serve_command(args)
|
|
569
|
+
raise typer.Exit(exit_code)
|
|
570
|
+
except ImportError as e:
|
|
571
|
+
output = get_output_controller()
|
|
572
|
+
output.print_error(f"A2A serve module not available: {e}")
|
|
573
|
+
raise typer.Exit(4)
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
@app.command("a2u")
|
|
577
|
+
def serve_a2u(
|
|
578
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
579
|
+
port: int = typer.Option(8002, "--port", "-p", help="Port to bind to"),
|
|
580
|
+
):
|
|
581
|
+
"""Start Agent-to-User event stream server.
|
|
582
|
+
|
|
583
|
+
Provides SSE event streaming for UI integration.
|
|
584
|
+
|
|
585
|
+
Examples:
|
|
586
|
+
praisonai serve a2u
|
|
587
|
+
praisonai serve a2u --port 8002
|
|
588
|
+
"""
|
|
589
|
+
try:
|
|
590
|
+
from praisonai.cli.features.serve import handle_serve_command
|
|
591
|
+
args = ["a2u", "--host", host, "--port", str(port)]
|
|
592
|
+
exit_code = handle_serve_command(args)
|
|
593
|
+
raise typer.Exit(exit_code)
|
|
594
|
+
except ImportError as e:
|
|
595
|
+
output = get_output_controller()
|
|
596
|
+
output.print_error(f"A2U serve module not available: {e}")
|
|
597
|
+
raise typer.Exit(4)
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
@app.command("unified")
|
|
601
|
+
def serve_unified(
|
|
602
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
603
|
+
port: int = typer.Option(8765, "--port", "-p", help="Port to bind to"),
|
|
604
|
+
file: str = typer.Option("agents.yaml", "--file", "-f", help="Agents YAML file"),
|
|
605
|
+
reload: bool = typer.Option(False, "--reload", help="Enable auto-reload"),
|
|
606
|
+
):
|
|
607
|
+
"""Start unified server with all providers.
|
|
608
|
+
|
|
609
|
+
Combines agents-api, recipe, mcp, a2a, and a2u in one server.
|
|
610
|
+
|
|
611
|
+
Examples:
|
|
612
|
+
praisonai serve unified
|
|
613
|
+
praisonai serve unified --port 8765 --reload
|
|
614
|
+
"""
|
|
615
|
+
try:
|
|
616
|
+
from praisonai.cli.features.serve import handle_serve_command
|
|
617
|
+
args = ["unified", "--host", host, "--port", str(port), "--file", file]
|
|
618
|
+
if reload:
|
|
619
|
+
args.append("--reload")
|
|
620
|
+
exit_code = handle_serve_command(args)
|
|
621
|
+
raise typer.Exit(exit_code)
|
|
622
|
+
except ImportError as e:
|
|
623
|
+
output = get_output_controller()
|
|
624
|
+
output.print_error(f"Unified serve module not available: {e}")
|
|
625
|
+
raise typer.Exit(4)
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
@app.command("openai")
|
|
629
|
+
def serve_openai(
|
|
630
|
+
host: str = typer.Option("127.0.0.1", "--host", "-h", help="Host to bind to"),
|
|
631
|
+
port: int = typer.Option(8765, "--port", "-p", help="Port to bind to"),
|
|
632
|
+
agents_url: str = typer.Option("http://127.0.0.1:8000", "--agents-url", help="URL of the running Agents API server"),
|
|
633
|
+
api_key: Optional[str] = typer.Option(None, "--api-key", help="API key for authentication"),
|
|
634
|
+
reload: bool = typer.Option(False, "--reload", help="Enable auto-reload"),
|
|
635
|
+
):
|
|
636
|
+
"""Start OpenAI API compatibility server.
|
|
637
|
+
|
|
638
|
+
Provides OpenAI-compatible endpoints like /v1/chat/completions for
|
|
639
|
+
drop-in compatibility with OpenAI client libraries.
|
|
640
|
+
|
|
641
|
+
Examples:
|
|
642
|
+
praisonai serve openai
|
|
643
|
+
praisonai serve openai --port 8765 --api-key mykey
|
|
644
|
+
"""
|
|
645
|
+
output = get_output_controller()
|
|
646
|
+
|
|
647
|
+
try:
|
|
648
|
+
import uvicorn
|
|
649
|
+
from praisonai.endpoints.providers import OpenAICompatProvider, AgentsAPIProvider
|
|
650
|
+
from praisonai.endpoints.server import create_unified_app, mount_provider_routes
|
|
651
|
+
from praisonai.cli.features.serve import _install_api_key_middleware
|
|
652
|
+
|
|
653
|
+
output.print_info(f"Starting OpenAI-compatible server on {host}:{port}")
|
|
654
|
+
|
|
655
|
+
# Create providers
|
|
656
|
+
agents_provider = AgentsAPIProvider(base_url=agents_url)
|
|
657
|
+
openai_provider = OpenAICompatProvider(
|
|
658
|
+
base_url=f"http://{host}:{port}",
|
|
659
|
+
api_key=api_key,
|
|
660
|
+
agent_provider=agents_provider
|
|
661
|
+
)
|
|
662
|
+
|
|
663
|
+
# Create server, mount provider routes, and apply shared auth middleware
|
|
664
|
+
# (same gate used by cmd_agents / cmd_unified).
|
|
665
|
+
app = create_unified_app(server_name="PraisonAI OpenAI API")
|
|
666
|
+
mount_provider_routes(app, openai_provider)
|
|
667
|
+
_install_api_key_middleware(app, api_key)
|
|
668
|
+
|
|
669
|
+
output.print("OpenAI-compatible endpoints available:")
|
|
670
|
+
output.print(" POST /v1/chat/completions")
|
|
671
|
+
output.print(" POST /v1/completions")
|
|
672
|
+
output.print(" GET /v1/models")
|
|
673
|
+
output.print(" POST /v1/tools/invoke")
|
|
674
|
+
|
|
675
|
+
# Start server
|
|
676
|
+
uvicorn.run(
|
|
677
|
+
app,
|
|
678
|
+
host=host,
|
|
679
|
+
port=port,
|
|
680
|
+
reload=reload,
|
|
681
|
+
access_log=False,
|
|
682
|
+
)
|
|
683
|
+
|
|
684
|
+
except ImportError as e:
|
|
685
|
+
output.print_error(f"OpenAI compatibility module not available: {e}")
|
|
686
|
+
output.print("Install with: pip install praisonai[api]")
|
|
687
|
+
raise typer.Exit(4)
|
|
688
|
+
except Exception as e:
|
|
689
|
+
output.print_error(f"Failed to start OpenAI server: {e}")
|
|
690
|
+
raise typer.Exit(1)
|