code-puppy 0.0.363__py3-none-any.whl → 0.0.364__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.
- code_puppy/agents/agent_manager.py +18 -0
- code_puppy/command_line/agent_menu.py +49 -11
- code_puppy/config.py +31 -0
- code_puppy/tools/agent_tools.py +3 -3
- code_puppy/tools/browser/__init__.py +1 -1
- code_puppy/tools/browser/browser_control.py +1 -1
- code_puppy/tools/browser/browser_interactions.py +1 -1
- code_puppy/tools/browser/browser_locators.py +1 -1
- code_puppy/tools/browser/{camoufox_manager.py → browser_manager.py} +29 -110
- code_puppy/tools/browser/browser_navigation.py +1 -1
- code_puppy/tools/browser/browser_screenshot.py +1 -1
- code_puppy/tools/browser/browser_scripts.py +1 -1
- {code_puppy-0.0.363.dist-info → code_puppy-0.0.364.dist-info}/METADATA +5 -6
- {code_puppy-0.0.363.dist-info → code_puppy-0.0.364.dist-info}/RECORD +19 -19
- {code_puppy-0.0.363.data → code_puppy-0.0.364.data}/data/code_puppy/models.json +0 -0
- {code_puppy-0.0.363.data → code_puppy-0.0.364.data}/data/code_puppy/models_dev_api.json +0 -0
- {code_puppy-0.0.363.dist-info → code_puppy-0.0.364.dist-info}/WHEEL +0 -0
- {code_puppy-0.0.363.dist-info → code_puppy-0.0.364.dist-info}/entry_points.txt +0 -0
- {code_puppy-0.0.363.dist-info → code_puppy-0.0.364.dist-info}/licenses/LICENSE +0 -0
|
@@ -295,12 +295,21 @@ def get_available_agents() -> Dict[str, str]:
|
|
|
295
295
|
Returns:
|
|
296
296
|
Dict mapping agent names to display names.
|
|
297
297
|
"""
|
|
298
|
+
from ..config import PACK_AGENT_NAMES, get_pack_agents_enabled
|
|
299
|
+
|
|
298
300
|
# Generate a message group ID for this operation
|
|
299
301
|
message_group_id = str(uuid.uuid4())
|
|
300
302
|
_discover_agents(message_group_id=message_group_id)
|
|
301
303
|
|
|
304
|
+
# Check if pack agents are enabled
|
|
305
|
+
pack_agents_enabled = get_pack_agents_enabled()
|
|
306
|
+
|
|
302
307
|
agents = {}
|
|
303
308
|
for name, agent_ref in _AGENT_REGISTRY.items():
|
|
309
|
+
# Filter out pack agents if disabled
|
|
310
|
+
if not pack_agents_enabled and name in PACK_AGENT_NAMES:
|
|
311
|
+
continue
|
|
312
|
+
|
|
304
313
|
try:
|
|
305
314
|
if isinstance(agent_ref, str): # JSON agent (file path)
|
|
306
315
|
agent_instance = JSONAgent(agent_ref)
|
|
@@ -423,12 +432,21 @@ def get_agent_descriptions() -> Dict[str, str]:
|
|
|
423
432
|
Returns:
|
|
424
433
|
Dict mapping agent names to their descriptions.
|
|
425
434
|
"""
|
|
435
|
+
from ..config import PACK_AGENT_NAMES, get_pack_agents_enabled
|
|
436
|
+
|
|
426
437
|
# Generate a message group ID for this operation
|
|
427
438
|
message_group_id = str(uuid.uuid4())
|
|
428
439
|
_discover_agents(message_group_id=message_group_id)
|
|
429
440
|
|
|
441
|
+
# Check if pack agents are enabled
|
|
442
|
+
pack_agents_enabled = get_pack_agents_enabled()
|
|
443
|
+
|
|
430
444
|
descriptions = {}
|
|
431
445
|
for name, agent_ref in _AGENT_REGISTRY.items():
|
|
446
|
+
# Filter out pack agents if disabled
|
|
447
|
+
if not pack_agents_enabled and name in PACK_AGENT_NAMES:
|
|
448
|
+
continue
|
|
449
|
+
|
|
432
450
|
try:
|
|
433
451
|
if isinstance(agent_ref, str): # JSON agent (file path)
|
|
434
452
|
agent_instance = JSONAgent(agent_ref)
|
|
@@ -27,26 +27,64 @@ PAGE_SIZE = 10 # Agents per page
|
|
|
27
27
|
|
|
28
28
|
def _sanitize_display_text(text: str) -> str:
|
|
29
29
|
"""Remove or replace characters that cause terminal rendering issues.
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
Args:
|
|
32
32
|
text: Text that may contain emojis or wide characters
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
Returns:
|
|
35
35
|
Sanitized text safe for prompt_toolkit rendering
|
|
36
36
|
"""
|
|
37
37
|
# Keep only characters that render cleanly in terminals
|
|
38
|
+
# Be aggressive about stripping anything that could cause width issues
|
|
38
39
|
result = []
|
|
39
40
|
for char in text:
|
|
40
41
|
# Get unicode category
|
|
41
42
|
cat = unicodedata.category(char)
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
|
|
43
|
+
# Categories to KEEP:
|
|
44
|
+
# - L* (Letters): Lu, Ll, Lt, Lm, Lo
|
|
45
|
+
# - N* (Numbers): Nd, Nl, No
|
|
46
|
+
# - P* (Punctuation): Pc, Pd, Ps, Pe, Pi, Pf, Po
|
|
47
|
+
# - Zs (Space separator)
|
|
48
|
+
# - Sm (Math symbols like +, -, =)
|
|
49
|
+
# - Sc (Currency symbols like $, €)
|
|
50
|
+
# - Sk (Modifier symbols)
|
|
51
|
+
#
|
|
52
|
+
# Categories to SKIP (cause rendering issues):
|
|
53
|
+
# - So (Symbol, other) - emojis
|
|
54
|
+
# - Cf (Format) - ZWJ, etc.
|
|
55
|
+
# - Mn (Mark, nonspacing) - combining characters
|
|
56
|
+
# - Mc (Mark, spacing combining)
|
|
57
|
+
# - Me (Mark, enclosing)
|
|
58
|
+
# - Cn (Not assigned)
|
|
59
|
+
# - Co (Private use)
|
|
60
|
+
# - Cs (Surrogate)
|
|
61
|
+
safe_categories = (
|
|
62
|
+
"Lu",
|
|
63
|
+
"Ll",
|
|
64
|
+
"Lt",
|
|
65
|
+
"Lm",
|
|
66
|
+
"Lo", # Letters
|
|
67
|
+
"Nd",
|
|
68
|
+
"Nl",
|
|
69
|
+
"No", # Numbers
|
|
70
|
+
"Pc",
|
|
71
|
+
"Pd",
|
|
72
|
+
"Ps",
|
|
73
|
+
"Pe",
|
|
74
|
+
"Pi",
|
|
75
|
+
"Pf",
|
|
76
|
+
"Po", # Punctuation
|
|
77
|
+
"Zs", # Space
|
|
78
|
+
"Sm",
|
|
79
|
+
"Sc",
|
|
80
|
+
"Sk", # Safe symbols (math, currency, modifier)
|
|
81
|
+
)
|
|
82
|
+
if cat in safe_categories:
|
|
45
83
|
result.append(char)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
84
|
+
|
|
85
|
+
# Clean up any double spaces left behind and strip
|
|
86
|
+
cleaned = " ".join("".join(result).split())
|
|
87
|
+
return cleaned
|
|
50
88
|
|
|
51
89
|
|
|
52
90
|
def _get_agent_entries() -> List[Tuple[str, str, str]]:
|
|
@@ -103,7 +141,7 @@ def _render_menu_panel(
|
|
|
103
141
|
name, display_name, _ = entries[i]
|
|
104
142
|
is_selected = i == selected_idx
|
|
105
143
|
is_current = name == current_agent_name
|
|
106
|
-
|
|
144
|
+
|
|
107
145
|
# Sanitize display name to avoid emoji rendering issues
|
|
108
146
|
safe_display_name = _sanitize_display_text(display_name)
|
|
109
147
|
|
|
@@ -160,7 +198,7 @@ def _render_preview_panel(
|
|
|
160
198
|
|
|
161
199
|
name, display_name, description = entry
|
|
162
200
|
is_current = name == current_agent_name
|
|
163
|
-
|
|
201
|
+
|
|
164
202
|
# Sanitize text to avoid emoji rendering issues
|
|
165
203
|
safe_display_name = _sanitize_display_text(display_name)
|
|
166
204
|
safe_description = _sanitize_display_text(description)
|
code_puppy/config.py
CHANGED
|
@@ -88,6 +88,35 @@ def get_subagent_verbose() -> bool:
|
|
|
88
88
|
return str(cfg_val).strip().lower() in {"1", "true", "yes", "on"}
|
|
89
89
|
|
|
90
90
|
|
|
91
|
+
# Pack agents - the specialized sub-agents coordinated by Pack Leader
|
|
92
|
+
PACK_AGENT_NAMES = frozenset(
|
|
93
|
+
[
|
|
94
|
+
"pack-leader",
|
|
95
|
+
"bloodhound",
|
|
96
|
+
"husky",
|
|
97
|
+
"shepherd",
|
|
98
|
+
"terrier",
|
|
99
|
+
"watchdog",
|
|
100
|
+
"retriever",
|
|
101
|
+
]
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def get_pack_agents_enabled() -> bool:
|
|
106
|
+
"""Return True if pack agents are enabled (default False).
|
|
107
|
+
|
|
108
|
+
When False (default), pack agents (pack-leader, bloodhound, husky, shepherd,
|
|
109
|
+
terrier, watchdog, retriever) are hidden from `list_agents` tool and `/agents`
|
|
110
|
+
command. They cannot be invoked by other agents or selected by users.
|
|
111
|
+
|
|
112
|
+
When True, pack agents are available for use.
|
|
113
|
+
"""
|
|
114
|
+
cfg_val = get_value("enable_pack_agents")
|
|
115
|
+
if cfg_val is None:
|
|
116
|
+
return False
|
|
117
|
+
return str(cfg_val).strip().lower() in {"1", "true", "yes", "on"}
|
|
118
|
+
|
|
119
|
+
|
|
91
120
|
DEFAULT_SECTION = "puppy"
|
|
92
121
|
REQUIRED_KEYS = ["puppy_name", "owner_name"]
|
|
93
122
|
|
|
@@ -226,6 +255,8 @@ def get_config_keys():
|
|
|
226
255
|
]
|
|
227
256
|
# Add DBOS control key
|
|
228
257
|
default_keys.append("enable_dbos")
|
|
258
|
+
# Add pack agents control key
|
|
259
|
+
default_keys.append("enable_pack_agents")
|
|
229
260
|
# Add cancel agent key configuration
|
|
230
261
|
default_keys.append("cancel_agent_key")
|
|
231
262
|
# Add banner color keys
|
code_puppy/tools/agent_tools.py
CHANGED
|
@@ -443,9 +443,9 @@ def register_invoke_agent(agent):
|
|
|
443
443
|
|
|
444
444
|
terminal_session_token = set_terminal_session(f"terminal-{session_id}")
|
|
445
445
|
|
|
446
|
-
# Set browser session for
|
|
446
|
+
# Set browser session for browser tools (qa-kitten, etc.)
|
|
447
447
|
# This allows parallel agent invocations to each have their own browser
|
|
448
|
-
from code_puppy.tools.browser.
|
|
448
|
+
from code_puppy.tools.browser.browser_manager import (
|
|
449
449
|
set_browser_session,
|
|
450
450
|
)
|
|
451
451
|
|
|
@@ -665,7 +665,7 @@ def register_invoke_agent(agent):
|
|
|
665
665
|
# Reset terminal session context
|
|
666
666
|
_terminal_session_var.reset(terminal_session_token)
|
|
667
667
|
# Reset browser session context
|
|
668
|
-
from code_puppy.tools.browser.
|
|
668
|
+
from code_puppy.tools.browser.browser_manager import (
|
|
669
669
|
_browser_session_var,
|
|
670
670
|
)
|
|
671
671
|
|
|
@@ -7,7 +7,7 @@ from pydantic_ai import RunContext
|
|
|
7
7
|
from code_puppy.messaging import emit_error, emit_info, emit_success, emit_warning
|
|
8
8
|
from code_puppy.tools.common import generate_group_id
|
|
9
9
|
|
|
10
|
-
from .
|
|
10
|
+
from .browser_manager import get_session_browser_manager
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
async def initialize_browser(
|
|
@@ -7,7 +7,7 @@ from pydantic_ai import RunContext
|
|
|
7
7
|
from code_puppy.messaging import emit_error, emit_info, emit_success
|
|
8
8
|
from code_puppy.tools.common import generate_group_id
|
|
9
9
|
|
|
10
|
-
from .
|
|
10
|
+
from .browser_manager import get_session_browser_manager
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
async def click_element(
|
|
@@ -7,7 +7,7 @@ from pydantic_ai import RunContext
|
|
|
7
7
|
from code_puppy.messaging import emit_info, emit_success
|
|
8
8
|
from code_puppy.tools.common import generate_group_id
|
|
9
9
|
|
|
10
|
-
from .
|
|
10
|
+
from .browser_manager import get_session_browser_manager
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
async def find_by_role(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Playwright browser manager for browser automation.
|
|
2
2
|
|
|
3
3
|
Supports multiple simultaneous instances with unique profile directories.
|
|
4
4
|
"""
|
|
@@ -16,7 +16,7 @@ from code_puppy import config
|
|
|
16
16
|
from code_puppy.messaging import emit_info, emit_success, emit_warning
|
|
17
17
|
|
|
18
18
|
# Store active manager instances by session ID
|
|
19
|
-
_active_managers: dict[str, "
|
|
19
|
+
_active_managers: dict[str, "BrowserManager"] = {}
|
|
20
20
|
|
|
21
21
|
# Context variable for browser session - properly inherits through async tasks
|
|
22
22
|
# This allows parallel agent invocations to each have their own browser instance
|
|
@@ -49,28 +49,29 @@ def get_browser_session() -> Optional[str]:
|
|
|
49
49
|
return _browser_session_var.get()
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def get_session_browser_manager() -> "
|
|
53
|
-
"""Get the
|
|
52
|
+
def get_session_browser_manager() -> "BrowserManager":
|
|
53
|
+
"""Get the BrowserManager for the current context's session.
|
|
54
54
|
|
|
55
55
|
This is the preferred way to get a browser manager in tool functions,
|
|
56
56
|
as it automatically uses the correct session ID for the current
|
|
57
57
|
agent context.
|
|
58
58
|
|
|
59
59
|
Returns:
|
|
60
|
-
A
|
|
60
|
+
A BrowserManager instance for the current session.
|
|
61
61
|
"""
|
|
62
62
|
session_id = get_browser_session()
|
|
63
|
-
return
|
|
63
|
+
return get_browser_manager(session_id)
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
# Flag to track if cleanup has already run
|
|
67
67
|
_cleanup_done: bool = False
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
class
|
|
71
|
-
"""Browser manager for
|
|
70
|
+
class BrowserManager:
|
|
71
|
+
"""Browser manager for Playwright-based browser automation.
|
|
72
72
|
|
|
73
73
|
Supports multiple simultaneous instances, each with its own profile directory.
|
|
74
|
+
Uses Chromium by default for maximum compatibility.
|
|
74
75
|
"""
|
|
75
76
|
|
|
76
77
|
_browser: Optional[Browser] = None
|
|
@@ -90,12 +91,6 @@ class CamoufoxManager:
|
|
|
90
91
|
# Override with BROWSER_HEADLESS=false to see the browser
|
|
91
92
|
self.headless = os.getenv("BROWSER_HEADLESS", "true").lower() != "false"
|
|
92
93
|
self.homepage = "https://www.google.com"
|
|
93
|
-
# Browser type: "chromium" skips Camoufox entirely, "firefox"/"camoufox" uses Camoufox
|
|
94
|
-
self.browser_type = "chromium" # Default to Chromium for reliability
|
|
95
|
-
# Camoufox-specific settings
|
|
96
|
-
self.geoip = True # Enable GeoIP spoofing
|
|
97
|
-
self.block_webrtc = True # Block WebRTC for privacy
|
|
98
|
-
self.humanize = True # Add human-like behavior
|
|
99
94
|
|
|
100
95
|
# Unique profile directory per session for browser state
|
|
101
96
|
self.profile_dir = self._get_profile_directory()
|
|
@@ -104,82 +99,36 @@ class CamoufoxManager:
|
|
|
104
99
|
"""Get or create the profile directory for this session.
|
|
105
100
|
|
|
106
101
|
Each session gets its own profile directory under:
|
|
107
|
-
XDG_CACHE_HOME/code_puppy/
|
|
102
|
+
XDG_CACHE_HOME/code_puppy/browser_profiles/<session_id>/
|
|
108
103
|
|
|
109
104
|
This allows multiple instances to run simultaneously.
|
|
110
105
|
"""
|
|
111
106
|
cache_dir = Path(config.CACHE_DIR)
|
|
112
|
-
profiles_base = cache_dir / "
|
|
107
|
+
profiles_base = cache_dir / "browser_profiles"
|
|
113
108
|
profile_path = profiles_base / self.session_id
|
|
114
109
|
profile_path.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
115
110
|
return profile_path
|
|
116
111
|
|
|
117
112
|
async def async_initialize(self) -> None:
|
|
118
|
-
"""Initialize
|
|
113
|
+
"""Initialize Chromium browser via Playwright."""
|
|
119
114
|
if self._initialized:
|
|
120
115
|
return
|
|
121
116
|
|
|
122
117
|
try:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
# Only prefetch Camoufox if we're going to use it
|
|
127
|
-
if self.browser_type != "chromium":
|
|
128
|
-
await self._prefetch_camoufox()
|
|
129
|
-
|
|
130
|
-
await self._initialize_camoufox()
|
|
131
|
-
# emit_info(
|
|
132
|
-
# "[green]✅ Browser initialized successfully[/green]"
|
|
133
|
-
# ) # Removed to reduce console spam
|
|
118
|
+
emit_info(f"Initializing Chromium browser (session: {self.session_id})...")
|
|
119
|
+
await self._initialize_browser()
|
|
134
120
|
self._initialized = True
|
|
135
121
|
|
|
136
122
|
except Exception:
|
|
137
123
|
await self._cleanup()
|
|
138
124
|
raise
|
|
139
125
|
|
|
140
|
-
async def
|
|
141
|
-
"""
|
|
126
|
+
async def _initialize_browser(self) -> None:
|
|
127
|
+
"""Initialize Playwright Chromium browser with persistent context."""
|
|
128
|
+
from playwright.async_api import async_playwright
|
|
142
129
|
|
|
143
|
-
If browser_type is 'chromium', skips Camoufox and uses Playwright Chromium directly.
|
|
144
|
-
Otherwise, tries Camoufox first and falls back to Chromium on failure.
|
|
145
|
-
"""
|
|
146
130
|
emit_info(f"Using persistent profile: {self.profile_dir}")
|
|
147
131
|
|
|
148
|
-
# If chromium is explicitly requested, skip Camoufox entirely
|
|
149
|
-
if self.browser_type == "chromium":
|
|
150
|
-
await self._initialize_chromium()
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
# Lazy import camoufox to avoid triggering heavy optional deps at import time
|
|
154
|
-
try:
|
|
155
|
-
import camoufox
|
|
156
|
-
from camoufox.addons import DefaultAddons
|
|
157
|
-
|
|
158
|
-
camoufox_instance = camoufox.AsyncCamoufox(
|
|
159
|
-
headless=self.headless,
|
|
160
|
-
block_webrtc=self.block_webrtc,
|
|
161
|
-
humanize=self.humanize,
|
|
162
|
-
exclude_addons=list(DefaultAddons),
|
|
163
|
-
persistent_context=True,
|
|
164
|
-
user_data_dir=str(self.profile_dir),
|
|
165
|
-
addons=[],
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
self._browser = camoufox_instance.browser
|
|
169
|
-
if not self._initialized:
|
|
170
|
-
self._context = await camoufox_instance.start()
|
|
171
|
-
self._initialized = True
|
|
172
|
-
except Exception:
|
|
173
|
-
emit_warning(
|
|
174
|
-
"Camoufox not available. Falling back to Playwright (Chromium)."
|
|
175
|
-
)
|
|
176
|
-
await self._initialize_chromium()
|
|
177
|
-
|
|
178
|
-
async def _initialize_chromium(self) -> None:
|
|
179
|
-
"""Initialize Playwright Chromium browser."""
|
|
180
|
-
from playwright.async_api import async_playwright
|
|
181
|
-
|
|
182
|
-
emit_info("Initializing Chromium browser...")
|
|
183
132
|
pw = await async_playwright().start()
|
|
184
133
|
# Use persistent context directory for Chromium to preserve browser state
|
|
185
134
|
context = await pw.chromium.launch_persistent_context(
|
|
@@ -214,41 +163,6 @@ class CamoufoxManager:
|
|
|
214
163
|
await page.goto(url)
|
|
215
164
|
return page
|
|
216
165
|
|
|
217
|
-
async def _prefetch_camoufox(self) -> None:
|
|
218
|
-
"""Prefetch Camoufox binary and dependencies."""
|
|
219
|
-
emit_info("Ensuring Camoufox binary and dependencies are up-to-date...")
|
|
220
|
-
|
|
221
|
-
# Lazy import camoufox utilities to avoid side effects during module import
|
|
222
|
-
try:
|
|
223
|
-
from camoufox.exceptions import CamoufoxNotInstalled, UnsupportedVersion
|
|
224
|
-
from camoufox.locale import ALLOW_GEOIP, download_mmdb
|
|
225
|
-
from camoufox.pkgman import CamoufoxFetcher, camoufox_path
|
|
226
|
-
except Exception:
|
|
227
|
-
emit_warning(
|
|
228
|
-
"Camoufox no disponible. Omitiendo prefetch y preparándose para usar Playwright."
|
|
229
|
-
)
|
|
230
|
-
return
|
|
231
|
-
|
|
232
|
-
needs_install = False
|
|
233
|
-
try:
|
|
234
|
-
camoufox_path(download_if_missing=False)
|
|
235
|
-
emit_info("Using cached Camoufox installation")
|
|
236
|
-
except (CamoufoxNotInstalled, FileNotFoundError):
|
|
237
|
-
emit_info("Camoufox not found, installing fresh copy")
|
|
238
|
-
needs_install = True
|
|
239
|
-
except UnsupportedVersion:
|
|
240
|
-
emit_info("Camoufox update required, reinstalling")
|
|
241
|
-
needs_install = True
|
|
242
|
-
|
|
243
|
-
if needs_install:
|
|
244
|
-
CamoufoxFetcher().install()
|
|
245
|
-
|
|
246
|
-
# Fetch GeoIP database if enabled
|
|
247
|
-
if ALLOW_GEOIP:
|
|
248
|
-
download_mmdb()
|
|
249
|
-
|
|
250
|
-
emit_info("Camoufox dependencies ready")
|
|
251
|
-
|
|
252
166
|
async def close_page(self, page: Page) -> None:
|
|
253
167
|
"""Close a specific page."""
|
|
254
168
|
await page.close()
|
|
@@ -303,11 +217,11 @@ class CamoufoxManager:
|
|
|
303
217
|
async def close(self) -> None:
|
|
304
218
|
"""Close the browser and clean up resources."""
|
|
305
219
|
await self._cleanup()
|
|
306
|
-
emit_info(f"
|
|
220
|
+
emit_info(f"Browser closed (session: {self.session_id})")
|
|
307
221
|
|
|
308
222
|
|
|
309
|
-
def
|
|
310
|
-
"""Get or create a
|
|
223
|
+
def get_browser_manager(session_id: Optional[str] = None) -> BrowserManager:
|
|
224
|
+
"""Get or create a BrowserManager instance.
|
|
311
225
|
|
|
312
226
|
Args:
|
|
313
227
|
session_id: Optional session ID. If provided and a manager with this
|
|
@@ -315,19 +229,19 @@ def get_camoufox_manager(session_id: Optional[str] = None) -> CamoufoxManager:
|
|
|
315
229
|
If None, uses 'default' as the session ID.
|
|
316
230
|
|
|
317
231
|
Returns:
|
|
318
|
-
A
|
|
232
|
+
A BrowserManager instance.
|
|
319
233
|
|
|
320
234
|
Example:
|
|
321
235
|
# Default session (for single-agent use)
|
|
322
|
-
manager =
|
|
236
|
+
manager = get_browser_manager()
|
|
323
237
|
|
|
324
238
|
# Named session (for multi-agent use)
|
|
325
|
-
manager =
|
|
239
|
+
manager = get_browser_manager("qa-agent-1")
|
|
326
240
|
"""
|
|
327
241
|
session_id = session_id or "default"
|
|
328
242
|
|
|
329
243
|
if session_id not in _active_managers:
|
|
330
|
-
_active_managers[session_id] =
|
|
244
|
+
_active_managers[session_id] = BrowserManager(session_id)
|
|
331
245
|
|
|
332
246
|
return _active_managers[session_id]
|
|
333
247
|
|
|
@@ -395,3 +309,8 @@ def _sync_cleanup_browsers() -> None:
|
|
|
395
309
|
# Register the cleanup handler with atexit
|
|
396
310
|
# This ensures browsers are closed even if close_browser() isn't explicitly called
|
|
397
311
|
atexit.register(_sync_cleanup_browsers)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
# Backwards compatibility aliases
|
|
315
|
+
CamoufoxManager = BrowserManager
|
|
316
|
+
get_camoufox_manager = get_browser_manager
|
|
@@ -7,7 +7,7 @@ from pydantic_ai import RunContext
|
|
|
7
7
|
from code_puppy.messaging import emit_error, emit_info, emit_success
|
|
8
8
|
from code_puppy.tools.common import generate_group_id
|
|
9
9
|
|
|
10
|
-
from .
|
|
10
|
+
from .browser_manager import get_session_browser_manager
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
async def navigate_to_url(url: str) -> Dict[str, Any]:
|
|
@@ -15,7 +15,7 @@ from pydantic_ai import BinaryContent, RunContext, ToolReturn
|
|
|
15
15
|
from code_puppy.messaging import emit_error, emit_info, emit_success
|
|
16
16
|
from code_puppy.tools.common import generate_group_id
|
|
17
17
|
|
|
18
|
-
from .
|
|
18
|
+
from .browser_manager import get_session_browser_manager
|
|
19
19
|
|
|
20
20
|
_TEMP_SCREENSHOT_ROOT = Path(
|
|
21
21
|
mkdtemp(prefix="code_puppy_screenshots_", dir=gettempdir())
|
|
@@ -7,7 +7,7 @@ from pydantic_ai import RunContext
|
|
|
7
7
|
from code_puppy.messaging import emit_error, emit_info, emit_success
|
|
8
8
|
from code_puppy.tools.common import generate_group_id
|
|
9
9
|
|
|
10
|
-
from .
|
|
10
|
+
from .browser_manager import get_session_browser_manager
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
async def execute_javascript(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: code-puppy
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.364
|
|
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
|
|
@@ -15,27 +15,26 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
16
16
|
Classifier: Topic :: Software Development :: Code Generators
|
|
17
17
|
Requires-Python: <3.14,>=3.11
|
|
18
|
-
Requires-Dist: camoufox>=0.4.11
|
|
19
18
|
Requires-Dist: dbos>=2.5.0
|
|
20
19
|
Requires-Dist: fastapi>=0.109.0
|
|
20
|
+
Requires-Dist: google-genai>=1.20.0
|
|
21
21
|
Requires-Dist: httpx[http2]>=0.24.1
|
|
22
22
|
Requires-Dist: json-repair>=0.46.2
|
|
23
|
-
Requires-Dist:
|
|
23
|
+
Requires-Dist: mcp>=1.9.4
|
|
24
24
|
Requires-Dist: openai>=1.99.1
|
|
25
25
|
Requires-Dist: pillow>=10.0.0
|
|
26
26
|
Requires-Dist: playwright>=1.40.0
|
|
27
27
|
Requires-Dist: prompt-toolkit>=3.0.52
|
|
28
|
-
Requires-Dist: pydantic-ai==1.25.0
|
|
28
|
+
Requires-Dist: pydantic-ai-slim[anthropic,google,openai]==1.25.0
|
|
29
29
|
Requires-Dist: pydantic>=2.4.0
|
|
30
30
|
Requires-Dist: pyfiglet>=0.8.post1
|
|
31
|
-
Requires-Dist: pytest-cov>=6.1.1
|
|
32
31
|
Requires-Dist: python-dotenv>=1.0.0
|
|
33
32
|
Requires-Dist: rapidfuzz>=3.13.0
|
|
34
33
|
Requires-Dist: rich>=13.4.2
|
|
35
34
|
Requires-Dist: ripgrep==14.1.0
|
|
36
|
-
Requires-Dist: ruff>=0.11.11
|
|
37
35
|
Requires-Dist: tenacity>=8.2.0
|
|
38
36
|
Requires-Dist: termflow-md>=0.1.8
|
|
37
|
+
Requires-Dist: typer>=0.12.0
|
|
39
38
|
Requires-Dist: uvicorn[standard]>=0.27.0
|
|
40
39
|
Requires-Dist: websockets>=12.0
|
|
41
40
|
Description-Content-Type: text/markdown
|
|
@@ -4,7 +4,7 @@ code_puppy/callbacks.py,sha256=Pp0VyeXJBEtk-N_RSWr5pbveelovsdLUiJ4f11dzwGw,10775
|
|
|
4
4
|
code_puppy/chatgpt_codex_client.py,sha256=Om0ANB_kpHubhCwNzF9ENf8RvKBqs0IYzBLl_SNw0Vk,9833
|
|
5
5
|
code_puppy/claude_cache_client.py,sha256=Gl6um5ZaKpcnxOvoFSM8Lwm_Vu4-VyWz8Nli8DnRLa4,22508
|
|
6
6
|
code_puppy/cli_runner.py,sha256=w5CLKgQYYaT7My3Cga2StXYol-u6DBxNzzUuhhsfhsA,34952
|
|
7
|
-
code_puppy/config.py,sha256=
|
|
7
|
+
code_puppy/config.py,sha256=MmKSvpgyrykOE0mTRvcq6xt7vjVUSwm5wW9PzzadiOE,53342
|
|
8
8
|
code_puppy/error_logging.py,sha256=a80OILCUtJhexI6a9GM-r5LqIdjvSRzggfgPp2jv1X0,3297
|
|
9
9
|
code_puppy/gemini_code_assist.py,sha256=KGS7sO5OLc83nDF3xxS-QiU6vxW9vcm6hmzilu79Ef8,13867
|
|
10
10
|
code_puppy/http_utils.py,sha256=H3N5Qz2B1CcsGUYOycGWAqoNMr2P1NCVluKX3aRwRqI,10358
|
|
@@ -32,7 +32,7 @@ code_puppy/agents/agent_cpp_reviewer.py,sha256=lbaGU4aKSNBrxsYfN86BKOeKBgL8kS9sL
|
|
|
32
32
|
code_puppy/agents/agent_creator_agent.py,sha256=pYnDRCn8qWivAeu-GA-WYn_gZ67KT1I9ZyHbaNssIII,25027
|
|
33
33
|
code_puppy/agents/agent_golang_reviewer.py,sha256=VEAwiQW06occkfABVz9Y7wStQ8pFtX94DAvZdRSRuzs,9319
|
|
34
34
|
code_puppy/agents/agent_javascript_reviewer.py,sha256=ATSXl278kPU4F6hiYsMMGkGrrWDlJqPwaYwYGNuo9J0,9494
|
|
35
|
-
code_puppy/agents/agent_manager.py,sha256=
|
|
35
|
+
code_puppy/agents/agent_manager.py,sha256=i4s9RnKyMTB0e8yg3YhU7MMx_dtzr1s4lwY-tcsyyjc,15610
|
|
36
36
|
code_puppy/agents/agent_pack_leader.py,sha256=DrP5rnYZbqkOm4ClK_Q4-aehjqXXVlq1UFs1bu11zbA,15766
|
|
37
37
|
code_puppy/agents/agent_planning.py,sha256=LtFqQixrDUPudSvmhbntK-zRbDHn0lSi1xrKFVqCwDo,6902
|
|
38
38
|
code_puppy/agents/agent_python_programmer.py,sha256=R-7XoGIFJ58EY9LE9mWGcQQ8gSsMzi-1HD6wigJQPL8,6846
|
|
@@ -67,7 +67,7 @@ code_puppy/api/routers/sessions.py,sha256=GqYRT7IJYPpEdTseLF3FIpbvvD86lIqwwPswL3
|
|
|
67
67
|
code_puppy/api/templates/terminal.html,sha256=9alh6tTbLyXPDjBvkXw8nEWPXB-m_LIceGGRYpSLuyo,13125
|
|
68
68
|
code_puppy/command_line/__init__.py,sha256=y7WeRemfYppk8KVbCGeAIiTuiOszIURCDjOMZv_YRmU,45
|
|
69
69
|
code_puppy/command_line/add_model_menu.py,sha256=CpURhxPvUhLHLBV_uwH1ODfJ-WAcGklvlsjEf5Vfvg4,43255
|
|
70
|
-
code_puppy/command_line/agent_menu.py,sha256=
|
|
70
|
+
code_puppy/command_line/agent_menu.py,sha256=uItsjRXZNdgYbfNC3hWIuaf9k3jYYdRbVZgqVkmHW_M,11660
|
|
71
71
|
code_puppy/command_line/attachments.py,sha256=4Q5I2Es4j0ltnz5wjw2z0QXMsiMJvEfWRkPf_lJeITM,13093
|
|
72
72
|
code_puppy/command_line/autosave_menu.py,sha256=de7nOmFmEH6x5T7C95U8N8xgxxeF-l5lgaJzGJsF3ZY,19824
|
|
73
73
|
code_puppy/command_line/clipboard.py,sha256=oe9bfAX5RnT81FiYrDmhvHaePS1tAT-NFG1fSXubSD4,16869
|
|
@@ -186,7 +186,7 @@ code_puppy/plugins/shell_safety/register_callbacks.py,sha256=W3v664RR48Fdbbbltf_
|
|
|
186
186
|
code_puppy/prompts/antigravity_system_prompt.md,sha256=ZaTfRyY57ttROyZMmOBtqZQu1to7sdTNTv8_0fTgPNw,6807
|
|
187
187
|
code_puppy/prompts/codex_system_prompt.md,sha256=hEFTCziroLqZmqNle5kG34A8kvTteOWezCiVrAEKhE0,24400
|
|
188
188
|
code_puppy/tools/__init__.py,sha256=9bzVIjX9CAr2YTZkhD7IWFYt4KpnFRx6ge_Tqazugbs,7425
|
|
189
|
-
code_puppy/tools/agent_tools.py,sha256=
|
|
189
|
+
code_puppy/tools/agent_tools.py,sha256=Dw2yNWhHtLd0Skh2jWElHSwTX4VgV08xVjrV2cL7KlU,25506
|
|
190
190
|
code_puppy/tools/command_runner.py,sha256=Sresr_ykou_c2V1sKoNxqrqCQovKF5yDiQJ8r3E9lak,50995
|
|
191
191
|
code_puppy/tools/common.py,sha256=lVtF94cn6jtC5YKfitV7L3rk37Ts2gMoHLQrqDFD2E4,46411
|
|
192
192
|
code_puppy/tools/display.py,sha256=-ulDyq55178f8O_TAEmnxGoy_ZdFkbHBw-W4ul851GM,2675
|
|
@@ -194,23 +194,23 @@ code_puppy/tools/file_modifications.py,sha256=vz9n7R0AGDSdLUArZr_55yJLkyI30M8zre
|
|
|
194
194
|
code_puppy/tools/file_operations.py,sha256=CqhpuBnOFOcQCIYXOujskxq2VMLWYJhibYrH0YcPSfA,35692
|
|
195
195
|
code_puppy/tools/subagent_context.py,sha256=zsiKV3B3DxZ_Y5IHHhtE-SMFDg_jMrY7Hi6r5LH--IU,4781
|
|
196
196
|
code_puppy/tools/tools_content.py,sha256=bsBqW-ppd1XNAS_g50B3UHDQBWEALC1UneH6-afz1zo,2365
|
|
197
|
-
code_puppy/tools/browser/__init__.py,sha256=
|
|
198
|
-
code_puppy/tools/browser/browser_control.py,sha256=
|
|
199
|
-
code_puppy/tools/browser/browser_interactions.py,sha256=
|
|
200
|
-
code_puppy/tools/browser/browser_locators.py,sha256
|
|
201
|
-
code_puppy/tools/browser/
|
|
202
|
-
code_puppy/tools/browser/
|
|
203
|
-
code_puppy/tools/browser/
|
|
197
|
+
code_puppy/tools/browser/__init__.py,sha256=Mu6zvTQHdKcEh3ttwNgjiKtaKjVkNQ4ncpQ00mhjcE8,926
|
|
198
|
+
code_puppy/tools/browser/browser_control.py,sha256=qul611bbXteH3pBoN39AystbYr3ZXkCs9mbjobir5Io,8429
|
|
199
|
+
code_puppy/tools/browser/browser_interactions.py,sha256=toroY2hDVDaNN9g6UV-vJ5IA1htaf_Pk85Z7PXwpMm4,16774
|
|
200
|
+
code_puppy/tools/browser/browser_locators.py,sha256=--cYu5pi1nvVh673fFCV2GSOJ5XuAUHvyPpPJREOx7s,19176
|
|
201
|
+
code_puppy/tools/browser/browser_manager.py,sha256=1-aXGzlOhAqC9eeH1RY13jaJntKrhhH3IUm24CfHWC8,10444
|
|
202
|
+
code_puppy/tools/browser/browser_navigation.py,sha256=MbfIL6UNs79ImbCli1854_ftwqLke37jhwQzfcA0Zag,7415
|
|
203
|
+
code_puppy/tools/browser/browser_screenshot.py,sha256=YT35iJc9SfFI8PiIfskyehDFpk1YfJ1K6lFwrzRwkH8,6281
|
|
204
|
+
code_puppy/tools/browser/browser_scripts.py,sha256=swQLuD61mwE3uFghOZmSSJXggg5ZIPKHqKu-KvdY49Y,14778
|
|
204
205
|
code_puppy/tools/browser/browser_workflows.py,sha256=nitW42vCf0ieTX1gLabozTugNQ8phtoFzZbiAhw1V90,6491
|
|
205
|
-
code_puppy/tools/browser/camoufox_manager.py,sha256=WIr98SrGeC5jd6jX5tjhFR6A3janqV4tq9Mbznnlh44,13920
|
|
206
206
|
code_puppy/tools/browser/chromium_terminal_manager.py,sha256=w1thQ_ACb6oV45L93TSqPQD0o0cTh3FqT5I9zcOOWlM,8226
|
|
207
207
|
code_puppy/tools/browser/terminal_command_tools.py,sha256=9byOZku-dwvTtCl532xt7Lumed_jTn0sLvUe_X75XCQ,19068
|
|
208
208
|
code_puppy/tools/browser/terminal_screenshot_tools.py,sha256=J_21YO_495NvYgNFu9KQP6VYg2K_f8CtSdZuF94Yhnw,18448
|
|
209
209
|
code_puppy/tools/browser/terminal_tools.py,sha256=F5LjVH3udSCFHmqC3O1UJLoLozZFZsEdX42jOmkqkW0,17853
|
|
210
|
-
code_puppy-0.0.
|
|
211
|
-
code_puppy-0.0.
|
|
212
|
-
code_puppy-0.0.
|
|
213
|
-
code_puppy-0.0.
|
|
214
|
-
code_puppy-0.0.
|
|
215
|
-
code_puppy-0.0.
|
|
216
|
-
code_puppy-0.0.
|
|
210
|
+
code_puppy-0.0.364.data/data/code_puppy/models.json,sha256=FMQdE_yvP_8y0xxt3K918UkFL9cZMYAqW1SfXcQkU_k,3105
|
|
211
|
+
code_puppy-0.0.364.data/data/code_puppy/models_dev_api.json,sha256=wHjkj-IM_fx1oHki6-GqtOoCrRMR0ScK0f-Iz0UEcy8,548187
|
|
212
|
+
code_puppy-0.0.364.dist-info/METADATA,sha256=x9IyVsYQAIy-K7BTs-H-WmRfeiQVZdJB91cwtgN1D9g,27611
|
|
213
|
+
code_puppy-0.0.364.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
214
|
+
code_puppy-0.0.364.dist-info/entry_points.txt,sha256=Tp4eQC99WY3HOKd3sdvb22vZODRq0XkZVNpXOag_KdI,91
|
|
215
|
+
code_puppy-0.0.364.dist-info/licenses/LICENSE,sha256=31u8x0SPgdOq3izJX41kgFazWsM43zPEF9eskzqbJMY,1075
|
|
216
|
+
code_puppy-0.0.364.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|