praisonAI 2.3.70__tar.gz → 2.3.72__tar.gz

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.
Files changed (119) hide show
  1. {praisonai-2.3.70 → praisonai-2.3.72}/PKG-INFO +1 -1
  2. {praisonai-2.3.70 → praisonai-2.3.72}/PraisonAI.egg-info/PKG-INFO +1 -1
  3. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/agent_scheduler.py +131 -42
  4. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/main.py +6 -4
  5. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/deploy.py +1 -1
  6. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/scheduler/agent_scheduler.py +25 -19
  7. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/scheduler/daemon_manager.py +4 -11
  8. praisonai-2.3.72/praisonai/version.py +1 -0
  9. praisonai-2.3.70/praisonai/version.py +0 -1
  10. {praisonai-2.3.70 → praisonai-2.3.72}/PraisonAI.egg-info/SOURCES.txt +0 -0
  11. {praisonai-2.3.70 → praisonai-2.3.72}/PraisonAI.egg-info/dependency_links.txt +0 -0
  12. {praisonai-2.3.70 → praisonai-2.3.72}/PraisonAI.egg-info/entry_points.txt +0 -0
  13. {praisonai-2.3.70 → praisonai-2.3.72}/PraisonAI.egg-info/requires.txt +0 -0
  14. {praisonai-2.3.70 → praisonai-2.3.72}/PraisonAI.egg-info/top_level.txt +0 -0
  15. {praisonai-2.3.70 → praisonai-2.3.72}/README.md +0 -0
  16. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/__init__.py +0 -0
  17. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/__main__.py +0 -0
  18. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/agent_scheduler.py +0 -0
  19. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/agents_generator.py +0 -0
  20. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/api/call.py +0 -0
  21. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/auto.py +0 -0
  22. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/chainlit_ui.py +0 -0
  23. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/__init__.py +0 -0
  24. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/__init__.py +0 -0
  25. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/at_mentions.py +0 -0
  26. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/auto_memory.py +0 -0
  27. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/autonomy_mode.py +0 -0
  28. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/base.py +0 -0
  29. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/cost_tracker.py +0 -0
  30. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/external_agents.py +0 -0
  31. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/fast_context.py +0 -0
  32. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/flow_display.py +0 -0
  33. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/git_integration.py +0 -0
  34. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/guardrail.py +0 -0
  35. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/handoff.py +0 -0
  36. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/image.py +0 -0
  37. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/interactive_tui.py +0 -0
  38. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/knowledge.py +0 -0
  39. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/mcp.py +0 -0
  40. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/message_queue.py +0 -0
  41. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/metrics.py +0 -0
  42. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/n8n.py +0 -0
  43. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/repo_map.py +0 -0
  44. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/router.py +0 -0
  45. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/sandbox_executor.py +0 -0
  46. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/session.py +0 -0
  47. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/slash_commands.py +0 -0
  48. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/telemetry.py +0 -0
  49. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/todo.py +0 -0
  50. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/tools.py +0 -0
  51. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/features/workflow.py +0 -0
  52. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/cli/schedule_cli.py +0 -0
  53. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/__init__.py +0 -0
  54. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/agent_tools.py +0 -0
  55. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/diff/__init__.py +0 -0
  56. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/diff/diff_strategy.py +0 -0
  57. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/tools/__init__.py +0 -0
  58. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/tools/apply_diff.py +0 -0
  59. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/tools/execute_command.py +0 -0
  60. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/tools/list_files.py +0 -0
  61. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/tools/read_file.py +0 -0
  62. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/tools/search_replace.py +0 -0
  63. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/tools/write_file.py +0 -0
  64. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/utils/__init__.py +0 -0
  65. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/utils/file_utils.py +0 -0
  66. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/utils/ignore_utils.py +0 -0
  67. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/code/utils/text_utils.py +0 -0
  68. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/inbuilt_tools/__init__.py +0 -0
  69. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/inbuilt_tools/autogen_tools.py +0 -0
  70. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/inc/__init__.py +0 -0
  71. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/inc/config.py +0 -0
  72. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/inc/models.py +0 -0
  73. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/integrations/__init__.py +0 -0
  74. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/integrations/base.py +0 -0
  75. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/integrations/claude_code.py +0 -0
  76. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/integrations/codex_cli.py +0 -0
  77. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/integrations/cursor_cli.py +0 -0
  78. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/integrations/gemini_cli.py +0 -0
  79. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/profiler.py +0 -0
  80. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/scheduler/__init__.py +0 -0
  81. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/scheduler/base.py +0 -0
  82. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/scheduler/state_manager.py +0 -0
  83. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/scheduler/yaml_loader.py +0 -0
  84. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/scheduler.py +0 -0
  85. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/setup/__init__.py +0 -0
  86. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/setup/build.py +0 -0
  87. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/setup/post_install.py +0 -0
  88. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/setup/setup_conda_env.py +0 -0
  89. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/setup.py +0 -0
  90. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/test.py +0 -0
  91. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/train.py +0 -0
  92. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/train_vision.py +0 -0
  93. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/agents.py +0 -0
  94. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/callbacks.py +0 -0
  95. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/chat.py +0 -0
  96. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/code.py +0 -0
  97. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/colab.py +0 -0
  98. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/colab_chainlit.py +0 -0
  99. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/components/aicoder.py +0 -0
  100. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/context.py +0 -0
  101. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/database_config.py +0 -0
  102. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/db.py +0 -0
  103. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/realtime.py +0 -0
  104. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/realtimeclient/__init__.py +0 -0
  105. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/realtimeclient/tools.py +0 -0
  106. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/ui/sql_alchemy.py +0 -0
  107. {praisonai-2.3.70 → praisonai-2.3.72}/praisonai/upload_vision.py +0 -0
  108. {praisonai-2.3.70 → praisonai-2.3.72}/pyproject.toml +0 -0
  109. {praisonai-2.3.70 → praisonai-2.3.72}/setup.cfg +0 -0
  110. {praisonai-2.3.70 → praisonai-2.3.72}/tests/test.py +0 -0
  111. {praisonai-2.3.70 → praisonai-2.3.72}/tests/test_agents_playbook.py +0 -0
  112. {praisonai-2.3.70 → praisonai-2.3.72}/tests/test_approval_system.py +0 -0
  113. {praisonai-2.3.70 → praisonai-2.3.72}/tests/test_basic.py +0 -0
  114. {praisonai-2.3.70 → praisonai-2.3.72}/tests/test_cli_features.py +0 -0
  115. {praisonai-2.3.70 → praisonai-2.3.72}/tests/test_custom_tools_fix.py +0 -0
  116. {praisonai-2.3.70 → praisonai-2.3.72}/tests/test_double_api_fix.py +0 -0
  117. {praisonai-2.3.70 → praisonai-2.3.72}/tests/test_n8n_integration.py +0 -0
  118. {praisonai-2.3.70 → praisonai-2.3.72}/tests/test_phase2_refactor.py +0 -0
  119. {praisonai-2.3.70 → praisonai-2.3.72}/tests/test_runner.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PraisonAI
