tapps-agents 3.5.38__py3-none-any.whl → 3.5.39__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.
@@ -0,0 +1,92 @@
1
+ """
2
+ Cleanup Agent command handlers
3
+ """
4
+ import asyncio
5
+
6
+ from ...agents.cleanup.agent import CleanupAgent
7
+ from ..base import normalize_command
8
+ from ..feedback import get_feedback
9
+ from ..help.static_help import get_static_help
10
+ from ..utils.agent_lifecycle import safe_close_agent_sync
11
+ from .common import check_result_error
12
+
13
+
14
+ def handle_cleanup_agent_command(args: object) -> None:
15
+ """Handle cleanup-agent commands."""
16
+ feedback = get_feedback()
17
+ command = normalize_command(getattr(args, "command", None))
18
+ output_format = getattr(args, "format", "json")
19
+ feedback.format_type = output_format
20
+
21
+ # Help commands first - no activation needed
22
+ if command == "help" or command is None:
23
+ help_text = get_static_help("cleanup-agent")
24
+ feedback.output_result(help_text)
25
+ return
26
+
27
+ # Cleanup agent runs offline (no network needed for file operations)
28
+ offline_mode = True
29
+
30
+ # Create and activate agent
31
+ cleanup = CleanupAgent()
32
+ try:
33
+ asyncio.run(cleanup.activate(offline_mode=offline_mode))
34
+
35
+ if command == "analyze":
36
+ result = asyncio.run(
37
+ cleanup.run(
38
+ "analyze",
39
+ path=getattr(args, "path", None),
40
+ pattern=getattr(args, "pattern", "*.md"),
41
+ output=getattr(args, "output", None),
42
+ )
43
+ )
44
+ elif command == "plan":
45
+ result = asyncio.run(
46
+ cleanup.run(
47
+ "plan",
48
+ analysis_file=getattr(args, "analysis_file", None),
49
+ path=getattr(args, "path", None),
50
+ pattern=getattr(args, "pattern", "*.md"),
51
+ output=getattr(args, "output", None),
52
+ )
53
+ )
54
+ elif command == "execute":
55
+ # Handle dry-run flag (--no-dry-run disables dry-run)
56
+ dry_run = not getattr(args, "no_dry_run", False)
57
+ backup = not getattr(args, "no_backup", False)
58
+
59
+ result = asyncio.run(
60
+ cleanup.run(
61
+ "execute",
62
+ plan_file=getattr(args, "plan_file", None),
63
+ path=getattr(args, "path", None),
64
+ pattern=getattr(args, "pattern", "*.md"),
65
+ dry_run=dry_run,
66
+ backup=backup,
67
+ )
68
+ )
69
+ elif command == "run":
70
+ # Handle dry-run flag (--no-dry-run disables dry-run)
71
+ dry_run = not getattr(args, "no_dry_run", False)
72
+ backup = not getattr(args, "no_backup", False)
73
+
74
+ result = asyncio.run(
75
+ cleanup.run(
76
+ "run",
77
+ path=getattr(args, "path", None),
78
+ pattern=getattr(args, "pattern", "*.md"),
79
+ dry_run=dry_run,
80
+ backup=backup,
81
+ )
82
+ )
83
+ else:
84
+ # Invalid command - show help
85
+ help_text = get_static_help("cleanup-agent")
86
+ feedback.output_result(help_text)
87
+ return
88
+
89
+ check_result_error(result)
90
+ feedback.output_result(result, message="Cleanup operation completed successfully")
91
+ finally:
92
+ safe_close_agent_sync(cleanup)