newcode 0.1.1__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.
Files changed (289) hide show
  1. code_puppy/__init__.py +10 -0
  2. code_puppy/__main__.py +10 -0
  3. code_puppy/agents/__init__.py +31 -0
  4. code_puppy/agents/agent_c_reviewer.py +155 -0
  5. code_puppy/agents/agent_code_puppy.py +147 -0
  6. code_puppy/agents/agent_code_reviewer.py +90 -0
  7. code_puppy/agents/agent_cpp_reviewer.py +132 -0
  8. code_puppy/agents/agent_creator_agent.py +630 -0
  9. code_puppy/agents/agent_golang_reviewer.py +151 -0
  10. code_puppy/agents/agent_helios.py +122 -0
  11. code_puppy/agents/agent_javascript_reviewer.py +160 -0
  12. code_puppy/agents/agent_manager.py +742 -0
  13. code_puppy/agents/agent_pack_leader.py +380 -0
  14. code_puppy/agents/agent_planning.py +165 -0
  15. code_puppy/agents/agent_python_programmer.py +167 -0
  16. code_puppy/agents/agent_python_reviewer.py +90 -0
  17. code_puppy/agents/agent_qa_expert.py +163 -0
  18. code_puppy/agents/agent_qa_kitten.py +208 -0
  19. code_puppy/agents/agent_scheduler.py +121 -0
  20. code_puppy/agents/agent_security_auditor.py +181 -0
  21. code_puppy/agents/agent_terminal_qa.py +323 -0
  22. code_puppy/agents/agent_typescript_reviewer.py +166 -0
  23. code_puppy/agents/base_agent.py +2145 -0
  24. code_puppy/agents/event_stream_handler.py +348 -0
  25. code_puppy/agents/json_agent.py +202 -0
  26. code_puppy/agents/pack/__init__.py +34 -0
  27. code_puppy/agents/pack/bloodhound.py +296 -0
  28. code_puppy/agents/pack/husky.py +307 -0
  29. code_puppy/agents/pack/retriever.py +380 -0
  30. code_puppy/agents/pack/shepherd.py +327 -0
  31. code_puppy/agents/pack/terrier.py +281 -0
  32. code_puppy/agents/pack/watchdog.py +357 -0
  33. code_puppy/agents/prompt_reviewer.py +145 -0
  34. code_puppy/agents/subagent_stream_handler.py +276 -0
  35. code_puppy/api/__init__.py +13 -0
  36. code_puppy/api/app.py +169 -0
  37. code_puppy/api/main.py +21 -0
  38. code_puppy/api/pty_manager.py +453 -0
  39. code_puppy/api/routers/__init__.py +12 -0
  40. code_puppy/api/routers/agents.py +36 -0
  41. code_puppy/api/routers/commands.py +217 -0
  42. code_puppy/api/routers/config.py +75 -0
  43. code_puppy/api/routers/sessions.py +234 -0
  44. code_puppy/api/templates/terminal.html +361 -0
  45. code_puppy/api/websocket.py +154 -0
  46. code_puppy/callbacks.py +674 -0
  47. code_puppy/chatgpt_codex_client.py +338 -0
  48. code_puppy/claude_cache_client.py +664 -0
  49. code_puppy/cli_runner.py +1038 -0
  50. code_puppy/command_line/__init__.py +1 -0
  51. code_puppy/command_line/add_model_menu.py +1092 -0
  52. code_puppy/command_line/agent_menu.py +662 -0
  53. code_puppy/command_line/attachments.py +395 -0
  54. code_puppy/command_line/autosave_menu.py +704 -0
  55. code_puppy/command_line/clipboard.py +527 -0
  56. code_puppy/command_line/colors_menu.py +526 -0
  57. code_puppy/command_line/command_handler.py +283 -0
  58. code_puppy/command_line/command_registry.py +150 -0
  59. code_puppy/command_line/config_commands.py +719 -0
  60. code_puppy/command_line/core_commands.py +853 -0
  61. code_puppy/command_line/diff_menu.py +865 -0
  62. code_puppy/command_line/file_path_completion.py +73 -0
  63. code_puppy/command_line/load_context_completion.py +52 -0
  64. code_puppy/command_line/mcp/__init__.py +10 -0
  65. code_puppy/command_line/mcp/base.py +32 -0
  66. code_puppy/command_line/mcp/catalog_server_installer.py +175 -0
  67. code_puppy/command_line/mcp/custom_server_form.py +688 -0
  68. code_puppy/command_line/mcp/custom_server_installer.py +195 -0
  69. code_puppy/command_line/mcp/edit_command.py +148 -0
  70. code_puppy/command_line/mcp/handler.py +138 -0
  71. code_puppy/command_line/mcp/help_command.py +147 -0
  72. code_puppy/command_line/mcp/install_command.py +214 -0
  73. code_puppy/command_line/mcp/install_menu.py +705 -0
  74. code_puppy/command_line/mcp/list_command.py +94 -0
  75. code_puppy/command_line/mcp/logs_command.py +235 -0
  76. code_puppy/command_line/mcp/remove_command.py +82 -0
  77. code_puppy/command_line/mcp/restart_command.py +100 -0
  78. code_puppy/command_line/mcp/search_command.py +123 -0
  79. code_puppy/command_line/mcp/start_all_command.py +135 -0
  80. code_puppy/command_line/mcp/start_command.py +117 -0
  81. code_puppy/command_line/mcp/status_command.py +184 -0
  82. code_puppy/command_line/mcp/stop_all_command.py +112 -0
  83. code_puppy/command_line/mcp/stop_command.py +80 -0
  84. code_puppy/command_line/mcp/test_command.py +107 -0
  85. code_puppy/command_line/mcp/utils.py +129 -0
  86. code_puppy/command_line/mcp/wizard_utils.py +334 -0
  87. code_puppy/command_line/mcp_completion.py +174 -0
  88. code_puppy/command_line/model_picker_completion.py +197 -0
  89. code_puppy/command_line/model_settings_menu.py +932 -0
  90. code_puppy/command_line/motd.py +91 -0
  91. code_puppy/command_line/onboarding_slides.py +179 -0
  92. code_puppy/command_line/onboarding_wizard.py +342 -0
  93. code_puppy/command_line/pin_command_completion.py +329 -0
  94. code_puppy/command_line/prompt_toolkit_completion.py +846 -0
  95. code_puppy/command_line/session_commands.py +302 -0
  96. code_puppy/command_line/skills_completion.py +160 -0
  97. code_puppy/command_line/uc_menu.py +893 -0
  98. code_puppy/command_line/utils.py +93 -0
  99. code_puppy/command_line/wiggum_state.py +78 -0
  100. code_puppy/config.py +1787 -0
  101. code_puppy/error_logging.py +133 -0
  102. code_puppy/gemini_code_assist.py +385 -0
  103. code_puppy/gemini_model.py +754 -0
  104. code_puppy/hook_engine/README.md +105 -0
  105. code_puppy/hook_engine/__init__.py +15 -0
  106. code_puppy/hook_engine/aliases.py +155 -0
  107. code_puppy/hook_engine/engine.py +195 -0
  108. code_puppy/hook_engine/executor.py +293 -0
  109. code_puppy/hook_engine/matcher.py +145 -0
  110. code_puppy/hook_engine/models.py +222 -0
  111. code_puppy/hook_engine/registry.py +106 -0
  112. code_puppy/hook_engine/validator.py +141 -0
  113. code_puppy/http_utils.py +361 -0
  114. code_puppy/keymap.py +128 -0
  115. code_puppy/main.py +10 -0
  116. code_puppy/mcp_/__init__.py +66 -0
  117. code_puppy/mcp_/async_lifecycle.py +286 -0
  118. code_puppy/mcp_/blocking_startup.py +469 -0
  119. code_puppy/mcp_/captured_stdio_server.py +275 -0
  120. code_puppy/mcp_/circuit_breaker.py +290 -0
  121. code_puppy/mcp_/config_wizard.py +507 -0
  122. code_puppy/mcp_/dashboard.py +308 -0
  123. code_puppy/mcp_/error_isolation.py +407 -0
  124. code_puppy/mcp_/examples/retry_example.py +226 -0
  125. code_puppy/mcp_/health_monitor.py +589 -0
  126. code_puppy/mcp_/managed_server.py +428 -0
  127. code_puppy/mcp_/manager.py +807 -0
  128. code_puppy/mcp_/mcp_logs.py +224 -0
  129. code_puppy/mcp_/registry.py +451 -0
  130. code_puppy/mcp_/retry_manager.py +337 -0
  131. code_puppy/mcp_/server_registry_catalog.py +1126 -0
  132. code_puppy/mcp_/status_tracker.py +355 -0
  133. code_puppy/mcp_/system_tools.py +209 -0
  134. code_puppy/mcp_prompts/__init__.py +1 -0
  135. code_puppy/mcp_prompts/hook_creator.py +103 -0
  136. code_puppy/messaging/__init__.py +255 -0
  137. code_puppy/messaging/bus.py +613 -0
  138. code_puppy/messaging/commands.py +167 -0
  139. code_puppy/messaging/markdown_patches.py +57 -0
  140. code_puppy/messaging/message_queue.py +361 -0
  141. code_puppy/messaging/messages.py +569 -0
  142. code_puppy/messaging/queue_console.py +271 -0
  143. code_puppy/messaging/renderers.py +311 -0
  144. code_puppy/messaging/rich_renderer.py +1153 -0
  145. code_puppy/messaging/spinner/__init__.py +83 -0
  146. code_puppy/messaging/spinner/console_spinner.py +240 -0
  147. code_puppy/messaging/spinner/spinner_base.py +96 -0
  148. code_puppy/messaging/subagent_console.py +460 -0
  149. code_puppy/model_factory.py +848 -0
  150. code_puppy/model_switching.py +63 -0
  151. code_puppy/model_utils.py +168 -0
  152. code_puppy/models.json +130 -0
  153. code_puppy/models_dev_api.json +1 -0
  154. code_puppy/models_dev_parser.py +592 -0
  155. code_puppy/plugins/__init__.py +186 -0
  156. code_puppy/plugins/agent_skills/__init__.py +22 -0
  157. code_puppy/plugins/agent_skills/config.py +175 -0
  158. code_puppy/plugins/agent_skills/discovery.py +136 -0
  159. code_puppy/plugins/agent_skills/downloader.py +392 -0
  160. code_puppy/plugins/agent_skills/installer.py +22 -0
  161. code_puppy/plugins/agent_skills/metadata.py +219 -0
  162. code_puppy/plugins/agent_skills/prompt_builder.py +100 -0
  163. code_puppy/plugins/agent_skills/register_callbacks.py +241 -0
  164. code_puppy/plugins/agent_skills/remote_catalog.py +322 -0
  165. code_puppy/plugins/agent_skills/skill_catalog.py +257 -0
  166. code_puppy/plugins/agent_skills/skills_install_menu.py +664 -0
  167. code_puppy/plugins/agent_skills/skills_menu.py +781 -0
  168. code_puppy/plugins/antigravity_oauth/__init__.py +10 -0
  169. code_puppy/plugins/antigravity_oauth/accounts.py +406 -0
  170. code_puppy/plugins/antigravity_oauth/antigravity_model.py +706 -0
  171. code_puppy/plugins/antigravity_oauth/config.py +42 -0
  172. code_puppy/plugins/antigravity_oauth/constants.py +133 -0
  173. code_puppy/plugins/antigravity_oauth/oauth.py +478 -0
  174. code_puppy/plugins/antigravity_oauth/register_callbacks.py +518 -0
  175. code_puppy/plugins/antigravity_oauth/storage.py +288 -0
  176. code_puppy/plugins/antigravity_oauth/test_plugin.py +319 -0
  177. code_puppy/plugins/antigravity_oauth/token.py +167 -0
  178. code_puppy/plugins/antigravity_oauth/transport.py +863 -0
  179. code_puppy/plugins/antigravity_oauth/utils.py +168 -0
  180. code_puppy/plugins/chatgpt_oauth/__init__.py +8 -0
  181. code_puppy/plugins/chatgpt_oauth/config.py +52 -0
  182. code_puppy/plugins/chatgpt_oauth/oauth_flow.py +328 -0
  183. code_puppy/plugins/chatgpt_oauth/register_callbacks.py +176 -0
  184. code_puppy/plugins/chatgpt_oauth/test_plugin.py +295 -0
  185. code_puppy/plugins/chatgpt_oauth/utils.py +499 -0
  186. code_puppy/plugins/claude_code_hooks/__init__.py +1 -0
  187. code_puppy/plugins/claude_code_hooks/config.py +131 -0
  188. code_puppy/plugins/claude_code_hooks/register_callbacks.py +163 -0
  189. code_puppy/plugins/claude_code_oauth/README.md +167 -0
  190. code_puppy/plugins/claude_code_oauth/SETUP.md +93 -0
  191. code_puppy/plugins/claude_code_oauth/__init__.py +25 -0
  192. code_puppy/plugins/claude_code_oauth/config.py +52 -0
  193. code_puppy/plugins/claude_code_oauth/register_callbacks.py +453 -0
  194. code_puppy/plugins/claude_code_oauth/test_plugin.py +283 -0
  195. code_puppy/plugins/claude_code_oauth/token_refresh_heartbeat.py +241 -0
  196. code_puppy/plugins/claude_code_oauth/utils.py +601 -0
  197. code_puppy/plugins/customizable_commands/__init__.py +0 -0
  198. code_puppy/plugins/customizable_commands/register_callbacks.py +152 -0
  199. code_puppy/plugins/example_custom_command/README.md +280 -0
  200. code_puppy/plugins/example_custom_command/register_callbacks.py +48 -0
  201. code_puppy/plugins/file_permission_handler/__init__.py +4 -0
  202. code_puppy/plugins/file_permission_handler/register_callbacks.py +528 -0
  203. code_puppy/plugins/frontend_emitter/__init__.py +25 -0
  204. code_puppy/plugins/frontend_emitter/emitter.py +121 -0
  205. code_puppy/plugins/frontend_emitter/register_callbacks.py +261 -0
  206. code_puppy/plugins/hook_creator/__init__.py +1 -0
  207. code_puppy/plugins/hook_creator/register_callbacks.py +33 -0
  208. code_puppy/plugins/hook_manager/__init__.py +1 -0
  209. code_puppy/plugins/hook_manager/config.py +277 -0
  210. code_puppy/plugins/hook_manager/hooks_menu.py +551 -0
  211. code_puppy/plugins/hook_manager/register_callbacks.py +205 -0
  212. code_puppy/plugins/oauth_puppy_html.py +224 -0
  213. code_puppy/plugins/scheduler/__init__.py +1 -0
  214. code_puppy/plugins/scheduler/register_callbacks.py +88 -0
  215. code_puppy/plugins/scheduler/scheduler_menu.py +522 -0
  216. code_puppy/plugins/scheduler/scheduler_wizard.py +341 -0
  217. code_puppy/plugins/shell_safety/__init__.py +6 -0
  218. code_puppy/plugins/shell_safety/agent_shell_safety.py +69 -0
  219. code_puppy/plugins/shell_safety/command_cache.py +156 -0
  220. code_puppy/plugins/shell_safety/register_callbacks.py +202 -0
  221. code_puppy/plugins/synthetic_status/__init__.py +1 -0
  222. code_puppy/plugins/synthetic_status/register_callbacks.py +132 -0
  223. code_puppy/plugins/synthetic_status/status_api.py +147 -0
  224. code_puppy/plugins/universal_constructor/__init__.py +13 -0
  225. code_puppy/plugins/universal_constructor/models.py +138 -0
  226. code_puppy/plugins/universal_constructor/register_callbacks.py +47 -0
  227. code_puppy/plugins/universal_constructor/registry.py +302 -0
  228. code_puppy/plugins/universal_constructor/sandbox.py +584 -0
  229. code_puppy/prompts/antigravity_system_prompt.md +1 -0
  230. code_puppy/pydantic_patches.py +317 -0
  231. code_puppy/reopenable_async_client.py +232 -0
  232. code_puppy/round_robin_model.py +150 -0
  233. code_puppy/scheduler/__init__.py +41 -0
  234. code_puppy/scheduler/__main__.py +9 -0
  235. code_puppy/scheduler/cli.py +118 -0
  236. code_puppy/scheduler/config.py +126 -0
  237. code_puppy/scheduler/daemon.py +280 -0
  238. code_puppy/scheduler/executor.py +155 -0
  239. code_puppy/scheduler/platform.py +19 -0
  240. code_puppy/scheduler/platform_unix.py +22 -0
  241. code_puppy/scheduler/platform_win.py +32 -0
  242. code_puppy/session_storage.py +338 -0
  243. code_puppy/status_display.py +257 -0
  244. code_puppy/summarization_agent.py +176 -0
  245. code_puppy/terminal_utils.py +418 -0
  246. code_puppy/tools/__init__.py +470 -0
  247. code_puppy/tools/agent_tools.py +616 -0
  248. code_puppy/tools/ask_user_question/__init__.py +26 -0
  249. code_puppy/tools/ask_user_question/constants.py +73 -0
  250. code_puppy/tools/ask_user_question/demo_tui.py +55 -0
  251. code_puppy/tools/ask_user_question/handler.py +232 -0
  252. code_puppy/tools/ask_user_question/models.py +304 -0
  253. code_puppy/tools/ask_user_question/registration.py +36 -0
  254. code_puppy/tools/ask_user_question/renderers.py +309 -0
  255. code_puppy/tools/ask_user_question/terminal_ui.py +329 -0
  256. code_puppy/tools/ask_user_question/theme.py +155 -0
  257. code_puppy/tools/ask_user_question/tui_loop.py +423 -0
  258. code_puppy/tools/browser/__init__.py +37 -0
  259. code_puppy/tools/browser/browser_control.py +289 -0
  260. code_puppy/tools/browser/browser_interactions.py +545 -0
  261. code_puppy/tools/browser/browser_locators.py +640 -0
  262. code_puppy/tools/browser/browser_manager.py +378 -0
  263. code_puppy/tools/browser/browser_navigation.py +251 -0
  264. code_puppy/tools/browser/browser_screenshot.py +179 -0
  265. code_puppy/tools/browser/browser_scripts.py +462 -0
  266. code_puppy/tools/browser/browser_workflows.py +221 -0
  267. code_puppy/tools/browser/chromium_terminal_manager.py +259 -0
  268. code_puppy/tools/browser/terminal_command_tools.py +534 -0
  269. code_puppy/tools/browser/terminal_screenshot_tools.py +552 -0
  270. code_puppy/tools/browser/terminal_tools.py +525 -0
  271. code_puppy/tools/command_runner.py +1346 -0
  272. code_puppy/tools/common.py +1409 -0
  273. code_puppy/tools/display.py +84 -0
  274. code_puppy/tools/file_modifications.py +739 -0
  275. code_puppy/tools/file_operations.py +802 -0
  276. code_puppy/tools/scheduler_tools.py +412 -0
  277. code_puppy/tools/skills_tools.py +251 -0
  278. code_puppy/tools/subagent_context.py +158 -0
  279. code_puppy/tools/tools_content.py +51 -0
  280. code_puppy/tools/universal_constructor.py +889 -0
  281. code_puppy/uvx_detection.py +242 -0
  282. code_puppy/version_checker.py +82 -0
  283. newcode-0.1.1.data/data/code_puppy/models.json +130 -0
  284. newcode-0.1.1.data/data/code_puppy/models_dev_api.json +1 -0
  285. newcode-0.1.1.dist-info/METADATA +154 -0
  286. newcode-0.1.1.dist-info/RECORD +289 -0
  287. newcode-0.1.1.dist-info/WHEEL +4 -0
  288. newcode-0.1.1.dist-info/entry_points.txt +3 -0
  289. newcode-0.1.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,470 @@