3
- Version: 2.3.70
3
+ Version: 2.3.72
4
4
  Summary: PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration.
5
5
  Author: Mervin Praison
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PraisonAI
3
- Version: 2.3.70
3
+ Version: 2.3.72
4
4
  Summary: PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration.
5
5
  Author: Mervin Praison
6
6
  License: MIT
@@ -47,10 +47,14 @@ class AgentSchedulerHandler:
47
47
  return AgentSchedulerHandler._handle_describe(unknown_args, state_manager, daemon_manager)
48
48
  elif subcommand == "save":
49
49
  return AgentSchedulerHandler._handle_save(unknown_args, state_manager)
50
+ elif subcommand == "stop-all":
51
+ return AgentSchedulerHandler._handle_stop_all(state_manager, daemon_manager)
52
+ elif subcommand == "stats":
53
+ return AgentSchedulerHandler._handle_stats(state_manager, unknown_args, daemon_manager)
50
54
  else:
51
55
  print(f"❌ Unknown subcommand: {subcommand}")
52
56
  print("\nAvailable commands:")
53
- print(" start, list, stop, logs, restart, delete, describe, save")
57
+ print(" start, list, stop, logs, restart, delete, describe, save, stop-all, stats")
54
58
  return 1
55
59
 
56
60
  @staticmethod
