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.
- {code_puppy-0.0.173 → code_puppy-0.0.175}/PKG-INFO +2 -2
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/__init__.py +4 -6
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/agent_manager.py +22 -189
- code_puppy-0.0.175/code_puppy/agents/base_agent.py +920 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/command_handler.py +40 -41
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/start_all_command.py +3 -6
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/start_command.py +0 -5
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/stop_all_command.py +3 -6
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/stop_command.py +2 -6
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/model_picker_completion.py +2 -2
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/prompt_toolkit_completion.py +2 -2
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/config.py +2 -2
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/http_utils.py +4 -7
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/main.py +12 -49
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/summarization_agent.py +2 -2
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/agent_tools.py +5 -4
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/vqa_agent.py +1 -3
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/app.py +48 -77
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/screens/settings.py +2 -2
- {code_puppy-0.0.173 → code_puppy-0.0.175}/pyproject.toml +2 -2
- code_puppy-0.0.173/code_puppy/agent.py +0 -239
- code_puppy-0.0.173/code_puppy/agents/agent_orchestrator.json +0 -26
- code_puppy-0.0.173/code_puppy/agents/base_agent.py +0 -512
- code_puppy-0.0.173/code_puppy/agents/runtime_manager.py +0 -272
- code_puppy-0.0.173/code_puppy/command_line/meta_command_handler.py +0 -153
- code_puppy-0.0.173/code_puppy/message_history_processor.py +0 -408
- code_puppy-0.0.173/code_puppy/state_management.py +0 -58
- {code_puppy-0.0.173 → code_puppy-0.0.175}/.gitignore +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/LICENSE +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/README.md +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/__main__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/agent_code_puppy.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/agent_creator_agent.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/agent_qa_kitten.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/agents/json_agent.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/callbacks.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/file_path_completion.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/load_context_completion.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/add_command.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/base.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/handler.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/help_command.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/install_command.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/list_command.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/logs_command.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/remove_command.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/restart_command.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/search_command.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/status_command.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/test_command.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/utils.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/mcp/wizard_utils.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/motd.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/command_line/utils.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/async_lifecycle.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/blocking_startup.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/captured_stdio_server.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/circuit_breaker.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/config_wizard.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/dashboard.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/error_isolation.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/examples/retry_example.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/health_monitor.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/managed_server.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/manager.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/registry.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/retry_manager.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/server_registry_catalog.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/status_tracker.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/mcp_/system_tools.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/message_queue.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/queue_console.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/renderers.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/spinner/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/spinner/console_spinner.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/spinner/spinner_base.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/messaging/spinner/textual_spinner.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/model_factory.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/models.json +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/plugins/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/reopenable_async_client.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/round_robin_model.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/status_display.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_control.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_interactions.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_locators.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_navigation.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_screenshot.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_scripts.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/browser_workflows.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser/camoufox_manager.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_control.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_interactions.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_locators.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_navigation.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_screenshot.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_scripts.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/browser_workflows.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/camoufox_manager.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/command_runner.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/common.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/file_modifications.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/file_operations.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tools/tools_content.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/chat_view.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/command_history_modal.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/copy_button.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/custom_widgets.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/human_input_modal.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/input_area.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/sidebar.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/components/status_bar.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/messages.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/models/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/models/chat_message.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/models/command_history.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/models/enums.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/screens/__init__.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/screens/help.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/screens/mcp_install_wizard.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui/screens/tools.py +0 -0
- {code_puppy-0.0.173 → code_puppy-0.0.175}/code_puppy/tui_state.py +0 -0
- {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.
|
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
|
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
|
-
|
9
|
+
get_current_agent,
|
10
10
|
set_current_agent,
|
11
|
-
|
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
|
-
"
|
18
|
+
"get_current_agent",
|
20
19
|
"set_current_agent",
|
21
|
-
"
|
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
|
9
|
+
from pydantic_ai.messages import ModelMessage
|
10
|
+
from typing import Dict, Optional, Type, Union, List
|
10
11
|
|
11
|
-
from
|
12
|
-
from
|
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
|
-
|
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
|
-
|
295
|
-
|
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
|
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
|
283
|
+
global _CURRENT_AGENT
|
317
284
|
|
318
|
-
if
|
285
|
+
if _CURRENT_AGENT is None:
|
319
286
|
agent_name = get_current_agent_name()
|
320
|
-
|
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
|
289
|
+
return _CURRENT_AGENT
|
325
290
|
|
326
291
|
|
327
|
-
def
|
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)
|