1
+ from code_puppy.callbacks import on_register_tools
2
+ from code_puppy.messaging import emit_warning
3
+ from code_puppy.tools.agent_tools import register_invoke_agent, register_list_agents
4
+ from code_puppy.tools.ask_user_question import register_ask_user_question
5
+
6
+ # Browser automation tools
7
+ from code_puppy.tools.browser.browser_control import (
8
+ register_close_browser,
9
+ register_create_new_page,
10
+ register_get_browser_status,
11
+ register_initialize_browser,
12
+ register_list_pages,
13
+ )
14
+ from code_puppy.tools.browser.browser_interactions import (
15
+ register_browser_check,
16
+ register_browser_uncheck,
17
+ register_click_element,
18
+ register_double_click_element,
19
+ register_get_element_text,
20
+ register_get_element_value,
21
+ register_hover_element,
22
+ register_select_option,
23
+ register_set_element_text,
24
+ )
25
+ from code_puppy.tools.browser.browser_locators import (
26
+ register_find_buttons,
27
+ register_find_by_label,
28
+ register_find_by_placeholder,
29
+ register_find_by_role,
30
+ register_find_by_test_id,
31
+ register_find_by_text,
32
+ register_find_links,
33
+ register_run_xpath_query,
34
+ )
35
+ from code_puppy.tools.browser.browser_navigation import (
36
+ register_browser_go_back,
37
+ register_browser_go_forward,
38
+ register_get_page_info,
39
+ register_navigate_to_url,
40
+ register_reload_page,
41
+ register_wait_for_load_state,
42
+ )
43
+ from code_puppy.tools.browser.browser_screenshot import (
44
+ register_take_screenshot_and_analyze,
45
+ )
46
+ from code_puppy.tools.browser.browser_scripts import (
47
+ register_browser_clear_highlights,
48
+ register_browser_highlight_element,
49
+ register_execute_javascript,
50
+ register_scroll_page,
51
+ register_scroll_to_element,
52
+ register_set_viewport_size,
53
+ register_wait_for_element,
54
+ )
55
+ from code_puppy.tools.browser.browser_workflows import (
56
+ register_list_workflows,
57
+ register_read_workflow,
58
+ register_save_workflow,
59
+ )
60
+ from code_puppy.tools.browser.terminal_command_tools import (
61
+ register_run_terminal_command,
62
+ register_send_terminal_keys,
63
+ register_wait_terminal_output,
64
+ )
65
+ from code_puppy.tools.browser.terminal_screenshot_tools import (
66
+ register_load_image,
67
+ register_terminal_compare_mockup,
68
+ register_terminal_read_output,
69
+ register_terminal_screenshot,
70
+ )
71
+
72
+ # Terminal automation tools
73
+ from code_puppy.tools.browser.terminal_tools import (
74
+ register_check_terminal_server,
75
+ register_close_terminal,
76
+ register_open_terminal,
77
+ register_start_api_server,
78
+ )
79
+ from code_puppy.tools.command_runner import (
80
+ register_agent_run_shell_command,
81
+ register_agent_share_your_reasoning,
82
+ )
83
+ from code_puppy.tools.display import (
84
+ display_non_streamed_result as display_non_streamed_result,
85
+ )
86
+ from code_puppy.tools.file_modifications import register_delete_file, register_edit_file
87
+ from code_puppy.tools.file_operations import (
88
+ register_grep,
89
+ register_list_files,
90
+ register_read_file,
91
+ )
92
+
93
+ # Scheduler tools
94
+ from code_puppy.tools.scheduler_tools import (
95
+ register_scheduler_create_task,
96
+ register_scheduler_daemon_status,
97
+ register_scheduler_delete_task,
98
+ register_scheduler_list_tasks,
99
+ register_scheduler_run_task,
100
+ register_scheduler_start_daemon,
101
+ register_scheduler_stop_daemon,
102
+ register_scheduler_toggle_task,
103
+ register_scheduler_view_log,
104
+ )
105
+ from code_puppy.tools.skills_tools import (
106
+ register_activate_skill,
107
+ register_list_or_search_skills,
108
+ )
109
+ from code_puppy.tools.universal_constructor import register_universal_constructor
110
+
111
+ # Map of tool names to their individual registration functions
112
+ TOOL_REGISTRY = {
113
+ # Agent Tools
114
+ "list_agents": register_list_agents,
115
+ "invoke_agent": register_invoke_agent,
116
+ # File Operations
117
+ "list_files": register_list_files,
118
+ "read_file": register_read_file,
119
+ "grep": register_grep,
120
+ # File Modifications
121
+ "edit_file": register_edit_file,
122
+ "delete_file": register_delete_file,
123
+ # Command Runner
124
+ "agent_run_shell_command": register_agent_run_shell_command,
125
+ "agent_share_your_reasoning": register_agent_share_your_reasoning,
126
+ # User Interaction
127
+ "ask_user_question": register_ask_user_question,
128
+ # Browser Control
129
+ "browser_initialize": register_initialize_browser,
130
+ "browser_close": register_close_browser,
131
+ "browser_status": register_get_browser_status,
132
+ "browser_new_page": register_create_new_page,
133
+ "browser_list_pages": register_list_pages,
134
+ # Browser Navigation
135
+ "browser_navigate": register_navigate_to_url,
136
+ "browser_get_page_info": register_get_page_info,
137
+ "browser_go_back": register_browser_go_back,
138
+ "browser_go_forward": register_browser_go_forward,
139
+ "browser_reload": register_reload_page,
140
+ "browser_wait_for_load": register_wait_for_load_state,
141
+ # Browser Element Discovery
142
+ "browser_find_by_role": register_find_by_role,
143
+ "browser_find_by_text": register_find_by_text,
144
+ "browser_find_by_label": register_find_by_label,
145
+ "browser_find_by_placeholder": register_find_by_placeholder,
146
+ "browser_find_by_test_id": register_find_by_test_id,
147
+ "browser_xpath_query": register_run_xpath_query,
148
+ "browser_find_buttons": register_find_buttons,
149
+ "browser_find_links": register_find_links,
150
+ # Browser Element Interactions
151
+ "browser_click": register_click_element,
152
+ "browser_double_click": register_double_click_element,
153
+ "browser_hover": register_hover_element,
154
+ "browser_set_text": register_set_element_text,
155
+ "browser_get_text": register_get_element_text,
156
+ "browser_get_value": register_get_element_value,
157
+ "browser_select_option": register_select_option,
158
+ "browser_check": register_browser_check,
159
+ "browser_uncheck": register_browser_uncheck,
160
+ # Browser Scripts and Advanced Features
161
+ "browser_execute_js": register_execute_javascript,
162
+ "browser_scroll": register_scroll_page,
163
+ "browser_scroll_to_element": register_scroll_to_element,
164
+ "browser_set_viewport": register_set_viewport_size,
165
+ "browser_wait_for_element": register_wait_for_element,
166
+ "browser_highlight_element": register_browser_highlight_element,
167
+ "browser_clear_highlights": register_browser_clear_highlights,
168
+ # Browser Screenshots
169
+ "browser_screenshot_analyze": register_take_screenshot_and_analyze,
170
+ # Browser Workflows
171
+ "browser_save_workflow": register_save_workflow,
172
+ "browser_list_workflows": register_list_workflows,
173
+ "browser_read_workflow": register_read_workflow,
174
+ # Terminal Connection Tools
175
+ "terminal_check_server": register_check_terminal_server,
176
+ "terminal_open": register_open_terminal,
177
+ "terminal_close": register_close_terminal,
178
+ "start_api_server": register_start_api_server,
179
+ # Terminal Command Execution Tools
180
+ "terminal_run_command": register_run_terminal_command,
181
+ "terminal_send_keys": register_send_terminal_keys,
182
+ "terminal_wait_output": register_wait_terminal_output,
183
+ # Terminal Screenshot Tools
184
+ "terminal_screenshot_analyze": register_terminal_screenshot,
185
+ "terminal_read_output": register_terminal_read_output,
186
+ "terminal_compare_mockup": register_terminal_compare_mockup,
187
+ "load_image_for_analysis": register_load_image,
188
+ # Skills Tools
189
+ "activate_skill": register_activate_skill,
190
+ "list_or_search_skills": register_list_or_search_skills,
191
+ # Universal Constructor
192
+ "universal_constructor": register_universal_constructor,
193
+ # Scheduler Tools
194
+ "scheduler_list_tasks": register_scheduler_list_tasks,
195
+ "scheduler_create_task": register_scheduler_create_task,
196
+ "scheduler_delete_task": register_scheduler_delete_task,
197
+ "scheduler_toggle_task": register_scheduler_toggle_task,
198
+ "scheduler_daemon_status": register_scheduler_daemon_status,
199
+ "scheduler_start_daemon": register_scheduler_start_daemon,
200
+ "scheduler_stop_daemon": register_scheduler_stop_daemon,
201
+ "scheduler_run_task": register_scheduler_run_task,
202
+ "scheduler_view_log": register_scheduler_view_log,
203
+ }
204
+
205
+
206
+ def _load_plugin_tools() -> None:
207
+ """Load tools registered by plugins via the register_tools callback.
208
+
209
+ This merges plugin-provided tools into the TOOL_REGISTRY.
210
+ Called lazily when tools are first accessed.
211
+ """
212
+ try:
213
+ results = on_register_tools()
214
+ for result in results:
215
+ if result is None:
216
+ continue
217
+ # Each result should be a list of tool definitions
218
+ tools_list = result if isinstance(result, list) else [result]
219
+ for tool_def in tools_list:
220
+ if (
221
+ isinstance(tool_def, dict)
222
+ and "name" in tool_def
223
+ and "register_func" in tool_def
224
+ ):
225
+ tool_name = tool_def["name"]
226
+ register_func = tool_def["register_func"]
227
+ if callable(register_func):
228
+ TOOL_REGISTRY[tool_name] = register_func
229
+ except Exception:
230
+ # Don't let plugin failures break core functionality
231
+ pass
232
+
233
+
234
+ # Appended to the system prompt when extended thinking is active and
235
+ # the share_your_reasoning tool is removed. Encourages the model to
236
+ # use its native thinking blocks between tool calls instead.
237
+ EXTENDED_THINKING_PROMPT_NOTE = (
238
+ "\n\nIMPORTANT: You have extended thinking enabled. "
239
+ "Always think between tool calls or waves of tool calls "
240
+ "(if running parallel tools). Use your thinking blocks to reason "
241
+ "about the results before deciding on next steps."
242
+ )
243
+
244
+
245
+ def has_extended_thinking_active(model_name: str | None = None) -> bool:
246
+ """Check if an Anthropic model has extended thinking enabled or adaptive.
247
+
248
+ When extended thinking is active, the model already exposes its reasoning
249
+ via thinking blocks, making the share_your_reasoning tool redundant.
250
+
251
+ Args:
252
+ model_name: The model name to check. If None, uses the current global model.
253
+
254
+ Returns:
255
+ True if the model is an Anthropic model with extended_thinking set to
256
+ "enabled" or "adaptive".
257
+ """
258
+ from code_puppy.config import get_effective_model_settings, get_global_model_name
259
+
260
+ if model_name is None:
261
+ model_name = get_global_model_name()
262
+
263
+ if model_name is None:
264
+ return False
265
+
266
+ # Only applies to Anthropic/Claude models
267
+ if not (model_name.startswith("claude-") or model_name.startswith("anthropic-")):
268
+ return False
269
+
270
+ from code_puppy.model_utils import get_default_extended_thinking
271
+
272
+ settings = get_effective_model_settings(model_name)
273
+ default_thinking = get_default_extended_thinking(model_name)
274
+ extended_thinking = settings.get("extended_thinking", default_thinking)
275
+
276
+ # Handle legacy boolean values
277
+ if extended_thinking is True:
278
+ extended_thinking = "enabled"
279
+ elif extended_thinking is False:
280
+ return False
281
+
282
+ return extended_thinking in ("enabled", "adaptive")
283
+
284
+
285
+ def register_tools_for_agent(
286
+ agent, tool_names: list[str], model_name: str | None = None
287
+ ):
288
+ """Register specific tools for an agent based on tool names.
289
+
290
+ Args:
291
+ agent: The agent to register tools to.
292
+ tool_names: List of tool names to register. UC tools are prefixed with "uc:".
293
+ model_name: Optional model name. Used to determine if certain tools
294
+ (like agent_share_your_reasoning) should be skipped. If None,
295
+ falls back to the current global model.
296
+ """
297
+ from code_puppy.config import get_universal_constructor_enabled
298
+
299
+ _load_plugin_tools()
300
+
301
+ # Pre-compute whether extended thinking is active to avoid repeated checks
302
+ skip_reasoning_tool = has_extended_thinking_active(model_name)
303
+
304
+ for tool_name in tool_names:
305
+ # Handle UC tools (prefixed with "uc:")
306
+ if tool_name.startswith("uc:"):
307
+ # Skip UC tools if UC is disabled
308
+ if not get_universal_constructor_enabled():
309
+ continue
310
+ uc_tool_name = tool_name[3:] # Remove "uc:" prefix
311
+ _register_uc_tool_wrapper(agent, uc_tool_name)
312
+ continue
313
+
314
+ if tool_name not in TOOL_REGISTRY:
315
+ # Skip unknown tools with a warning instead of failing
316
+ emit_warning(f"Warning: Unknown tool '{tool_name}' requested, skipping...")
317
+ continue
318
+
319
+ # Check if Universal Constructor is disabled
320
+ if (
321
+ tool_name == "universal_constructor"
322
+ and not get_universal_constructor_enabled()
323
+ ):
324
+ continue # Skip UC if disabled in config
325
+
326
+ # Skip reasoning tool when extended thinking is active — the model
327
+ # already exposes its chain-of-thought via thinking blocks.
328
+ if tool_name == "agent_share_your_reasoning" and skip_reasoning_tool:
329
+ continue
330
+
331
+ # Register the individual tool
332
+ register_func = TOOL_REGISTRY[tool_name]
333
+ register_func(agent)
334
+
335
+
336
+ def _register_uc_tool_wrapper(agent, uc_tool_name: str):
337
+ """Register a wrapper for a UC tool that calls it via the UC registry.
338
+
339
+ This creates a dynamic tool that wraps the UC tool, preserving its
340
+ parameter signature so pydantic-ai can generate proper JSON schema.
341
+
342
+ Args:
343
+ agent: The agent to register the tool wrapper to.
344
+ uc_tool_name: The full name of the UC tool (e.g., "api.weather").
345
+ """
346
+ import inspect
347
+ from typing import Any
348
+
349
+ from pydantic_ai import RunContext
350
+
351
+ # Get tool info and function from registry
352
+ try:
353
+ from code_puppy.plugins.universal_constructor.registry import get_registry
354
+
355
+ registry = get_registry()
356
+ tool_info = registry.get_tool(uc_tool_name)
357
+ if not tool_info:
358
+ emit_warning(f"Warning: UC tool '{uc_tool_name}' not found, skipping...")
359
+ return
360
+
361
+ func = registry.get_tool_function(uc_tool_name)
362
+ if not func:
363
+ emit_warning(
364
+ f"Warning: UC tool '{uc_tool_name}' function not found, skipping..."
365
+ )
366
+ return
367
+
368
+ description = tool_info.meta.description
369
+ docstring = tool_info.docstring or description
370
+ except Exception as e:
371
+ emit_warning(f"Warning: Failed to get UC tool '{uc_tool_name}' info: {e}")
372
+ return
373
+
374
+ # Get the original function's signature
375
+ try:
376
+ sig = inspect.signature(func)
377
+ # Get annotations from the original function
378
+ annotations = getattr(func, "__annotations__", {}).copy()
379
+ except (ValueError, TypeError):
380
+ sig = None
381
+ annotations = {}
382
+
383
+ # Create wrapper that preserves the signature
384
+ def make_uc_wrapper(
385
+ tool_name: str, original_func, original_sig, original_annotations
386
+ ):
387
+ # Build the wrapper function
388
+ async def uc_tool_wrapper(context: RunContext, **kwargs: Any) -> Any:
389
+ """Dynamically generated wrapper for a UC tool."""
390
+ try:
391
+ result = original_func(**kwargs)
392
+ # Await async tool implementations
393
+ if inspect.isawaitable(result):
394
+ result = await result
395
+ return result
396
+ except Exception as e:
397
+ return {"error": f"UC tool '{tool_name}' failed: {e}"}
398
+
399
+ # Copy signature info from original function
400
+ uc_tool_wrapper.__name__ = tool_name.replace(".", "_")
401
+ uc_tool_wrapper.__doc__ = (
402
+ f"{docstring}\n\nThis is a Universal Constructor tool."
403
+ )
404
+
405
+ # Preserve annotations for pydantic-ai schema generation
406
+ if original_annotations:
407
+ # Add 'context' param and copy original params (excluding 'return')
408
+ new_annotations = {"context": RunContext}
409
+ for param_name, param_type in original_annotations.items():
410
+ if param_name != "return":
411
+ new_annotations[param_name] = param_type
412
+ if "return" in original_annotations:
413
+ new_annotations["return"] = original_annotations["return"]
414
+ else:
415
+ new_annotations["return"] = Any
416
+ uc_tool_wrapper.__annotations__ = new_annotations
417
+
418
+ # Try to set __signature__ for better introspection
419
+ if original_sig:
420
+ try:
421
+ # Build new parameters list: context first, then original params
422
+ new_params = [
423
+ inspect.Parameter(
424
+ "context",
425
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
426
+ annotation=RunContext,
427
+ )
428
+ ]
429
+ for param in original_sig.parameters.values():
430
+ new_params.append(param)
431
+
432
+ # Create new signature with return annotation
433
+ return_annotation = original_annotations.get("return", Any)
434
+ new_sig = original_sig.replace(
435
+ parameters=new_params, return_annotation=return_annotation
436
+ )
437
+ uc_tool_wrapper.__signature__ = new_sig
438
+ except (ValueError, TypeError):
439
+ pass # Signature manipulation failed, continue without it
440
+
441
+ return uc_tool_wrapper
442
+
443
+ wrapper = make_uc_wrapper(uc_tool_name, func, sig, annotations)
444
+
445
+ # Register the wrapper as a tool
446
+ try:
447
+ agent.tool(wrapper)
448
+ except Exception as e:
449
+ emit_warning(f"Warning: Failed to register UC tool '{uc_tool_name}': {e}")
450
+
451
+
452
+ def register_all_tools(agent, model_name: str | None = None):
453
+ """Register all available tools to the provided agent.
454
+
455
+ Args:
456
+ agent: The agent to register tools to.
457
+ model_name: Optional model name for conditional tool filtering.
458
+ """
459
+ all_tools = list(TOOL_REGISTRY.keys())
460
+ register_tools_for_agent(agent, all_tools, model_name=model_name)
461
+
462
+
463
+ def get_available_tool_names() -> list[str]:
464
+ """Get list of all available tool names.
465
+
466
+ Returns:
467
+ List of all tool names that can be registered.
468
+ """
469
+ _load_plugin_tools()
470
+ return list(TOOL_REGISTRY.keys())