@@ -164,6 +168,94 @@ class AgentSchedulerHandler:
164
168
  print(f"\nTotal: {len(states)} scheduler(s)")
165
169
  return 0
166
170
 
171
+ @staticmethod
172
+ def _handle_stats(state_manager, unknown_args=None, daemon_manager=None) -> int:
173
+ """Handle 'schedule stats' command - show aggregate or individual statistics."""
174
+ # If a name is provided, show individual stats (alias for describe)
175
+ if unknown_args and len(unknown_args) > 0:
176
+ name = unknown_args[0]
177
+ return AgentSchedulerHandler._handle_describe([name], state_manager, daemon_manager)
178
+
179
+ # Otherwise show aggregate stats
180
+ states = state_manager.list_all()
181
+
182
+ if not states:
183
+ print("No schedulers found.")
184
+ print("\nStart one with:")
185
+ print(' praisonai schedule start <name> "Your task" --interval hourly')
186
+ return 0
187
+
188
+ # Calculate aggregate stats
189
+ total_schedulers = len(states)
190
+ running = sum(1 for s in states if s.get('status') == 'running')
191
+ stopped = total_schedulers - running
192
+ total_executions = sum(s.get('executions', 0) for s in states)
193
+ total_cost = sum(s.get('cost', 0.0) for s in states)
194
+
195
+ print(f"\n{'='*60}")
196
+ print(f"📊 Aggregate Scheduler Statistics")
197
+ print(f"{'='*60}")
198
+ print(f"Total Schedulers: {total_schedulers}")
199
+ print(f" 🟢 Running: {running}")
200
+ print(f" 🔴 Stopped: {stopped}")
201
+ print(f"\nTotal Executions: {total_executions}")
202
+ print(f"Total Cost: ${total_cost:.4f}")
203
+
204
+ if total_executions > 0:
205
+ avg_cost = total_cost / total_executions
206
+ print(f"Avg Cost/Execution: ${avg_cost:.4f}")
207
+
208
+ print(f"{'='*60}\n")
209
+
210
+ # Show per-scheduler breakdown
211
+ print("Per-Scheduler Breakdown:")
212
+ print(f"{'Name':<20} {'Status':<10} {'Executions':<12} {'Cost':<12}")
213
+ print("="*60)
214
+
215
+ for state in sorted(states, key=lambda x: x.get('executions', 0), reverse=True):
216
+ name = state['name'][:20]
217
+ status = state.get('status', 'unknown')
218
+ executions = state.get('executions', 0)
219
+ cost = state.get('cost', 0.0)
220
+
221
+ status_icon = "🟢" if status == "running" else "🔴"
222
+ print(f"{name:<20} {status_icon} {status:<8} {executions:<12} ${cost:<11.4f}")
223
+
224
+ return 0
225
+
226
+ @staticmethod
227
+ def _handle_stop_all(state_manager, daemon_manager) -> int:
228
+ """Handle 'schedule stop-all' command."""
229
+ states = state_manager.list_all()
230
+
231
+ if not states:
232
+ print("No schedulers running.")
233
+ return 0
234
+
235
+ print(f"\n🛑 Stopping all schedulers ({len(states)} total)...\n")
236
+
237
+ stopped = 0
238
+ failed = 0
239
+
240
+ for state in states:
241
+ name = state['name']
242
+ pid = state['pid']
243
+
244
+ try:
245
+ if daemon_manager.stop_daemon(pid):
246
+ state_manager.delete_state(name)
247
+ print(f"✅ Stopped '{name}' (PID: {pid})")
248
+ stopped += 1
249
+ else:
250
+ print(f"❌ Failed to stop '{name}' (PID: {pid})")
251
+ failed += 1
252
+ except Exception as e:
253
+ print(f"❌ Error stopping '{name}': {e}")
254
+ failed += 1
255
+
256
+ print(f"\n📊 Summary: {stopped} stopped, {failed} failed")
257
+ return 0 if failed == 0 else 1
258
+
167
259
  @staticmethod
