PraisonAI 3.0.0__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/__init__.py +54 -0
- praisonai/__main__.py +15 -0
- praisonai/acp/__init__.py +54 -0
- praisonai/acp/config.py +159 -0
- praisonai/acp/server.py +587 -0
- praisonai/acp/session.py +219 -0
- praisonai/adapters/__init__.py +50 -0
- praisonai/adapters/readers.py +395 -0
- praisonai/adapters/rerankers.py +315 -0
- praisonai/adapters/retrievers.py +394 -0
- praisonai/adapters/vector_stores.py +409 -0
- praisonai/agent_scheduler.py +337 -0
- praisonai/agents_generator.py +903 -0
- praisonai/api/call.py +292 -0
- praisonai/auto.py +1197 -0
- praisonai/capabilities/__init__.py +275 -0
- praisonai/capabilities/a2a.py +140 -0
- praisonai/capabilities/assistants.py +283 -0
- praisonai/capabilities/audio.py +320 -0
- praisonai/capabilities/batches.py +469 -0
- praisonai/capabilities/completions.py +336 -0
- praisonai/capabilities/container_files.py +155 -0
- praisonai/capabilities/containers.py +93 -0
- praisonai/capabilities/embeddings.py +158 -0
- praisonai/capabilities/files.py +467 -0
- praisonai/capabilities/fine_tuning.py +293 -0
- praisonai/capabilities/guardrails.py +182 -0
- praisonai/capabilities/images.py +330 -0
- praisonai/capabilities/mcp.py +190 -0
- praisonai/capabilities/messages.py +270 -0
- praisonai/capabilities/moderations.py +154 -0
- praisonai/capabilities/ocr.py +217 -0
- praisonai/capabilities/passthrough.py +204 -0
- praisonai/capabilities/rag.py +207 -0
- praisonai/capabilities/realtime.py +160 -0
- praisonai/capabilities/rerank.py +165 -0
- praisonai/capabilities/responses.py +266 -0
- praisonai/capabilities/search.py +109 -0
- praisonai/capabilities/skills.py +133 -0
- praisonai/capabilities/vector_store_files.py +334 -0
- praisonai/capabilities/vector_stores.py +304 -0
- praisonai/capabilities/videos.py +141 -0
- praisonai/chainlit_ui.py +304 -0
- praisonai/chat/__init__.py +106 -0
- praisonai/chat/app.py +125 -0
- praisonai/cli/__init__.py +26 -0
- praisonai/cli/app.py +213 -0
- praisonai/cli/commands/__init__.py +75 -0
- praisonai/cli/commands/acp.py +70 -0
- praisonai/cli/commands/completion.py +333 -0
- praisonai/cli/commands/config.py +166 -0
- praisonai/cli/commands/debug.py +142 -0
- praisonai/cli/commands/diag.py +55 -0
- praisonai/cli/commands/doctor.py +166 -0
- praisonai/cli/commands/environment.py +179 -0
- praisonai/cli/commands/lsp.py +112 -0
- praisonai/cli/commands/mcp.py +210 -0
- praisonai/cli/commands/profile.py +457 -0
- praisonai/cli/commands/run.py +228 -0
- praisonai/cli/commands/schedule.py +150 -0
- praisonai/cli/commands/serve.py +97 -0
- praisonai/cli/commands/session.py +212 -0
- praisonai/cli/commands/traces.py +145 -0
- praisonai/cli/commands/version.py +101 -0
- praisonai/cli/configuration/__init__.py +18 -0
- praisonai/cli/configuration/loader.py +353 -0
- praisonai/cli/configuration/paths.py +114 -0
- praisonai/cli/configuration/schema.py +164 -0
- praisonai/cli/features/__init__.py +268 -0
- praisonai/cli/features/acp.py +236 -0
- praisonai/cli/features/action_orchestrator.py +546 -0
- praisonai/cli/features/agent_scheduler.py +773 -0
- praisonai/cli/features/agent_tools.py +474 -0
- praisonai/cli/features/agents.py +375 -0
- praisonai/cli/features/at_mentions.py +471 -0
- praisonai/cli/features/auto_memory.py +182 -0
- praisonai/cli/features/autonomy_mode.py +490 -0
- praisonai/cli/features/background.py +356 -0
- praisonai/cli/features/base.py +168 -0
- praisonai/cli/features/capabilities.py +1326 -0
- praisonai/cli/features/checkpoints.py +338 -0
- praisonai/cli/features/code_intelligence.py +652 -0
- praisonai/cli/features/compaction.py +294 -0
- praisonai/cli/features/compare.py +534 -0
- praisonai/cli/features/cost_tracker.py +514 -0
- praisonai/cli/features/debug.py +810 -0
- praisonai/cli/features/deploy.py +517 -0
- praisonai/cli/features/diag.py +289 -0
- praisonai/cli/features/doctor/__init__.py +63 -0
- praisonai/cli/features/doctor/checks/__init__.py +24 -0
- praisonai/cli/features/doctor/checks/acp_checks.py +240 -0
- praisonai/cli/features/doctor/checks/config_checks.py +366 -0
- praisonai/cli/features/doctor/checks/db_checks.py +366 -0
- praisonai/cli/features/doctor/checks/env_checks.py +543 -0
- praisonai/cli/features/doctor/checks/lsp_checks.py +199 -0
- praisonai/cli/features/doctor/checks/mcp_checks.py +349 -0
- praisonai/cli/features/doctor/checks/memory_checks.py +268 -0
- praisonai/cli/features/doctor/checks/network_checks.py +251 -0
- praisonai/cli/features/doctor/checks/obs_checks.py +328 -0
- praisonai/cli/features/doctor/checks/performance_checks.py +235 -0
- praisonai/cli/features/doctor/checks/permissions_checks.py +259 -0
- praisonai/cli/features/doctor/checks/selftest_checks.py +322 -0
- praisonai/cli/features/doctor/checks/serve_checks.py +426 -0
- praisonai/cli/features/doctor/checks/skills_checks.py +231 -0
- praisonai/cli/features/doctor/checks/tools_checks.py +371 -0
- praisonai/cli/features/doctor/engine.py +266 -0
- praisonai/cli/features/doctor/formatters.py +310 -0
- praisonai/cli/features/doctor/handler.py +397 -0
- praisonai/cli/features/doctor/models.py +264 -0
- praisonai/cli/features/doctor/registry.py +239 -0
- praisonai/cli/features/endpoints.py +1019 -0
- praisonai/cli/features/eval.py +560 -0
- praisonai/cli/features/external_agents.py +231 -0
- praisonai/cli/features/fast_context.py +410 -0
- praisonai/cli/features/flow_display.py +566 -0
- praisonai/cli/features/git_integration.py +651 -0
- praisonai/cli/features/guardrail.py +171 -0
- praisonai/cli/features/handoff.py +185 -0
- praisonai/cli/features/hooks.py +583 -0
- praisonai/cli/features/image.py +384 -0
- praisonai/cli/features/interactive_runtime.py +585 -0
- praisonai/cli/features/interactive_tools.py +380 -0
- praisonai/cli/features/interactive_tui.py +603 -0
- praisonai/cli/features/jobs.py +632 -0
- praisonai/cli/features/knowledge.py +531 -0
- praisonai/cli/features/lite.py +244 -0
- praisonai/cli/features/lsp_cli.py +225 -0
- praisonai/cli/features/mcp.py +169 -0
- praisonai/cli/features/message_queue.py +587 -0
- praisonai/cli/features/metrics.py +211 -0
- praisonai/cli/features/n8n.py +673 -0
- praisonai/cli/features/observability.py +293 -0
- praisonai/cli/features/ollama.py +361 -0
- praisonai/cli/features/output_style.py +273 -0
- praisonai/cli/features/package.py +631 -0
- praisonai/cli/features/performance.py +308 -0
- praisonai/cli/features/persistence.py +636 -0
- praisonai/cli/features/profile.py +226 -0
- praisonai/cli/features/profiler/__init__.py +81 -0
- praisonai/cli/features/profiler/core.py +558 -0
- praisonai/cli/features/profiler/optimizations.py +652 -0
- praisonai/cli/features/profiler/suite.py +386 -0
- praisonai/cli/features/profiling.py +350 -0
- praisonai/cli/features/queue/__init__.py +73 -0
- praisonai/cli/features/queue/manager.py +395 -0
- praisonai/cli/features/queue/models.py +286 -0
- praisonai/cli/features/queue/persistence.py +564 -0
- praisonai/cli/features/queue/scheduler.py +484 -0
- praisonai/cli/features/queue/worker.py +372 -0
- praisonai/cli/features/recipe.py +1723 -0
- praisonai/cli/features/recipes.py +449 -0
- praisonai/cli/features/registry.py +229 -0
- praisonai/cli/features/repo_map.py +860 -0
- praisonai/cli/features/router.py +466 -0
- praisonai/cli/features/sandbox_executor.py +515 -0
- praisonai/cli/features/serve.py +829 -0
- praisonai/cli/features/session.py +222 -0
- praisonai/cli/features/skills.py +856 -0
- praisonai/cli/features/slash_commands.py +650 -0
- praisonai/cli/features/telemetry.py +179 -0
- praisonai/cli/features/templates.py +1384 -0
- praisonai/cli/features/thinking.py +305 -0
- praisonai/cli/features/todo.py +334 -0
- praisonai/cli/features/tools.py +680 -0
- praisonai/cli/features/tui/__init__.py +83 -0
- praisonai/cli/features/tui/app.py +580 -0
- praisonai/cli/features/tui/cli.py +566 -0
- praisonai/cli/features/tui/debug.py +511 -0
- praisonai/cli/features/tui/events.py +99 -0
- praisonai/cli/features/tui/mock_provider.py +328 -0
- praisonai/cli/features/tui/orchestrator.py +652 -0
- praisonai/cli/features/tui/screens/__init__.py +50 -0
- praisonai/cli/features/tui/screens/main.py +245 -0
- praisonai/cli/features/tui/screens/queue.py +174 -0
- praisonai/cli/features/tui/screens/session.py +124 -0
- praisonai/cli/features/tui/screens/settings.py +148 -0
- praisonai/cli/features/tui/widgets/__init__.py +56 -0
- praisonai/cli/features/tui/widgets/chat.py +261 -0
- praisonai/cli/features/tui/widgets/composer.py +224 -0
- praisonai/cli/features/tui/widgets/queue_panel.py +200 -0
- praisonai/cli/features/tui/widgets/status.py +167 -0
- praisonai/cli/features/tui/widgets/tool_panel.py +248 -0
- praisonai/cli/features/workflow.py +720 -0
- praisonai/cli/legacy.py +236 -0
- praisonai/cli/main.py +5559 -0
- praisonai/cli/schedule_cli.py +54 -0
- praisonai/cli/state/__init__.py +31 -0
- praisonai/cli/state/identifiers.py +161 -0
- praisonai/cli/state/sessions.py +313 -0
- praisonai/code/__init__.py +93 -0
- praisonai/code/agent_tools.py +344 -0
- praisonai/code/diff/__init__.py +21 -0
- praisonai/code/diff/diff_strategy.py +432 -0
- praisonai/code/tools/__init__.py +27 -0
- praisonai/code/tools/apply_diff.py +221 -0
- praisonai/code/tools/execute_command.py +275 -0
- praisonai/code/tools/list_files.py +274 -0
- praisonai/code/tools/read_file.py +206 -0
- praisonai/code/tools/search_replace.py +248 -0
- praisonai/code/tools/write_file.py +217 -0
- praisonai/code/utils/__init__.py +46 -0
- praisonai/code/utils/file_utils.py +307 -0
- praisonai/code/utils/ignore_utils.py +308 -0
- praisonai/code/utils/text_utils.py +276 -0
- praisonai/db/__init__.py +64 -0
- praisonai/db/adapter.py +531 -0
- praisonai/deploy/__init__.py +62 -0
- praisonai/deploy/api.py +231 -0
- praisonai/deploy/docker.py +454 -0
- praisonai/deploy/doctor.py +367 -0
- praisonai/deploy/main.py +327 -0
- praisonai/deploy/models.py +179 -0
- praisonai/deploy/providers/__init__.py +33 -0
- praisonai/deploy/providers/aws.py +331 -0
- praisonai/deploy/providers/azure.py +358 -0
- praisonai/deploy/providers/base.py +101 -0
- praisonai/deploy/providers/gcp.py +314 -0
- praisonai/deploy/schema.py +208 -0
- praisonai/deploy.py +185 -0
- praisonai/endpoints/__init__.py +53 -0
- praisonai/endpoints/a2u_server.py +410 -0
- praisonai/endpoints/discovery.py +165 -0
- praisonai/endpoints/providers/__init__.py +28 -0
- praisonai/endpoints/providers/a2a.py +253 -0
- praisonai/endpoints/providers/a2u.py +208 -0
- praisonai/endpoints/providers/agents_api.py +171 -0
- praisonai/endpoints/providers/base.py +231 -0
- praisonai/endpoints/providers/mcp.py +263 -0
- praisonai/endpoints/providers/recipe.py +206 -0
- praisonai/endpoints/providers/tools_mcp.py +150 -0
- praisonai/endpoints/registry.py +131 -0
- praisonai/endpoints/server.py +161 -0
- praisonai/inbuilt_tools/__init__.py +24 -0
- praisonai/inbuilt_tools/autogen_tools.py +117 -0
- praisonai/inc/__init__.py +2 -0
- praisonai/inc/config.py +96 -0
- praisonai/inc/models.py +155 -0
- praisonai/integrations/__init__.py +56 -0
- praisonai/integrations/base.py +303 -0
- praisonai/integrations/claude_code.py +270 -0
- praisonai/integrations/codex_cli.py +255 -0
- praisonai/integrations/cursor_cli.py +195 -0
- praisonai/integrations/gemini_cli.py +222 -0
- praisonai/jobs/__init__.py +67 -0
- praisonai/jobs/executor.py +425 -0
- praisonai/jobs/models.py +230 -0
- praisonai/jobs/router.py +314 -0
- praisonai/jobs/server.py +186 -0
- praisonai/jobs/store.py +203 -0
- praisonai/llm/__init__.py +66 -0
- praisonai/llm/registry.py +382 -0
- praisonai/mcp_server/__init__.py +152 -0
- praisonai/mcp_server/adapters/__init__.py +74 -0
- praisonai/mcp_server/adapters/agents.py +128 -0
- praisonai/mcp_server/adapters/capabilities.py +168 -0
- praisonai/mcp_server/adapters/cli_tools.py +568 -0
- praisonai/mcp_server/adapters/extended_capabilities.py +462 -0
- praisonai/mcp_server/adapters/knowledge.py +93 -0
- praisonai/mcp_server/adapters/memory.py +104 -0
- praisonai/mcp_server/adapters/prompts.py +306 -0
- praisonai/mcp_server/adapters/resources.py +124 -0
- praisonai/mcp_server/adapters/tools_bridge.py +280 -0
- praisonai/mcp_server/auth/__init__.py +48 -0
- praisonai/mcp_server/auth/api_key.py +291 -0
- praisonai/mcp_server/auth/oauth.py +460 -0
- praisonai/mcp_server/auth/oidc.py +289 -0
- praisonai/mcp_server/auth/scopes.py +260 -0
- praisonai/mcp_server/cli.py +852 -0
- praisonai/mcp_server/elicitation.py +445 -0
- praisonai/mcp_server/icons.py +302 -0
- praisonai/mcp_server/recipe_adapter.py +573 -0
- praisonai/mcp_server/recipe_cli.py +824 -0
- praisonai/mcp_server/registry.py +703 -0
- praisonai/mcp_server/sampling.py +422 -0
- praisonai/mcp_server/server.py +490 -0
- praisonai/mcp_server/tasks.py +443 -0
- praisonai/mcp_server/transports/__init__.py +18 -0
- praisonai/mcp_server/transports/http_stream.py +376 -0
- praisonai/mcp_server/transports/stdio.py +132 -0
- praisonai/persistence/__init__.py +84 -0
- praisonai/persistence/config.py +238 -0
- praisonai/persistence/conversation/__init__.py +25 -0
- praisonai/persistence/conversation/async_mysql.py +427 -0
- praisonai/persistence/conversation/async_postgres.py +410 -0
- praisonai/persistence/conversation/async_sqlite.py +371 -0
- praisonai/persistence/conversation/base.py +151 -0
- praisonai/persistence/conversation/json_store.py +250 -0
- praisonai/persistence/conversation/mysql.py +387 -0
- praisonai/persistence/conversation/postgres.py +401 -0
- praisonai/persistence/conversation/singlestore.py +240 -0
- praisonai/persistence/conversation/sqlite.py +341 -0
- praisonai/persistence/conversation/supabase.py +203 -0
- praisonai/persistence/conversation/surrealdb.py +287 -0
- praisonai/persistence/factory.py +301 -0
- praisonai/persistence/hooks/__init__.py +18 -0
- praisonai/persistence/hooks/agent_hooks.py +297 -0
- praisonai/persistence/knowledge/__init__.py +26 -0
- praisonai/persistence/knowledge/base.py +144 -0
- praisonai/persistence/knowledge/cassandra.py +232 -0
- praisonai/persistence/knowledge/chroma.py +295 -0
- praisonai/persistence/knowledge/clickhouse.py +242 -0
- praisonai/persistence/knowledge/cosmosdb_vector.py +438 -0
- praisonai/persistence/knowledge/couchbase.py +286 -0
- praisonai/persistence/knowledge/lancedb.py +216 -0
- praisonai/persistence/knowledge/langchain_adapter.py +291 -0
- praisonai/persistence/knowledge/lightrag_adapter.py +212 -0
- praisonai/persistence/knowledge/llamaindex_adapter.py +256 -0
- praisonai/persistence/knowledge/milvus.py +277 -0
- praisonai/persistence/knowledge/mongodb_vector.py +306 -0
- praisonai/persistence/knowledge/pgvector.py +335 -0
- praisonai/persistence/knowledge/pinecone.py +253 -0
- praisonai/persistence/knowledge/qdrant.py +301 -0
- praisonai/persistence/knowledge/redis_vector.py +291 -0
- praisonai/persistence/knowledge/singlestore_vector.py +299 -0
- praisonai/persistence/knowledge/surrealdb_vector.py +309 -0
- praisonai/persistence/knowledge/upstash_vector.py +266 -0
- praisonai/persistence/knowledge/weaviate.py +223 -0
- praisonai/persistence/migrations/__init__.py +10 -0
- praisonai/persistence/migrations/manager.py +251 -0
- praisonai/persistence/orchestrator.py +406 -0
- praisonai/persistence/state/__init__.py +21 -0
- praisonai/persistence/state/async_mongodb.py +200 -0
- praisonai/persistence/state/base.py +107 -0
- praisonai/persistence/state/dynamodb.py +226 -0
- praisonai/persistence/state/firestore.py +175 -0
- praisonai/persistence/state/gcs.py +155 -0
- praisonai/persistence/state/memory.py +245 -0
- praisonai/persistence/state/mongodb.py +158 -0
- praisonai/persistence/state/redis.py +190 -0
- praisonai/persistence/state/upstash.py +144 -0
- praisonai/persistence/tests/__init__.py +3 -0
- praisonai/persistence/tests/test_all_backends.py +633 -0
- praisonai/profiler.py +1214 -0
- praisonai/recipe/__init__.py +134 -0
- praisonai/recipe/bridge.py +278 -0
- praisonai/recipe/core.py +893 -0
- praisonai/recipe/exceptions.py +54 -0
- praisonai/recipe/history.py +402 -0
- praisonai/recipe/models.py +266 -0
- praisonai/recipe/operations.py +440 -0
- praisonai/recipe/policy.py +422 -0
- praisonai/recipe/registry.py +849 -0
- praisonai/recipe/runtime.py +214 -0
- praisonai/recipe/security.py +711 -0
- praisonai/recipe/serve.py +859 -0
- praisonai/recipe/server.py +613 -0
- praisonai/scheduler/__init__.py +45 -0
- praisonai/scheduler/agent_scheduler.py +552 -0
- praisonai/scheduler/base.py +124 -0
- praisonai/scheduler/daemon_manager.py +225 -0
- praisonai/scheduler/state_manager.py +155 -0
- praisonai/scheduler/yaml_loader.py +193 -0
- praisonai/scheduler.py +194 -0
- praisonai/setup/__init__.py +1 -0
- praisonai/setup/build.py +21 -0
- praisonai/setup/post_install.py +23 -0
- praisonai/setup/setup_conda_env.py +25 -0
- praisonai/setup.py +16 -0
- praisonai/templates/__init__.py +116 -0
- praisonai/templates/cache.py +364 -0
- praisonai/templates/dependency_checker.py +358 -0
- praisonai/templates/discovery.py +391 -0
- praisonai/templates/loader.py +564 -0
- praisonai/templates/registry.py +511 -0
- praisonai/templates/resolver.py +206 -0
- praisonai/templates/security.py +327 -0
- praisonai/templates/tool_override.py +498 -0
- praisonai/templates/tools_doctor.py +256 -0
- praisonai/test.py +105 -0
- praisonai/train.py +562 -0
- praisonai/train_vision.py +306 -0
- praisonai/ui/agents.py +824 -0
- praisonai/ui/callbacks.py +57 -0
- praisonai/ui/chainlit_compat.py +246 -0
- praisonai/ui/chat.py +532 -0
- praisonai/ui/code.py +717 -0
- praisonai/ui/colab.py +474 -0
- praisonai/ui/colab_chainlit.py +81 -0
- praisonai/ui/components/aicoder.py +284 -0
- praisonai/ui/context.py +283 -0
- praisonai/ui/database_config.py +56 -0
- praisonai/ui/db.py +294 -0
- praisonai/ui/realtime.py +488 -0
- praisonai/ui/realtimeclient/__init__.py +756 -0
- praisonai/ui/realtimeclient/tools.py +242 -0
- praisonai/ui/sql_alchemy.py +710 -0
- praisonai/upload_vision.py +140 -0
- praisonai/version.py +1 -0
- praisonai-3.0.0.dist-info/METADATA +3493 -0
- praisonai-3.0.0.dist-info/RECORD +393 -0
- praisonai-3.0.0.dist-info/WHEEL +5 -0
- praisonai-3.0.0.dist-info/entry_points.txt +4 -0
- praisonai-3.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Run command group for PraisonAI CLI.
|
|
3
|
+
|
|
4
|
+
Provides agent execution commands.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
import typer
|
|
10
|
+
|
|
11
|
+
from ..output.console import get_output_controller
|
|
12
|
+
from ..state.identifiers import get_current_context
|
|
13
|
+
|
|
14
|
+
app = typer.Typer(help="Run agents")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@app.callback(invoke_without_command=True)
|
|
18
|
+
def run_main(
|
|
19
|
+
ctx: typer.Context,
|
|
20
|
+
target: Optional[str] = typer.Argument(None, help="Agent file or prompt"),
|
|
21
|
+
model: Optional[str] = typer.Option(None, "--model", "-m", help="LLM model to use"),
|
|
22
|
+
framework: Optional[str] = typer.Option(None, "--framework", "-f", help="Framework: praisonai, crewai, autogen"),
|
|
23
|
+
interactive: bool = typer.Option(False, "--interactive", "-i", help="Interactive mode"),
|
|
24
|
+
verbose: bool = typer.Option(False, "--verbose", "-v", help="Verbose output"),
|
|
25
|
+
stream: bool = typer.Option(True, "--stream/--no-stream", help="Stream output"),
|
|
26
|
+
trace: bool = typer.Option(False, "--trace", help="Enable tracing"),
|
|
27
|
+
memory: bool = typer.Option(False, "--memory", help="Enable memory"),
|
|
28
|
+
tools: Optional[str] = typer.Option(None, "--tools", "-t", help="Tools file path"),
|
|
29
|
+
max_tokens: int = typer.Option(16000, "--max-tokens", help="Maximum output tokens"),
|
|
30
|
+
):
|
|
31
|
+
"""
|
|
32
|
+
Run agents from a file or prompt.
|
|
33
|
+
|
|
34
|
+
Examples:
|
|
35
|
+
praisonai run agents.yaml
|
|
36
|
+
praisonai run "What is the weather?"
|
|
37
|
+
praisonai run agents.yaml --interactive
|
|
38
|
+
"""
|
|
39
|
+
output = get_output_controller()
|
|
40
|
+
context = get_current_context()
|
|
41
|
+
|
|
42
|
+
if not target:
|
|
43
|
+
output.print_panel(
|
|
44
|
+
"Run agents from a file or prompt.\n\n"
|
|
45
|
+
"Usage:\n"
|
|
46
|
+
" praisonai run agents.yaml\n"
|
|
47
|
+
" praisonai run \"What is the weather?\"\n"
|
|
48
|
+
" praisonai run agents.yaml --interactive\n\n"
|
|
49
|
+
"Options:\n"
|
|
50
|
+
" --model, -m LLM model to use\n"
|
|
51
|
+
" --framework, -f Framework (praisonai, crewai, autogen)\n"
|
|
52
|
+
" --interactive, -i Interactive mode\n"
|
|
53
|
+
" --verbose, -v Verbose output\n"
|
|
54
|
+
" --trace Enable tracing\n"
|
|
55
|
+
" --memory Enable memory",
|
|
56
|
+
title="Run Command"
|
|
57
|
+
)
|
|
58
|
+
return
|
|
59
|
+
|
|
60
|
+
# Emit start event
|
|
61
|
+
output.emit_start(
|
|
62
|
+
message=f"Starting run: {target[:50]}..." if len(target) > 50 else f"Starting run: {target}",
|
|
63
|
+
data={
|
|
64
|
+
"target": target,
|
|
65
|
+
"model": model,
|
|
66
|
+
"framework": framework,
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Check if target is a file or prompt
|
|
71
|
+
import os
|
|
72
|
+
is_file = os.path.exists(target) and (target.endswith('.yaml') or target.endswith('.yml'))
|
|
73
|
+
|
|
74
|
+
if is_file:
|
|
75
|
+
# Run from file
|
|
76
|
+
_run_from_file(
|
|
77
|
+
target,
|
|
78
|
+
model=model,
|
|
79
|
+
framework=framework,
|
|
80
|
+
interactive=interactive,
|
|
81
|
+
verbose=verbose,
|
|
82
|
+
stream=stream,
|
|
83
|
+
trace=trace,
|
|
84
|
+
memory=memory,
|
|
85
|
+
tools=tools,
|
|
86
|
+
max_tokens=max_tokens,
|
|
87
|
+
)
|
|
88
|
+
else:
|
|
89
|
+
# Run as prompt
|
|
90
|
+
_run_prompt(
|
|
91
|
+
target,
|
|
92
|
+
model=model,
|
|
93
|
+
verbose=verbose,
|
|
94
|
+
stream=stream,
|
|
95
|
+
trace=trace,
|
|
96
|
+
memory=memory,
|
|
97
|
+
tools=tools,
|
|
98
|
+
max_tokens=max_tokens,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _run_from_file(
|
|
103
|
+
file_path: str,
|
|
104
|
+
model: Optional[str] = None,
|
|
105
|
+
framework: Optional[str] = None,
|
|
106
|
+
interactive: bool = False,
|
|
107
|
+
verbose: bool = False,
|
|
108
|
+
stream: bool = True,
|
|
109
|
+
trace: bool = False,
|
|
110
|
+
memory: bool = False,
|
|
111
|
+
tools: Optional[str] = None,
|
|
112
|
+
max_tokens: int = 16000,
|
|
113
|
+
):
|
|
114
|
+
"""Run agents from a YAML file."""
|
|
115
|
+
output = get_output_controller()
|
|
116
|
+
|
|
117
|
+
try:
|
|
118
|
+
# Use existing PraisonAI class
|
|
119
|
+
from praisonai.cli.main import PraisonAI
|
|
120
|
+
|
|
121
|
+
praison = PraisonAI(
|
|
122
|
+
agent_file=file_path,
|
|
123
|
+
framework=framework or "praisonai",
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# Set model if provided
|
|
127
|
+
if model:
|
|
128
|
+
praison.config_list[0]['model'] = model
|
|
129
|
+
|
|
130
|
+
# Run
|
|
131
|
+
result = praison.run()
|
|
132
|
+
|
|
133
|
+
output.emit_result(
|
|
134
|
+
message="Run completed",
|
|
135
|
+
data={"result": str(result) if result else None}
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
if result:
|
|
139
|
+
if not output.is_json_mode:
|
|
140
|
+
output.print_success("Run completed")
|
|
141
|
+
|
|
142
|
+
except Exception as e:
|
|
143
|
+
output.emit_error(message=str(e))
|
|
144
|
+
output.print_error(str(e))
|
|
145
|
+
raise typer.Exit(1)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def _run_prompt(
|
|
149
|
+
prompt: str,
|
|
150
|
+
model: Optional[str] = None,
|
|
151
|
+
verbose: bool = False,
|
|
152
|
+
stream: bool = True,
|
|
153
|
+
trace: bool = False,
|
|
154
|
+
memory: bool = False,
|
|
155
|
+
tools: Optional[str] = None,
|
|
156
|
+
max_tokens: int = 16000,
|
|
157
|
+
):
|
|
158
|
+
"""Run a direct prompt."""
|
|
159
|
+
output = get_output_controller()
|
|
160
|
+
|
|
161
|
+
try:
|
|
162
|
+
# Use existing handle_direct_prompt
|
|
163
|
+
from praisonai.cli.main import PraisonAI
|
|
164
|
+
|
|
165
|
+
praison = PraisonAI()
|
|
166
|
+
|
|
167
|
+
if model:
|
|
168
|
+
praison.config_list[0]['model'] = model
|
|
169
|
+
|
|
170
|
+
# Create args-like object for handle_direct_prompt
|
|
171
|
+
class Args:
|
|
172
|
+
pass
|
|
173
|
+
|
|
174
|
+
args = Args()
|
|
175
|
+
args.llm = model
|
|
176
|
+
args.verbose = verbose
|
|
177
|
+
args.memory = memory
|
|
178
|
+
args.tools = tools
|
|
179
|
+
args.max_tokens = max_tokens
|
|
180
|
+
args.web_search = False
|
|
181
|
+
args.web_fetch = False
|
|
182
|
+
args.prompt_caching = False
|
|
183
|
+
args.planning = False
|
|
184
|
+
args.planning_tools = None
|
|
185
|
+
args.planning_reasoning = False
|
|
186
|
+
args.auto_approve_plan = False
|
|
187
|
+
args.final_agent = None
|
|
188
|
+
args.user_id = None
|
|
189
|
+
args.auto_save = None
|
|
190
|
+
args.history = None
|
|
191
|
+
args.include_rules = None
|
|
192
|
+
args.workflow = None
|
|
193
|
+
args.workflow_var = None
|
|
194
|
+
args.claude_memory = False
|
|
195
|
+
args.guardrail = None
|
|
196
|
+
args.metrics = False
|
|
197
|
+
args.image = None
|
|
198
|
+
args.image_generate = False
|
|
199
|
+
args.telemetry = False
|
|
200
|
+
args.mcp = None
|
|
201
|
+
args.mcp_env = None
|
|
202
|
+
args.fast_context = None
|
|
203
|
+
args.handoff = None
|
|
204
|
+
args.auto_memory = False
|
|
205
|
+
args.todo = False
|
|
206
|
+
args.router = False
|
|
207
|
+
args.router_provider = None
|
|
208
|
+
args.query_rewrite = False
|
|
209
|
+
args.rewrite_tools = None
|
|
210
|
+
args.expand_prompt = False
|
|
211
|
+
args.expand_tools = None
|
|
212
|
+
args.no_tools = False
|
|
213
|
+
|
|
214
|
+
praison.args = args
|
|
215
|
+
result = praison.handle_direct_prompt(prompt)
|
|
216
|
+
|
|
217
|
+
output.emit_result(
|
|
218
|
+
message="Prompt completed",
|
|
219
|
+
data={"result": str(result) if result else None}
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
if result and not output.is_json_mode:
|
|
223
|
+
print(result)
|
|
224
|
+
|
|
225
|
+
except Exception as e:
|
|
226
|
+
output.emit_error(message=str(e))
|
|
227
|
+
output.print_error(str(e))
|
|
228
|
+
raise typer.Exit(1)
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Schedule command group for PraisonAI CLI.
|
|
3
|
+
|
|
4
|
+
Provides scheduler management.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
import typer
|
|
10
|
+
|
|
11
|
+
from ..output.console import get_output_controller
|
|
12
|
+
|
|
13
|
+
app = typer.Typer(help="Scheduler management")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _run_schedule(args: list) -> int:
|
|
17
|
+
"""Run schedule command with args."""
|
|
18
|
+
try:
|
|
19
|
+
from ..features.agent_scheduler import AgentSchedulerHandler
|
|
20
|
+
|
|
21
|
+
# Parse subcommand
|
|
22
|
+
if args and args[0] in ['start', 'list', 'stop', 'logs', 'restart', 'delete', 'describe', 'save', 'stop-all', 'stats']:
|
|
23
|
+
subcommand = args[0]
|
|
24
|
+
remaining = args[1:] if len(args) > 1 else []
|
|
25
|
+
|
|
26
|
+
# Create minimal args namespace
|
|
27
|
+
class Args:
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
fake_args = Args()
|
|
31
|
+
return AgentSchedulerHandler.handle_daemon_command(subcommand, fake_args, remaining)
|
|
32
|
+
|
|
33
|
+
return 0
|
|
34
|
+
except ImportError as e:
|
|
35
|
+
output = get_output_controller()
|
|
36
|
+
output.print_error(f"Scheduler module not available: {e}")
|
|
37
|
+
return 4
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@app.command("start")
|
|
41
|
+
def schedule_start(
|
|
42
|
+
agents_file: str = typer.Argument("agents.yaml", help="Agents YAML file"),
|
|
43
|
+
interval: Optional[str] = typer.Option(None, "--interval", "-i", help="Schedule interval (e.g., 'hourly', '*/30m')"),
|
|
44
|
+
daemon: bool = typer.Option(True, "--daemon/--no-daemon", help="Run as daemon"),
|
|
45
|
+
name: Optional[str] = typer.Option(None, "--name", "-n", help="Job name"),
|
|
46
|
+
):
|
|
47
|
+
"""Start scheduled agent execution."""
|
|
48
|
+
args = ["start", agents_file]
|
|
49
|
+
if interval:
|
|
50
|
+
args.extend(["--interval", interval])
|
|
51
|
+
if not daemon:
|
|
52
|
+
args.append("--no-daemon")
|
|
53
|
+
if name:
|
|
54
|
+
args.extend(["--name", name])
|
|
55
|
+
|
|
56
|
+
raise typer.Exit(_run_schedule(args))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@app.command("stop")
|
|
60
|
+
def schedule_stop(
|
|
61
|
+
job_id: Optional[str] = typer.Argument(None, help="Job ID to stop (or 'all')"),
|
|
62
|
+
):
|
|
63
|
+
"""Stop scheduled job(s)."""
|
|
64
|
+
if job_id == "all":
|
|
65
|
+
raise typer.Exit(_run_schedule(["stop-all"]))
|
|
66
|
+
elif job_id:
|
|
67
|
+
raise typer.Exit(_run_schedule(["stop", job_id]))
|
|
68
|
+
else:
|
|
69
|
+
raise typer.Exit(_run_schedule(["stop"]))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@app.command("list")
|
|
73
|
+
def schedule_list(
|
|
74
|
+
json_output: bool = typer.Option(False, "--json", help="Output JSON"),
|
|
75
|
+
):
|
|
76
|
+
"""List scheduled jobs."""
|
|
77
|
+
args = ["list"]
|
|
78
|
+
if json_output:
|
|
79
|
+
args.append("--json")
|
|
80
|
+
raise typer.Exit(_run_schedule(args))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@app.command("logs")
|
|
84
|
+
def schedule_logs(
|
|
85
|
+
job_id: Optional[str] = typer.Argument(None, help="Job ID"),
|
|
86
|
+
tail: int = typer.Option(50, "--tail", "-n", help="Number of lines"),
|
|
87
|
+
follow: bool = typer.Option(False, "--follow", "-f", help="Follow log output"),
|
|
88
|
+
):
|
|
89
|
+
"""View scheduler logs."""
|
|
90
|
+
args = ["logs"]
|
|
91
|
+
if job_id:
|
|
92
|
+
args.append(job_id)
|
|
93
|
+
args.extend(["--tail", str(tail)])
|
|
94
|
+
if follow:
|
|
95
|
+
args.append("--follow")
|
|
96
|
+
raise typer.Exit(_run_schedule(args))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@app.command("restart")
|
|
100
|
+
def schedule_restart(
|
|
101
|
+
job_id: str = typer.Argument(..., help="Job ID to restart"),
|
|
102
|
+
):
|
|
103
|
+
"""Restart a scheduled job."""
|
|
104
|
+
raise typer.Exit(_run_schedule(["restart", job_id]))
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@app.command("delete")
|
|
108
|
+
def schedule_delete(
|
|
109
|
+
job_id: str = typer.Argument(..., help="Job ID to delete"),
|
|
110
|
+
confirm: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation"),
|
|
111
|
+
):
|
|
112
|
+
"""Delete a scheduled job."""
|
|
113
|
+
if not confirm:
|
|
114
|
+
confirmed = typer.confirm(f"Delete job {job_id}?")
|
|
115
|
+
if not confirmed:
|
|
116
|
+
output = get_output_controller()
|
|
117
|
+
output.print_info("Cancelled")
|
|
118
|
+
raise typer.Exit(0)
|
|
119
|
+
|
|
120
|
+
raise typer.Exit(_run_schedule(["delete", job_id]))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@app.command("describe")
|
|
124
|
+
def schedule_describe(
|
|
125
|
+
job_id: str = typer.Argument(..., help="Job ID"),
|
|
126
|
+
json_output: bool = typer.Option(False, "--json", help="Output JSON"),
|
|
127
|
+
):
|
|
128
|
+
"""Show job details."""
|
|
129
|
+
args = ["describe", job_id]
|
|
130
|
+
if json_output:
|
|
131
|
+
args.append("--json")
|
|
132
|
+
raise typer.Exit(_run_schedule(args))
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@app.command("stats")
|
|
136
|
+
def schedule_stats(
|
|
137
|
+
json_output: bool = typer.Option(False, "--json", help="Output JSON"),
|
|
138
|
+
):
|
|
139
|
+
"""Show scheduler statistics."""
|
|
140
|
+
args = ["stats"]
|
|
141
|
+
if json_output:
|
|
142
|
+
args.append("--json")
|
|
143
|
+
raise typer.Exit(_run_schedule(args))
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@app.callback(invoke_without_command=True)
|
|
147
|
+
def schedule_callback(ctx: typer.Context):
|
|
148
|
+
"""Show schedule help or list jobs."""
|
|
149
|
+
if ctx.invoked_subcommand is None:
|
|
150
|
+
schedule_list(json_output=False)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Serve command group for PraisonAI CLI.
|
|
3
|
+
|
|
4
|
+
Provides API server management.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
import typer
|
|
10
|
+
|
|
11
|
+
from ..output.console import get_output_controller
|
|
12
|
+
|
|
13
|
+
app = typer.Typer(help="API server management")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.command("start")
|
|
17
|
+
def serve_start(
|
|
18
|
+
host: str = typer.Option("0.0.0.0", "--host", "-h", help="Host to bind to"),
|
|
19
|
+
port: int = typer.Option(8000, "--port", "-p", help="Port to bind to"),
|
|
20
|
+
agents_file: Optional[str] = typer.Option(None, "--agents", "-a", help="Agents YAML file"),
|
|
21
|
+
reload: bool = typer.Option(False, "--reload", help="Enable auto-reload"),
|
|
22
|
+
workers: int = typer.Option(1, "--workers", "-w", help="Number of workers"),
|
|
23
|
+
):
|
|
24
|
+
"""Start API server."""
|
|
25
|
+
output = get_output_controller()
|
|
26
|
+
|
|
27
|
+
# Build args for existing handler
|
|
28
|
+
args = [
|
|
29
|
+
"start",
|
|
30
|
+
"--host", host,
|
|
31
|
+
"--port", str(port),
|
|
32
|
+
"--workers", str(workers),
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
if agents_file:
|
|
36
|
+
args.extend(["--agents", agents_file])
|
|
37
|
+
if reload:
|
|
38
|
+
args.append("--reload")
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
from ..features.serve import handle_serve_command
|
|
42
|
+
exit_code = handle_serve_command(args)
|
|
43
|
+
raise typer.Exit(exit_code)
|
|
44
|
+
except ImportError as e:
|
|
45
|
+
output.print_error(f"Serve module not available: {e}")
|
|
46
|
+
raise typer.Exit(4)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@app.command("stop")
|
|
50
|
+
def serve_stop():
|
|
51
|
+
"""Stop API server."""
|
|
52
|
+
output = get_output_controller()
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
from ..features.serve import handle_serve_command
|
|
56
|
+
exit_code = handle_serve_command(["stop"])
|
|
57
|
+
raise typer.Exit(exit_code)
|
|
58
|
+
except ImportError as e:
|
|
59
|
+
output.print_error(f"Serve module not available: {e}")
|
|
60
|
+
raise typer.Exit(4)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@app.command("status")
|
|
64
|
+
def serve_status(
|
|
65
|
+
json_output: bool = typer.Option(False, "--json", help="Output JSON"),
|
|
66
|
+
):
|
|
67
|
+
"""Show server status."""
|
|
68
|
+
output = get_output_controller()
|
|
69
|
+
|
|
70
|
+
args = ["status"]
|
|
71
|
+
if json_output:
|
|
72
|
+
args.append("--json")
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
from ..features.serve import handle_serve_command
|
|
76
|
+
exit_code = handle_serve_command(args)
|
|
77
|
+
raise typer.Exit(exit_code)
|
|
78
|
+
except ImportError as e:
|
|
79
|
+
output.print_error(f"Serve module not available: {e}")
|
|
80
|
+
raise typer.Exit(4)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@app.callback(invoke_without_command=True)
|
|
84
|
+
def serve_callback(ctx: typer.Context):
|
|
85
|
+
"""Show serve help or start server."""
|
|
86
|
+
if ctx.invoked_subcommand is None:
|
|
87
|
+
output = get_output_controller()
|
|
88
|
+
output.print_panel(
|
|
89
|
+
"API server management.\n\n"
|
|
90
|
+
"Commands:\n"
|
|
91
|
+
" start Start API server\n"
|
|
92
|
+
" stop Stop API server\n"
|
|
93
|
+
" status Show server status\n\n"
|
|
94
|
+
"Quick start:\n"
|
|
95
|
+
" praisonai serve start --agents agents.yaml",
|
|
96
|
+
title="Serve Commands"
|
|
97
|
+
)
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Session command group for PraisonAI CLI.
|
|
3
|
+
|
|
4
|
+
Provides session management:
|
|
5
|
+
- session list: List all sessions
|
|
6
|
+
- session resume: Resume a session
|
|
7
|
+
- session delete: Delete a session
|
|
8
|
+
- session export: Export a session
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from typing import Optional
|
|
12
|
+
|
|
13
|
+
import typer
|
|
14
|
+
|
|
15
|
+
from ..output.console import get_output_controller
|
|
16
|
+
from ..state.sessions import get_session_manager
|
|
17
|
+
|
|
18
|
+
app = typer.Typer(help="Session management")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@app.command("list")
|
|
22
|
+
def session_list(
|
|
23
|
+
limit: int = typer.Option(
|
|
24
|
+
20,
|
|
25
|
+
"--limit",
|
|
26
|
+
"-n",
|
|
27
|
+
help="Maximum number of sessions to show",
|
|
28
|
+
),
|
|
29
|
+
):
|
|
30
|
+
"""List all sessions."""
|
|
31
|
+
output = get_output_controller()
|
|
32
|
+
manager = get_session_manager()
|
|
33
|
+
|
|
34
|
+
sessions = manager.list(limit=limit)
|
|
35
|
+
|
|
36
|
+
if output.is_json_mode:
|
|
37
|
+
output.print_json({
|
|
38
|
+
"sessions": [s.to_dict() for s in sessions]
|
|
39
|
+
})
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
if not sessions:
|
|
43
|
+
output.print_info("No sessions found")
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
headers = ["ID", "Name", "Status", "Events", "Updated"]
|
|
47
|
+
rows = []
|
|
48
|
+
for s in sessions:
|
|
49
|
+
rows.append([
|
|
50
|
+
s.session_id[:20] + "..." if len(s.session_id) > 20 else s.session_id,
|
|
51
|
+
s.name or "-",
|
|
52
|
+
s.status,
|
|
53
|
+
str(s.event_count),
|
|
54
|
+
s.updated_at.strftime("%Y-%m-%d %H:%M"),
|
|
55
|
+
])
|
|
56
|
+
|
|
57
|
+
output.print_table(headers, rows, title="Sessions")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@app.command("resume")
|
|
61
|
+
def session_resume(
|
|
62
|
+
session_id: str = typer.Argument(..., help="Session ID to resume"),
|
|
63
|
+
):
|
|
64
|
+
"""Resume a session."""
|
|
65
|
+
output = get_output_controller()
|
|
66
|
+
manager = get_session_manager()
|
|
67
|
+
|
|
68
|
+
session = manager.get(session_id)
|
|
69
|
+
|
|
70
|
+
if not session:
|
|
71
|
+
output.print_error(
|
|
72
|
+
f"Session not found: {session_id}",
|
|
73
|
+
remediation="Use 'praisonai session list' to see available sessions"
|
|
74
|
+
)
|
|
75
|
+
raise typer.Exit(1)
|
|
76
|
+
|
|
77
|
+
# Load session events
|
|
78
|
+
events = manager.get_events(session_id)
|
|
79
|
+
|
|
80
|
+
if output.is_json_mode:
|
|
81
|
+
output.print_json({
|
|
82
|
+
"session": session.to_dict(),
|
|
83
|
+
"events": events,
|
|
84
|
+
"message": "Session loaded. True resume not supported - showing transcript.",
|
|
85
|
+
})
|
|
86
|
+
return
|
|
87
|
+
|
|
88
|
+
output.print_panel(
|
|
89
|
+
f"Session: {session.name or session.session_id}\n"
|
|
90
|
+
f"Run ID: {session.run_id}\n"
|
|
91
|
+
f"Trace ID: {session.trace_id}\n"
|
|
92
|
+
f"Events: {session.event_count}\n"
|
|
93
|
+
f"Status: {session.status}",
|
|
94
|
+
title="Session Loaded"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
output.print_warning(
|
|
98
|
+
"True session resume is not yet supported. "
|
|
99
|
+
"Showing session transcript instead."
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# Show recent events
|
|
103
|
+
if events:
|
|
104
|
+
output.print("\n--- Recent Events ---\n")
|
|
105
|
+
for event in events[-10:]:
|
|
106
|
+
event_type = event.get("event", "unknown")
|
|
107
|
+
message = event.get("message", "")
|
|
108
|
+
output.print(f"[{event_type}] {message}")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@app.command("delete")
|
|
112
|
+
def session_delete(
|
|
113
|
+
session_id: str = typer.Argument(..., help="Session ID to delete"),
|
|
114
|
+
confirm: bool = typer.Option(
|
|
115
|
+
False,
|
|
116
|
+
"--yes",
|
|
117
|
+
"-y",
|
|
118
|
+
help="Skip confirmation",
|
|
119
|
+
),
|
|
120
|
+
):
|
|
121
|
+
"""Delete a session."""
|
|
122
|
+
output = get_output_controller()
|
|
123
|
+
manager = get_session_manager()
|
|
124
|
+
|
|
125
|
+
session = manager.get(session_id)
|
|
126
|
+
|
|
127
|
+
if not session:
|
|
128
|
+
output.print_error(f"Session not found: {session_id}")
|
|
129
|
+
raise typer.Exit(1)
|
|
130
|
+
|
|
131
|
+
if not confirm:
|
|
132
|
+
confirmed = typer.confirm(f"Delete session {session_id}?")
|
|
133
|
+
if not confirmed:
|
|
134
|
+
output.print_info("Cancelled")
|
|
135
|
+
raise typer.Exit(0)
|
|
136
|
+
|
|
137
|
+
deleted = manager.delete(session_id)
|
|
138
|
+
|
|
139
|
+
if output.is_json_mode:
|
|
140
|
+
output.print_json({"deleted": deleted, "session_id": session_id})
|
|
141
|
+
else:
|
|
142
|
+
if deleted:
|
|
143
|
+
output.print_success(f"Deleted session: {session_id}")
|
|
144
|
+
else:
|
|
145
|
+
output.print_error(f"Failed to delete session: {session_id}")
|
|
146
|
+
raise typer.Exit(1)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@app.command("export")
|
|
150
|
+
def session_export(
|
|
151
|
+
session_id: str = typer.Argument(..., help="Session ID to export"),
|
|
152
|
+
format: str = typer.Option(
|
|
153
|
+
"md",
|
|
154
|
+
"--format",
|
|
155
|
+
"-f",
|
|
156
|
+
help="Export format: md or json",
|
|
157
|
+
),
|
|
158
|
+
output_file: Optional[str] = typer.Option(
|
|
159
|
+
None,
|
|
160
|
+
"--output",
|
|
161
|
+
"-o",
|
|
162
|
+
help="Output file path",
|
|
163
|
+
),
|
|
164
|
+
):
|
|
165
|
+
"""Export a session."""
|
|
166
|
+
output = get_output_controller()
|
|
167
|
+
manager = get_session_manager()
|
|
168
|
+
|
|
169
|
+
content = manager.export(session_id, format=format)
|
|
170
|
+
|
|
171
|
+
if content is None:
|
|
172
|
+
output.print_error(f"Session not found: {session_id}")
|
|
173
|
+
raise typer.Exit(1)
|
|
174
|
+
|
|
175
|
+
if output_file:
|
|
176
|
+
with open(output_file, "w", encoding="utf-8") as f:
|
|
177
|
+
f.write(content)
|
|
178
|
+
output.print_success(f"Exported to: {output_file}")
|
|
179
|
+
else:
|
|
180
|
+
print(content)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
@app.command("show")
|
|
184
|
+
def session_show(
|
|
185
|
+
session_id: str = typer.Argument(..., help="Session ID to show"),
|
|
186
|
+
):
|
|
187
|
+
"""Show session details."""
|
|
188
|
+
output = get_output_controller()
|
|
189
|
+
manager = get_session_manager()
|
|
190
|
+
|
|
191
|
+
session = manager.get(session_id)
|
|
192
|
+
|
|
193
|
+
if not session:
|
|
194
|
+
output.print_error(f"Session not found: {session_id}")
|
|
195
|
+
raise typer.Exit(1)
|
|
196
|
+
|
|
197
|
+
if output.is_json_mode:
|
|
198
|
+
output.print_json(session.to_dict())
|
|
199
|
+
return
|
|
200
|
+
|
|
201
|
+
output.print_panel(
|
|
202
|
+
f"Session ID: {session.session_id}\n"
|
|
203
|
+
f"Name: {session.name or '-'}\n"
|
|
204
|
+
f"Run ID: {session.run_id}\n"
|
|
205
|
+
f"Trace ID: {session.trace_id}\n"
|
|
206
|
+
f"Created: {session.created_at.isoformat()}\n"
|
|
207
|
+
f"Updated: {session.updated_at.isoformat()}\n"
|
|
208
|
+
f"Status: {session.status}\n"
|
|
209
|
+
f"Events: {session.event_count}\n"
|
|
210
|
+
f"Workspace: {session.workspace or '-'}",
|
|
211
|
+
title="Session Details"
|
|
212
|
+
)
|