code-puppy 0.0.173__tar.gz → 0.0.175__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 (132) hide show
  1. {code_puppy-0.0.173 → code_puppy-0.0.175}/PKG-INFO +2 -2
  2. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/__init__.py +4 -6
  3. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/agent_manager.py +22 -189
  4. code_puppy-0.0.175/code_puppy/agents/base_agent.py +920 -0
  5. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/command_handler.py +40 -41
  6. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/start_all_command.py +3 -6
  7. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/start_command.py +0 -5
  8. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/stop_all_command.py +3 -6
  9. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/stop_command.py +2 -6
  10. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/model_picker_completion.py +2 -2
  11. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/prompt_toolkit_completion.py +2 -2
  12. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/config.py +2 -2
  13. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/http_utils.py +4 -7
  14. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/main.py +12 -49
  15. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/summarization_agent.py +2 -2
  16. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/agent_tools.py +5 -4
  17. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/vqa_agent.py +1 -3
  18. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/app.py +48 -77
  19. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/screens/settings.py +2 -2
  20. {code_puppy-0.0.173 → code_puppy-0.0.175}/pyproject.toml +2 -2
  21. code_puppy-0.0.173/code_puppy/agent.py +0 -239
  22. code_puppy-0.0.173/code_puppy/agents/agent_orchestrator.json +0 -26
  23. code_puppy-0.0.173/code_puppy/agents/base_agent.py +0 -512
  24. code_puppy-0.0.173/code_puppy/agents/runtime_manager.py +0 -272
  25. code_puppy-0.0.173/code_puppy/command_line/meta_command_handler.py +0 -153
  26. code_puppy-0.0.173/code_puppy/message_history_processor.py +0 -408
  27. code_puppy-0.0.173/code_puppy/state_management.py +0 -58
  28. {code_puppy-0.0.173 → code_puppy-0.0.175}/.gitignore +0 -0
  29. {code_puppy-0.0.173 → code_puppy-0.0.175}/LICENSE +0 -0
  30. {code_puppy-0.0.173 → code_puppy-0.0.175}/README.md +0 -0
  31. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/__init__.py +0 -0
  32. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/__main__.py +0 -0
  33. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/agent_code_puppy.py +0 -0
  34. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/agent_creator_agent.py +0 -0
  35. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/agent_qa_kitten.py +0 -0
  36. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/json_agent.py +0 -0
  37. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/callbacks.py +0 -0
  38. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/__init__.py +0 -0
  39. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/file_path_completion.py +0 -0
  40. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/load_context_completion.py +0 -0
  41. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/__init__.py +0 -0
  42. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/add_command.py +0 -0
  43. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/base.py +0 -0
  44. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/handler.py +0 -0
  45. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/help_command.py +0 -0
  46. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/install_command.py +0 -0
  47. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/list_command.py +0 -0
  48. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/logs_command.py +0 -0
  49. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/remove_command.py +0 -0
  50. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/restart_command.py +0 -0
  51. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/search_command.py +0 -0
  52. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/status_command.py +0 -0
  53. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/test_command.py +0 -0
  54. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/utils.py +0 -0
  55. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/wizard_utils.py +0 -0
  56. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/motd.py +0 -0
  57. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/utils.py +0 -0
  58. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/__init__.py +0 -0
  59. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/async_lifecycle.py +0 -0
  60. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/blocking_startup.py +0 -0
  61. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/captured_stdio_server.py +0 -0
  62. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/circuit_breaker.py +0 -0
  63. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/config_wizard.py +0 -0
  64. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/dashboard.py +0 -0
  65. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/error_isolation.py +0 -0
  66. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/examples/retry_example.py +0 -0
  67. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/health_monitor.py +0 -0
  68. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/managed_server.py +0 -0
  69. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/manager.py +0 -0
  70. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/registry.py +0 -0
  71. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/retry_manager.py +0 -0
  72. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/server_registry_catalog.py +0 -0
  73. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/status_tracker.py +0 -0
  74. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/system_tools.py +0 -0
  75. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/__init__.py +0 -0
  76. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/message_queue.py +0 -0
  77. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/queue_console.py +0 -0
  78. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/renderers.py +0 -0
  79. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/spinner/__init__.py +0 -0
  80. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/spinner/console_spinner.py +0 -0
  81. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/spinner/spinner_base.py +0 -0
  82. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/spinner/textual_spinner.py +0 -0
  83. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/model_factory.py +0 -0
  84. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/models.json +0 -0
  85. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/plugins/__init__.py +0 -0
  86. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/reopenable_async_client.py +0 -0
  87. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/round_robin_model.py +0 -0
  88. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/status_display.py +0 -0
  89. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/__init__.py +0 -0
  90. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/__init__.py +0 -0
  91. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_control.py +0 -0
  92. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_interactions.py +0 -0
  93. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_locators.py +0 -0
  94. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_navigation.py +0 -0
  95. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_screenshot.py +0 -0
  96. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_scripts.py +0 -0
  97. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_workflows.py +0 -0
  98. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/camoufox_manager.py +0 -0
  99. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_control.py +0 -0
  100. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_interactions.py +0 -0
  101. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_locators.py +0 -0
  102. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_navigation.py +0 -0
  103. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_screenshot.py +0 -0
  104. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_scripts.py +0 -0
  105. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_workflows.py +0 -0
  106. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/camoufox_manager.py +0 -0
  107. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/command_runner.py +0 -0
  108. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/common.py +0 -0
  109. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/file_modifications.py +0 -0
  110. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/file_operations.py +0 -0
  111. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/tools_content.py +0 -0
  112. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/__init__.py +0 -0
  113. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/__init__.py +0 -0
  114. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/chat_view.py +0 -0
  115. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/command_history_modal.py +0 -0
  116. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/copy_button.py +0 -0
  117. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/custom_widgets.py +0 -0
  118. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/human_input_modal.py +0 -0
  119. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/input_area.py +0 -0
  120. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/sidebar.py +0 -0
  121. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/status_bar.py +0 -0
  122. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/messages.py +0 -0
  123. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/models/__init__.py +0 -0
  124. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/models/chat_message.py +0 -0
  125. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/models/command_history.py +0 -0
  126. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/models/enums.py +0 -0
  127. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/screens/__init__.py +0 -0
  128. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/screens/help.py +0 -0
  129. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/screens/mcp_install_wizard.py +0 -0
  130. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/screens/tools.py +0 -0
  131. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui_state.py +0 -0
  132. {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/version_checker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-puppy
3
- Version: 0.0.173
3
+ Version: 0.0.175
4
4
  Summary: Code generation agent
5
5
  Project-URL: repository, https://github.com/mpfaffenberger/code_puppy
6
6
  Project-URL: HomePage, https://github.com/mpfaffenberger/code_puppy
@@ -26,7 +26,7 @@ Requires-Dist: openai>=1.99.1
26
26
  Requires-Dist: pathspec>=0.11.0
27
27
  Requires-Dist: playwright>=1.40.0
28
28
  Requires-Dist: prompt-toolkit>=3.0.38
29
- Requires-Dist: pydantic-ai>=1.0.10
29
+ Requires-Dist: pydantic-ai<=0.8
30
30
  Requires-Dist: pydantic>=2.4.0
31
31
  Requires-Dist: pyjwt>=2.8.0
32
32
  Requires-Dist: pytest-cov>=6.1.1
@@ -6,20 +6,18 @@ configurations, each with their own system prompts and tool sets.
6
6
 
7
7
  from .agent_manager import (
8
8
  get_available_agents,
9
- get_current_agent_config,
9
+ get_current_agent,
10
10
  set_current_agent,
11
- load_agent_config,
11
+ load_agent,
12
12
  get_agent_descriptions,
13
- clear_agent_cache,
14
13
  refresh_agents,
15
14
  )
16
15
 
17
16
  __all__ = [
18
17
  "get_available_agents",
19
- "get_current_agent_config",
18
+ "get_current_agent",
20
19
  "set_current_agent",
21
- "load_agent_config",
20
+ "load_agent",
22
21
  "get_agent_descriptions",
23
- "clear_agent_cache",
24
22
  "refresh_agents",
25
23
  ]
@@ -6,16 +6,18 @@ import os
6
6
  import pkgutil
7
7
  import uuid
8
8
  from pathlib import Path
9
- from typing import Dict, Optional, Type, Union
9
+ from pydantic_ai.messages import ModelMessage
10
+ from typing import Dict, Optional, Type, Union, List
10
11
 
11
- from ..callbacks import on_agent_reload
12
- from ..messaging import emit_warning
13
- from .base_agent import BaseAgent
14
- from .json_agent import JSONAgent, discover_json_agents
12
+ from code_puppy.callbacks import on_agent_reload
13
+ from code_puppy.messaging import emit_warning
14
+ from code_puppy.agents.base_agent import BaseAgent
15
+ from code_puppy.agents.json_agent import JSONAgent, discover_json_agents
15
16
 
16
17
  # Registry of available agents (Python classes and JSON file paths)
17
18
  _AGENT_REGISTRY: Dict[str, Union[Type[BaseAgent], str]] = {}
18
- _CURRENT_AGENT_CONFIG: Optional[BaseAgent] = None
19
+ _AGENT_HISTORIES: Dict[str, List[ModelMessage]] = {}
20
+ _CURRENT_AGENT: Optional[BaseAgent] = None
19
21
 
20
22
  # Terminal session-based agent selection
21
23
  _SESSION_AGENTS_CACHE: dict[str, str] = {}
@@ -146,40 +148,6 @@ def _ensure_session_cache_loaded() -> None:
146
148
  _SESSION_FILE_LOADED = True
147
149
 
148
150
 
149
- # Persistent storage for agent message histories
150
- _AGENT_HISTORIES: Dict[str, Dict[str, any]] = {}
151
- # Structure: {agent_name: {"message_history": [...], "compacted_hashes": set(...)}}
152
-
153
-
154
- def _save_agent_history(agent_name: str, agent: BaseAgent) -> None:
155
- """Save an agent's message history to persistent storage.
156
-
157
- Args:
158
- agent_name: The name of the agent
159
- agent: The agent instance to save history from
160
- """
161
- global _AGENT_HISTORIES
162
- _AGENT_HISTORIES[agent_name] = {
163
- "message_history": agent.get_message_history().copy(),
164
- "compacted_hashes": agent.get_compacted_message_hashes().copy(),
165
- }
166
-
167
-
168
- def _restore_agent_history(agent_name: str, agent: BaseAgent) -> None:
169
- """Restore an agent's message history from persistent storage.
170
-
171
- Args:
172
- agent_name: The name of the agent
173
- agent: The agent instance to restore history to
174
- """
175
- global _AGENT_HISTORIES
176
- if agent_name in _AGENT_HISTORIES:
177
- stored_data = _AGENT_HISTORIES[agent_name]
178
- agent.set_message_history(stored_data["message_history"])
179
- # Restore compacted hashes
180
- for hash_val in stored_data["compacted_hashes"]:
181
- agent.add_compacted_message_hash(hash_val)
182
-
183
151
 
184
152
  def _discover_agents(message_group_id: Optional[str] = None):
185
153
  """Dynamically discover all agent classes and JSON agents."""
@@ -281,50 +249,47 @@ def set_current_agent(agent_name: str) -> bool:
281
249
  Returns:
282
250
  True if the agent was set successfully, False if agent not found.
283
251
  """
252
+ global _CURRENT_AGENT
253
+ curr_agent = get_current_agent()
254
+ if curr_agent != None:
255
+ _AGENT_HISTORIES[curr_agent.name] = curr_agent.get_message_history()
284
256
  # Generate a message group ID for agent switching
285
257
  message_group_id = str(uuid.uuid4())
286
258
  _discover_agents(message_group_id=message_group_id)
287
259
 
288
260
  # Save current agent's history before switching
289
- global _CURRENT_AGENT_CONFIG, _CURRENT_AGENT_NAME
290
- if _CURRENT_AGENT_CONFIG is not None:
291
- _save_agent_history(_CURRENT_AGENT_CONFIG.name, _CURRENT_AGENT_CONFIG)
292
261
 
293
262
  # Clear the cached config when switching agents
294
- _CURRENT_AGENT_CONFIG = None
295
- agent_obj = load_agent_config(agent_name)
296
-
297
- # Restore the agent's history if it exists
298
- _restore_agent_history(agent_name, agent_obj)
263
+ agent_obj = load_agent(agent_name)
264
+ _CURRENT_AGENT = agent_obj
299
265
 
300
266
  # Update session-based agent selection and persist to disk
301
267
  _ensure_session_cache_loaded()
302
268
  session_id = get_terminal_session_id()
303
269
  _SESSION_AGENTS_CACHE[session_id] = agent_name
304
270
  _save_session_data(_SESSION_AGENTS_CACHE)
305
-
271
+ if agent_obj.name in _AGENT_HISTORIES:
272
+ agent_obj.set_message_history(_AGENT_HISTORIES[agent_obj.name])
306
273
  on_agent_reload(agent_obj.id, agent_name)
307
274
  return True
308
275
 
309
276
 
310
- def get_current_agent_config() -> BaseAgent:
277
+ def get_current_agent() -> BaseAgent:
311
278
  """Get the current agent configuration.
312
279
 
313
280
  Returns:
314
281
  The current agent configuration instance.
315
282
  """
316
- global _CURRENT_AGENT_CONFIG
283
+ global _CURRENT_AGENT
317
284
 
318
- if _CURRENT_AGENT_CONFIG is None:
285
+ if _CURRENT_AGENT is None:
319
286
  agent_name = get_current_agent_name()
320
- _CURRENT_AGENT_CONFIG = load_agent_config(agent_name)
321
- # Restore the agent's history if it exists
322
- _restore_agent_history(agent_name, _CURRENT_AGENT_CONFIG)
287
+ _CURRENT_AGENT = load_agent(agent_name)
323
288
 
324
- return _CURRENT_AGENT_CONFIG
289
+ return _CURRENT_AGENT
325
290
 
326
291
 
327
- def load_agent_config(agent_name: str) -> BaseAgent:
292
+ def load_agent(agent_name: str) -> BaseAgent:
328
293
  """Load an agent configuration by name.
329
294
 
330
295
  Args:
@@ -380,26 +345,6 @@ def get_agent_descriptions() -> Dict[str, str]:
380
345
  return descriptions
381
346
 
382
347
 
383
- def clear_agent_cache():
384
- """Clear the cached agent configuration to force reload."""
385
- global _CURRENT_AGENT_CONFIG
386
- _CURRENT_AGENT_CONFIG = None
387
-
388
-
389
- def reset_to_default_agent():
390
- """Reset the current agent to the default (code-puppy) for this terminal session.
391
-
392
- This is useful for testing or when you want to start fresh.
393
- """
394
- global _CURRENT_AGENT_CONFIG
395
- _ensure_session_cache_loaded()
396
- session_id = get_terminal_session_id()
397
- if session_id in _SESSION_AGENTS_CACHE:
398
- del _SESSION_AGENTS_CACHE[session_id]
399
- _save_session_data(_SESSION_AGENTS_CACHE)
400
- _CURRENT_AGENT_CONFIG = None
401
-
402
-
403
348
  def refresh_agents():
404
349
  """Refresh the agent discovery to pick up newly created agents.
405
350
 
@@ -408,115 +353,3 @@ def refresh_agents():
408
353
  # Generate a message group ID for agent refreshing
409
354
  message_group_id = str(uuid.uuid4())
410
355
  _discover_agents(message_group_id=message_group_id)
411
-
412
-
413
- def clear_all_agent_histories():
414
- """Clear all agent message histories from persistent storage.
415
-
416
- This is useful for debugging or when you want a fresh start.
417
- """
418
- global _AGENT_HISTORIES
419
- _AGENT_HISTORIES.clear()
420
- # Also clear the current agent's history
421
- if _CURRENT_AGENT_CONFIG is not None:
422
- _CURRENT_AGENT_CONFIG.messages = []
423
-
424
-
425
- def cleanup_dead_terminal_sessions() -> int:
426
- """Clean up terminal sessions for processes that no longer exist.
427
-
428
- Returns:
429
- int: Number of dead sessions removed
430
- """
431
- _ensure_session_cache_loaded()
432
- original_count = len(_SESSION_AGENTS_CACHE)
433
- cleaned_cache = _cleanup_dead_sessions(_SESSION_AGENTS_CACHE)
434
-
435
- if len(cleaned_cache) != original_count:
436
- _SESSION_AGENTS_CACHE.clear()
437
- _SESSION_AGENTS_CACHE.update(cleaned_cache)
438
- _save_session_data(_SESSION_AGENTS_CACHE)
439
-
440
- return original_count - len(cleaned_cache)
441
-
442
-
443
- # Agent-aware message history functions
444
- def get_current_agent_message_history():
445
- """Get the message history for the currently active agent.
446
-
447
- Returns:
448
- List of messages from the current agent's conversation history.
449
- """
450
- current_agent = get_current_agent_config()
451
- return current_agent.get_message_history()
452
-
453
-
454
- def set_current_agent_message_history(history):
455
- """Set the message history for the currently active agent.
456
-
457
- Args:
458
- history: List of messages to set as the current agent's conversation history.
459
- """
460
- current_agent = get_current_agent_config()
461
- current_agent.set_message_history(history)
462
- # Also update persistent storage
463
- _save_agent_history(current_agent.name, current_agent)
464
-
465
-
466
- def clear_current_agent_message_history():
467
- """Clear the message history for the currently active agent."""
468
- current_agent = get_current_agent_config()
469
- current_agent.clear_message_history()
470
- # Also clear from persistent storage
471
- global _AGENT_HISTORIES
472
- if current_agent.name in _AGENT_HISTORIES:
473
- _AGENT_HISTORIES[current_agent.name] = {
474
- "message_history": [],
475
- "compacted_hashes": set(),
476
- }
477
-
478
-
479
- def append_to_current_agent_message_history(message):
480
- """Append a message to the currently active agent's history.
481
-
482
- Args:
483
- message: Message to append to the current agent's conversation history.
484
- """
485
- current_agent = get_current_agent_config()
486
- current_agent.append_to_message_history(message)
487
- # Also update persistent storage
488
- _save_agent_history(current_agent.name, current_agent)
489
-
490
-
491
- def extend_current_agent_message_history(history):
492
- """Extend the currently active agent's message history with multiple messages.
493
-
494
- Args:
495
- history: List of messages to append to the current agent's conversation history.
496
- """
497
- current_agent = get_current_agent_config()
498
- current_agent.extend_message_history(history)
499
- # Also update persistent storage
500
- _save_agent_history(current_agent.name, current_agent)
501
-
502
-
503
- def get_current_agent_compacted_message_hashes():
504
- """Get the set of compacted message hashes for the currently active agent.
505
-
506
- Returns:
507
- Set of hashes for messages that have been compacted/summarized.
508
- """
509
- current_agent = get_current_agent_config()
510
- return current_agent.get_compacted_message_hashes()
511
-
512
-
513
- def add_current_agent_compacted_message_hash(message_hash: str):
514
- """Add a message hash to the current agent's set of compacted message hashes.
515
-
516
- Args:
517
- message_hash: Hash of a message that has been compacted/summarized.
518
- """
519
- current_agent = get_current_agent_config()
520
- current_agent.add_compacted_message_hash(message_hash)
521
- # Also update persistent storage
522
- _save_agent_history(current_agent.name, current_agent)