168
260
  def _handle_stop(unknown_args, state_manager, daemon_manager) -> int:
169
261
  """Handle 'schedule stop' command."""
@@ -416,7 +508,7 @@ class AgentSchedulerHandler:
416
508
  return 1
417
509
 
418
510
  @staticmethod
419
- def handle_schedule_command(args, unknown_args=None) -> int:
511
+ def handle_schedule_command(args, unknown_args, daemon_mode=False) -> int:
420
512
  """
421
513
  Handle the schedule command for running agents periodically.
422
514
 
@@ -483,41 +575,33 @@ class AgentSchedulerHandler:
483
575
  print(' praisonai schedule "Check news every hour" --interval hourly')
484
576
  return 1
485
577
 
486
- task_prompt = first_arg
487
- print(f"🤖 Creating scheduler for task: {task_prompt[:60]}...")
578
+ task = first_arg
488
579
 
489
- # Create a simple agent with the prompt
580
+ # Create agent
490
581
  agent = Agent(
491
582
  name="Scheduled Agent",
492
583
  role="Task Executor",
493
- goal=task_prompt,
494
- instructions=f"Execute this task: {task_prompt}",
495
- verbose=verbose
584
+ goal=task,
585
+ instructions=task,
586
+ verbose=True # Enable verbose to see output in logs
496
587
  )
497
588
 
498
589
  # Create scheduler
499
590
  scheduler = AgentScheduler(
500
591
  agent=agent,
501
- task=task_prompt,
592
+ task=task,
502
593
  timeout=timeout_override,
503
594
  max_cost=max_cost_override
504
595
  )
505
596
 
506
- # Display configuration
507
- agent_name = getattr(scheduler.agent, 'name', 'Agent')
508
- print(f"\n{'='*60}")
509
- print(f"🤖 Starting 24/7 {agent_name}")
510
- print(f"{'='*60}")
511
- print(f"Task: {scheduler.task[:80]}{'...' if len(scheduler.task) > 80 else ''}")
597
+ # Get configuration
598
+ interval = interval_override
599
+ max_retries = max_retries_override
512
600
 
513
- # Get schedule info
514
601
  if is_yaml_mode:
515
602
  schedule_config = scheduler._yaml_schedule_config
516
603
  interval = interval_override or schedule_config.get('interval', 'hourly')
517
604
  max_retries = max_retries_override or schedule_config.get('max_retries', 3)
518
- else:
519
- interval = interval_override
520
- max_retries = max_retries_override
521
605
 
522
606
  print(f"Schedule: {interval}")
523
607
  print(f"Max Retries: {max_retries}")
@@ -528,33 +612,38 @@ class AgentSchedulerHandler:
528
612
  print(f"{'='*60}\n")
529
613
 
530
614
  # Start scheduler
531
- print("⏰ Starting scheduler... (Press Ctrl+C to stop)\n")
532
615
  if is_yaml_mode:
533
616
  scheduler.start_from_yaml_config()
534
617
  else:
535
- scheduler.start(
536
- schedule_expr=interval,
537
- max_retries=max_retries,
538
- run_immediately=True
539
- )
618
+ scheduler.start(schedule_expr=interval, max_retries=max_retries, run_immediately=True)
540
619
 
541
- # Keep running until interrupted
542
- try:
543
- while scheduler.is_running:
544
- import time
545
- time.sleep(1)
546
- except KeyboardInterrupt:
547
- print("\n\n🛑 Stopping scheduler...")
548
- scheduler.stop()
549
-
550
- # Display final stats
551
- stats = scheduler.get_stats()
552
- print("\n📊 Final Statistics:")
553
- print(f" Total Executions: {stats['total_executions']}")
554
- print(f" Successful: {stats['successful_executions']}")
555
- print(f" Failed: {stats['failed_executions']}")
556
- print(f" Success Rate: {stats['success_rate']:.1f}%")
557
- print("\n✅ Agent stopped successfully\n")
620
+ # If daemon mode, block to keep process alive
621
+ if daemon_mode:
622
+ import time
623
+ try:
624
+ while scheduler.is_running:
625
+ time.sleep(1)
626
+ except KeyboardInterrupt:
627
+ scheduler.stop()
628
+ else:
629
+ # Foreground mode - wait for Ctrl+C
630
+ print("⏰ Starting scheduler... (Press Ctrl+C to stop)\n")
631
+ import time
632
+ try:
633
+ while scheduler.is_running:
634
+ time.sleep(1)
635
+ except KeyboardInterrupt:
636
+ print("\n\n🛑 Stopping scheduler...")
637
+ scheduler.stop()
638
+
639
+ # Display final stats
640
+ stats = scheduler.get_stats()
641
+ print("\n📊 Final Statistics:")
642
+ print(f" Total Executions: {stats['total_executions']}")
643
+ print(f" Successful: {stats['successful_executions']}")
644
+ print(f" Failed: {stats['failed_executions']}")
645
+ print(f" Success Rate: {stats['success_rate']:.1f}%")
646
+ print("\n✅ Agent stopped successfully\n")
558
647
 
559
648
  return 0
560
649
 
@@ -236,11 +236,12 @@ class PraisonAI:
236
236
  # Check for subcommands (start, list, stop, logs, restart)
237
237
  subcommand = unknown_args[0] if unknown_args and not unknown_args[0].startswith('-') else None
238
238
 
239
- if subcommand in ['start', 'list', 'stop', 'logs', 'restart', 'delete', 'describe', 'save']:
239
+ if subcommand in ['start', 'list', 'stop', 'logs', 'restart', 'delete', 'describe', 'save', 'stop-all', 'stats']:
240
240
  exit_code = AgentSchedulerHandler.handle_daemon_command(subcommand, args, unknown_args[1:] if len(unknown_args) > 1 else [])
241
241
  else:
242
- # Legacy mode: direct scheduling (foreground)
243
- exit_code = AgentSchedulerHandler.handle_schedule_command(args, unknown_args)
242
+ # Legacy mode: direct scheduling (foreground) or daemon mode
243
+ daemon_mode = getattr(args, 'daemon', False)
244
+ exit_code = AgentSchedulerHandler.handle_schedule_command(args, unknown_args, daemon_mode=daemon_mode)
244
245
 
245
246
  sys.exit(exit_code)
246
247
  elif args.command.startswith("tests.test") or args.command.startswith("tests/test"): # Argument used for testing purposes
@@ -734,7 +735,8 @@ class PraisonAI:
734
735
  parser.add_argument("--interval", dest="schedule_interval", type=str, help="Schedule interval (e.g., 'hourly', '*/30m', 'daily')")
735
736
  parser.add_argument("--schedule-max-retries", dest="schedule_max_retries", type=int, help="Maximum retry attempts for scheduled execution")
736
737
  parser.add_argument("--timeout", type=int, help="Maximum execution time per run in seconds")
737
- parser.add_argument("--max-cost", dest="max_cost", type=float, help="Maximum total cost budget in USD")
738
+ parser.add_argument('--max-cost', type=float, help='Maximum total cost budget in USD')
739
+ parser.add_argument('--daemon', action='store_true', help=argparse.SUPPRESS) # Hidden flag for daemon mode
738
740
 
739
741
  # If we're in a test environment, parse with empty args to avoid pytest interference
740
742
  if in_test_env:
@@ -57,7 +57,7 @@ class CloudDeployer:
57
57
  file.write("FROM python:3.11-slim\n")
58
58
  file.write("WORKDIR /app\n")
59
59
  file.write("COPY . .\n")
60
- file.write("RUN pip install flask praisonai==2.3.70 gunicorn markdown\n")
60
+ file.write("RUN pip install flask praisonai==2.3.72 gunicorn markdown\n")
61
61
  file.write("EXPOSE 8080\n")
62
62
  file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
63
63
 
@@ -100,16 +100,16 @@ class AgentScheduler:
100
100
  self.is_running = True
101
101
  self._stop_event.clear()
102
102
 
103
- logger.info(f"Starting agent scheduler: {getattr(self.agent, 'name', 'Agent')}")
104
- logger.info(f"Task: {self.task}")
105
- logger.info(f"Schedule: {schedule_expr} ({interval}s interval)")
103
+ logger.debug(f"Starting agent scheduler: {getattr(self.agent, 'name', 'Agent')}")
104
+ logger.debug(f"Task: {self.task}")
105
+ logger.debug(f"Schedule: {schedule_expr} ({interval}s interval)")
106
106
  self.is_running = True
107
107
  self._stop_event.clear()
108
108
  self._start_time = datetime.now()
109
109
 
110
110
  # Run immediately if requested
111
111
  if run_immediately:
112
- logger.info("Running agent immediately before starting schedule...")
112
+ logger.debug("Running agent immediately before starting schedule...")
113
113
  self._execute_with_retry(max_retries)
114
114
 
115
115
  self._thread = threading.Thread(
@@ -119,7 +119,7 @@ class AgentScheduler:
119
119
  )
120
120
  self._thread.start()
121
121
 
122
- logger.info("Agent scheduler started successfully")
122
+ logger.debug("Agent scheduler started successfully")
123
123
  if self.timeout:
124
124
  logger.info(f"Timeout per execution: {self.timeout}s")
125
125
  if self.max_cost:
@@ -139,18 +139,18 @@ class AgentScheduler:
139
139
  True if stopped successfully
140
140
  """
141
141
  if not self.is_running:
142
- logger.info("Scheduler is not running")
142
+ logger.debug("Scheduler is not running")
143
143
  return True
144
144
 
145
- logger.info("Stopping agent scheduler...")
145
+ logger.debug("Stopping agent scheduler...")
146
146
  self._stop_event.set()
147
147
 
148
148
  if self._thread and self._thread.is_alive():
149
149
  self._thread.join(timeout=10)
150
150
 
151
151
  self.is_running = False
152
- logger.info("Agent scheduler stopped")
153
- logger.info(f"Execution stats - Total: {self._execution_count}, Success: {self._success_count}, Failed: {self._failure_count}")
152
+ logger.debug("Agent scheduler stopped")
153
+ logger.debug(f"Execution stats - Total: {self._execution_count}, Success: {self._success_count}, Failed: {self._failure_count}")
154
154
  return True
155
155
 
156
156
  def get_stats(self) -> Dict[str, Any]:
@@ -219,15 +219,15 @@ class AgentScheduler:
219
219
  self.stop()
220
220
  break
221
221
 
222
- logger.info(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Starting scheduled agent execution")
222
+ logger.debug(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Starting scheduled agent execution")
223
223
 
224
224
  self._execute_with_retry(max_retries)
225
225
 
226
226
  # Wait for next scheduled time
227
- logger.info(f"Next execution in {interval} seconds ({interval/3600:.1f} hours)")
227
+ logger.debug(f"Next execution in {interval} seconds ({interval/3600:.1f} hours)")
228
228
  if self.max_cost:
229
229
  remaining = self.max_cost - self._total_cost
230
- logger.info(f"Budget remaining: ${remaining:.4f}")
230
+ logger.debug(f"Budget remaining: ${remaining:.4f}")
231
231
  self._stop_event.wait(interval)
232
232
 
233
233
  def _execute_with_retry(self, max_retries: int):
@@ -238,7 +238,7 @@ class AgentScheduler:
238
238
 
239
239
  for attempt in range(max_retries):
240
240
  try:
241
- logger.info(f"Attempt {attempt + 1}/{max_retries}")
241
+ logger.debug(f"Attempt {attempt + 1}/{max_retries}")
242
242
 
243
243
  # Execute with timeout if specified
244
244
  if self.timeout:
@@ -260,8 +260,8 @@ class AgentScheduler:
260
260
  else:
261
261
  result = self._executor.execute(self.task)
262
262
 
263
- logger.info(f"Agent execution successful on attempt {attempt + 1}")
264
- logger.info(f"Result: {result}")
263
+ logger.debug(f"Agent execution successful on attempt {attempt + 1}")
264
+ logger.debug(f"Result: {result}")
265
265
 
266
266
  # Always print result to stdout (even in non-verbose mode)
267
267
  print(f"\n✅ Agent Response:\n{result}\n")
@@ -269,7 +269,7 @@ class AgentScheduler:
269
269
  # Estimate cost (rough: ~$0.0001 per execution for gpt-4o-mini)
270
270
  estimated_cost = 0.0001 # Base cost estimate
271
271
  self._total_cost += estimated_cost
272
- logger.info(f"Estimated cost this run: ${estimated_cost:.4f}, Total: ${self._total_cost:.4f}")
272
+ logger.debug(f"Estimated cost this run: ${estimated_cost:.4f}, Total: ${self._total_cost:.4f}")
273
273
 
274
274
  self._success_count += 1
275
275
  success = True
@@ -279,6 +279,9 @@ class AgentScheduler:
279
279
  self.on_success(result)
280
280
  except Exception as e:
281
281
  logger.error(f"Callback error in on_success: {e}")
282
+
283
+ # Update state file after successful execution
284
+ self._update_state_if_daemon()
282
285
 
283
286
  break
284
287
 
@@ -290,7 +293,7 @@ class AgentScheduler:
290
293
 
291
294
  if attempt < max_retries - 1:
292
295
  wait_time = 30 * (attempt + 1) # Exponential backoff
293
- logger.info(f"Waiting {wait_time}s before retry...")
296
+ logger.debug(f"Waiting {wait_time}s before retry...")
294
297
  time.sleep(wait_time)
295
298
 
296
299
  if not success:
@@ -302,6 +305,9 @@ class AgentScheduler:
302
305
  self.on_failure(f"Failed after {max_retries} attempts")
303
306
  except Exception as e:
304
307
  logger.error(f"Callback error in on_failure: {e}")
308
+
309
+ # Update state file even after failure
310
+ self._update_state_if_daemon()
305
311
 
306
312
  def execute_once(self) -> Any:
307
313
  """
@@ -310,10 +316,10 @@ class AgentScheduler:
310
316
  Returns:
311
317
  Agent execution result
312
318
  """
313
- logger.info("Executing agent once")
319
+ logger.debug("Executing agent once")
314
320
  try:
315
321
  result = self._executor.execute(self.task)
316
- logger.info(f"One-time execution successful: {result}")
322
+ logger.debug(f"One-time execution successful: {result}")
317
323
 
318
324
  if self.on_success:
319
325
  try:
@@ -50,14 +50,8 @@ class DaemonManager:
50
50
  """
51
51
  log_file = self.log_dir / f"{name}.log"
52
52
 
53
- # Open log file
53
+ # Open log file - use original working approach
54
54
  with open(log_file, 'a') as log:
55
- log.write(f"\n{'='*60}\n")
56
- log.write(f"Starting daemon: {name}\n")
57
- log.write(f"Task: {task}\n")
58
- log.write(f"Interval: {interval}\n")
59
- log.write(f"Time: {datetime.now().isoformat()}\n")
60
- log.write(f"{'='*60}\n\n")
61
55
  log.flush()
62
56
 
63
57
  # Start process as daemon
@@ -95,16 +89,15 @@ class DaemonManager:
95
89
  Returns:
96
90
  Process ID
97
91
  """
98
- # Build command - use praisonai CLI to run scheduler in foreground
92
+ # Build command - use CLI without --daemon flag (original working approach)
99
93
  command = [
100
94
  sys.executable,
101
95
  "-m",
102
96
  "praisonai.cli.main",
103
97
  "schedule",
104
- f'"{task}"', # Quote the task
98
+ task,
105
99
  "--interval", interval,
106
- "--max-retries", str(max_retries),
107
- "--verbose" # Enable verbose to see output
100
+ "--max-retries", str(max_retries)
108
101
  ]
109
102
 
110
103
  if timeout:
@@ -0,0 +1 @@
1
+ __version__ = "2.3.72"
@@ -1 +0,0 @@
1
- __version__ = "2.3.70"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes