code-puppy-core-plugins 0.0.2__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_core_plugins/__init__.py +5 -0
- code_puppy_core_plugins/acp/README.md +266 -0
- code_puppy_core_plugins/acp/__init__.py +8 -0
- code_puppy_core_plugins/acp/agent.py +494 -0
- code_puppy_core_plugins/acp/bridge.py +309 -0
- code_puppy_core_plugins/acp/capabilities.py +73 -0
- code_puppy_core_plugins/acp/commands.py +116 -0
- code_puppy_core_plugins/acp/content.py +115 -0
- code_puppy_core_plugins/acp/io_delegation.py +231 -0
- code_puppy_core_plugins/acp/mcp_config.py +66 -0
- code_puppy_core_plugins/acp/permissions.py +159 -0
- code_puppy_core_plugins/acp/persistence.py +197 -0
- code_puppy_core_plugins/acp/register_callbacks.py +110 -0
- code_puppy_core_plugins/acp/replay.py +114 -0
- code_puppy_core_plugins/acp/session.py +329 -0
- code_puppy_core_plugins/acp/session_config.py +179 -0
- code_puppy_core_plugins/acp/state.py +135 -0
- code_puppy_core_plugins/agent_skills/__init__.py +22 -0
- code_puppy_core_plugins/agent_skills/config.py +208 -0
- code_puppy_core_plugins/agent_skills/discovery.py +337 -0
- code_puppy_core_plugins/agent_skills/downloader.py +392 -0
- code_puppy_core_plugins/agent_skills/enabled_skills.py +82 -0
- code_puppy_core_plugins/agent_skills/installer.py +22 -0
- code_puppy_core_plugins/agent_skills/metadata.py +219 -0
- code_puppy_core_plugins/agent_skills/prompt_builder.py +49 -0
- code_puppy_core_plugins/agent_skills/provider.py +52 -0
- code_puppy_core_plugins/agent_skills/register_callbacks.py +309 -0
- code_puppy_core_plugins/agent_skills/remote_catalog.py +322 -0
- code_puppy_core_plugins/agent_skills/skill_catalog.py +257 -0
- code_puppy_core_plugins/agent_skills/skill_commands.py +102 -0
- code_puppy_core_plugins/agent_skills/skills_install_menu.py +698 -0
- code_puppy_core_plugins/agent_skills/skills_menu.py +794 -0
- code_puppy_core_plugins/aws_bedrock/__init__.py +14 -0
- code_puppy_core_plugins/aws_bedrock/config.py +101 -0
- code_puppy_core_plugins/aws_bedrock/register_callbacks.py +243 -0
- code_puppy_core_plugins/aws_bedrock/utils.py +186 -0
- code_puppy_core_plugins/azure_foundry/README.md +238 -0
- code_puppy_core_plugins/azure_foundry/__init__.py +15 -0
- code_puppy_core_plugins/azure_foundry/config.py +126 -0
- code_puppy_core_plugins/azure_foundry/discovery.py +189 -0
- code_puppy_core_plugins/azure_foundry/register_callbacks.py +506 -0
- code_puppy_core_plugins/azure_foundry/token.py +182 -0
- code_puppy_core_plugins/azure_foundry/utils.py +375 -0
- code_puppy_core_plugins/btw/__init__.py +1 -0
- code_puppy_core_plugins/btw/inline_view.py +135 -0
- code_puppy_core_plugins/btw/register_callbacks.py +106 -0
- code_puppy_core_plugins/btw/side_query.py +91 -0
- code_puppy_core_plugins/chatgpt_oauth/IMAGEGEN_SKILL.md +83 -0
- code_puppy_core_plugins/chatgpt_oauth/__init__.py +8 -0
- code_puppy_core_plugins/chatgpt_oauth/config.py +52 -0
- code_puppy_core_plugins/chatgpt_oauth/image_generation.py +253 -0
- code_puppy_core_plugins/chatgpt_oauth/image_tool.py +70 -0
- code_puppy_core_plugins/chatgpt_oauth/oauth_flow.py +461 -0
- code_puppy_core_plugins/chatgpt_oauth/register_callbacks.py +288 -0
- code_puppy_core_plugins/chatgpt_oauth/test_plugin.py +663 -0
- code_puppy_core_plugins/chatgpt_oauth/usage.py +113 -0
- code_puppy_core_plugins/chatgpt_oauth/utils.py +534 -0
- code_puppy_core_plugins/claude_code_hooks/__init__.py +1 -0
- code_puppy_core_plugins/claude_code_hooks/config.py +137 -0
- code_puppy_core_plugins/claude_code_hooks/register_callbacks.py +383 -0
- code_puppy_core_plugins/claude_code_oauth/README.md +167 -0
- code_puppy_core_plugins/claude_code_oauth/SETUP.md +93 -0
- code_puppy_core_plugins/claude_code_oauth/__init__.py +25 -0
- code_puppy_core_plugins/claude_code_oauth/config.py +59 -0
- code_puppy_core_plugins/claude_code_oauth/fast_mode.py +122 -0
- code_puppy_core_plugins/claude_code_oauth/prompt_handler.py +64 -0
- code_puppy_core_plugins/claude_code_oauth/register_callbacks.py +719 -0
- code_puppy_core_plugins/claude_code_oauth/test_plugin.py +285 -0
- code_puppy_core_plugins/claude_code_oauth/token_refresh_heartbeat.py +240 -0
- code_puppy_core_plugins/claude_code_oauth/utils.py +663 -0
- code_puppy_core_plugins/code_puppy_agent/AGENTS_AND_TOOLS.md +155 -0
- code_puppy_core_plugins/code_puppy_agent/MODELS_AND_MCP.md +104 -0
- code_puppy_core_plugins/code_puppy_agent/PLUGINS_AND_CALLBACKS.md +147 -0
- code_puppy_core_plugins/code_puppy_agent/SESSIONS_AND_HISTORY.md +39 -0
- code_puppy_core_plugins/code_puppy_agent/SKILL.md +180 -0
- code_puppy_core_plugins/code_puppy_agent/SKILLS_SYSTEM.md +136 -0
- code_puppy_core_plugins/code_puppy_agent/SYSTEM_PROMPT_CONFIG_AND_I18N.md +160 -0
- code_puppy_core_plugins/code_puppy_agent/__init__.py +5 -0
- code_puppy_core_plugins/code_puppy_agent/register_callbacks.py +46 -0
- code_puppy_core_plugins/computer_use/NativeCapture.swift +123 -0
- code_puppy_core_plugins/computer_use/README.md +109 -0
- code_puppy_core_plugins/computer_use/__init__.py +1 -0
- code_puppy_core_plugins/computer_use/accessibility.py +163 -0
- code_puppy_core_plugins/computer_use/activation.py +75 -0
- code_puppy_core_plugins/computer_use/backend.py +584 -0
- code_puppy_core_plugins/computer_use/backend_types.py +5 -0
- code_puppy_core_plugins/computer_use/capture.py +110 -0
- code_puppy_core_plugins/computer_use/commands.py +62 -0
- code_puppy_core_plugins/computer_use/geometry.py +81 -0
- code_puppy_core_plugins/computer_use/inline_image.py +56 -0
- code_puppy_core_plugins/computer_use/keycodes.py +47 -0
- code_puppy_core_plugins/computer_use/policy.py +144 -0
- code_puppy_core_plugins/computer_use/register_callbacks.py +96 -0
- code_puppy_core_plugins/computer_use/safety.py +18 -0
- code_puppy_core_plugins/computer_use/settle.py +64 -0
- code_puppy_core_plugins/computer_use/state.py +86 -0
- code_puppy_core_plugins/computer_use/tools.py +469 -0
- code_puppy_core_plugins/context_indicator/__init__.py +14 -0
- code_puppy_core_plugins/context_indicator/register_callbacks.py +249 -0
- code_puppy_core_plugins/context_indicator/usage.py +40 -0
- code_puppy_core_plugins/copilot_auth/__init__.py +11 -0
- code_puppy_core_plugins/copilot_auth/config.py +93 -0
- code_puppy_core_plugins/copilot_auth/reasoning_client.py +409 -0
- code_puppy_core_plugins/copilot_auth/register_callbacks.py +460 -0
- code_puppy_core_plugins/copilot_auth/utils.py +587 -0
- code_puppy_core_plugins/customizable_commands/__init__.py +0 -0
- code_puppy_core_plugins/customizable_commands/register_callbacks.py +464 -0
- code_puppy_core_plugins/dbos_durable_exec/__init__.py +1 -0
- code_puppy_core_plugins/dbos_durable_exec/cancel.py +15 -0
- code_puppy_core_plugins/dbos_durable_exec/commands.py +31 -0
- code_puppy_core_plugins/dbos_durable_exec/config.py +31 -0
- code_puppy_core_plugins/dbos_durable_exec/lifecycle.py +83 -0
- code_puppy_core_plugins/dbos_durable_exec/register_callbacks.py +45 -0
- code_puppy_core_plugins/dbos_durable_exec/runtime.py +65 -0
- code_puppy_core_plugins/dbos_durable_exec/startup_lock.py +155 -0
- code_puppy_core_plugins/dbos_durable_exec/workflow_ids.py +16 -0
- code_puppy_core_plugins/dbos_durable_exec/wrapper.py +58 -0
- code_puppy_core_plugins/destructive_command_guard/AGENTS.md +79 -0
- code_puppy_core_plugins/destructive_command_guard/__init__.py +14 -0
- code_puppy_core_plugins/destructive_command_guard/detector.py +374 -0
- code_puppy_core_plugins/destructive_command_guard/register_callbacks.py +165 -0
- code_puppy_core_plugins/emoji_filter/__init__.py +12 -0
- code_puppy_core_plugins/emoji_filter/config.py +26 -0
- code_puppy_core_plugins/emoji_filter/register_callbacks.py +238 -0
- code_puppy_core_plugins/emoji_filter/stripper.py +45 -0
- code_puppy_core_plugins/empty_html_comment_filter/register_callbacks.py +116 -0
- code_puppy_core_plugins/example_custom_command/README.md +328 -0
- code_puppy_core_plugins/example_custom_command/register_callbacks.py +66 -0
- code_puppy_core_plugins/file_permission_handler/__init__.py +4 -0
- code_puppy_core_plugins/file_permission_handler/register_callbacks.py +575 -0
- code_puppy_core_plugins/flux_bootstrap/__init__.py +5 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/_docs/README.md +173 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/_docs/cheatsheet.md +86 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/_docs/pipeline.md +167 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/_docs/synopsis.md +392 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/about.md +51 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/address-feedback.md +129 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/ask.md +211 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/aug.md +181 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/auto-pilot.md +71 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/cheatsheet.md +16 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/commit.md +103 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/config.md +108 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/create-pr.md +195 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/exec.md +221 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/new.md +151 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/qa.md +208 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/rebase.md +180 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/review.md +304 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/split.md +120 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/squash-commits.md +179 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/status.md +46 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/commands/flux/tests.md +155 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/scripts/flux_about.py +154 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/scripts/flux_cheatsheet.py +248 -0
- code_puppy_core_plugins/flux_bootstrap/bundled/scripts/flux_status.py +345 -0
- code_puppy_core_plugins/flux_bootstrap/installer.py +256 -0
- code_puppy_core_plugins/flux_bootstrap/register_callbacks.py +71 -0
- code_puppy_core_plugins/force_push_guard/__init__.py +5 -0
- code_puppy_core_plugins/force_push_guard/detector.py +96 -0
- code_puppy_core_plugins/force_push_guard/register_callbacks.py +161 -0
- code_puppy_core_plugins/fork/__init__.py +7 -0
- code_puppy_core_plugins/fork/register_callbacks.py +445 -0
- code_puppy_core_plugins/frontend_emitter/__init__.py +25 -0
- code_puppy_core_plugins/frontend_emitter/emitter.py +249 -0
- code_puppy_core_plugins/frontend_emitter/register_callbacks.py +412 -0
- code_puppy_core_plugins/frontend_emitter/session_context.py +50 -0
- code_puppy_core_plugins/grok_oauth/__init__.py +6 -0
- code_puppy_core_plugins/grok_oauth/config.py +49 -0
- code_puppy_core_plugins/grok_oauth/oauth_flow.py +213 -0
- code_puppy_core_plugins/grok_oauth/register_callbacks.py +132 -0
- code_puppy_core_plugins/grok_oauth/utils.py +195 -0
- code_puppy_core_plugins/herdr/README.md +168 -0
- code_puppy_core_plugins/herdr/__init__.py +9 -0
- code_puppy_core_plugins/herdr/client.py +339 -0
- code_puppy_core_plugins/herdr/register_callbacks.py +140 -0
- code_puppy_core_plugins/herdr/reporter.py +212 -0
- code_puppy_core_plugins/herdr/smoke.py +143 -0
- code_puppy_core_plugins/herdr/sources.py +133 -0
- code_puppy_core_plugins/hook_creator/__init__.py +1 -0
- code_puppy_core_plugins/hook_creator/register_callbacks.py +33 -0
- code_puppy_core_plugins/hook_manager/__init__.py +1 -0
- code_puppy_core_plugins/hook_manager/config.py +290 -0
- code_puppy_core_plugins/hook_manager/hooks_menu.py +571 -0
- code_puppy_core_plugins/hook_manager/register_callbacks.py +227 -0
- code_puppy_core_plugins/meta_oauth/__init__.py +1 -0
- code_puppy_core_plugins/meta_oauth/config.py +55 -0
- code_puppy_core_plugins/meta_oauth/oauth_flow.py +109 -0
- code_puppy_core_plugins/meta_oauth/register_callbacks.py +154 -0
- code_puppy_core_plugins/meta_oauth/utils.py +252 -0
- code_puppy_core_plugins/namespace_skill_search/README.md +118 -0
- code_puppy_core_plugins/namespace_skill_search/__init__.py +15 -0
- code_puppy_core_plugins/namespace_skill_search/namespaces.py +125 -0
- code_puppy_core_plugins/namespace_skill_search/register_callbacks.py +99 -0
- code_puppy_core_plugins/namespace_skill_search/search_tool.py +158 -0
- code_puppy_core_plugins/no_tools/__init__.py +0 -0
- code_puppy_core_plugins/no_tools/register_callbacks.py +42 -0
- code_puppy_core_plugins/oauth_pasteback.py +110 -0
- code_puppy_core_plugins/oauth_puppy_html.py +194 -0
- code_puppy_core_plugins/obsidian_agent/README.md +52 -0
- code_puppy_core_plugins/obsidian_agent/__init__.py +8 -0
- code_puppy_core_plugins/obsidian_agent/agent_obsidian.py +147 -0
- code_puppy_core_plugins/obsidian_agent/register_callbacks.py +13 -0
- code_puppy_core_plugins/ollama/__init__.py +1 -0
- code_puppy_core_plugins/ollama/register_callbacks.py +127 -0
- code_puppy_core_plugins/ollama_setup/__init__.py +5 -0
- code_puppy_core_plugins/ollama_setup/completer.py +38 -0
- code_puppy_core_plugins/ollama_setup/register_callbacks.py +419 -0
- code_puppy_core_plugins/plugin_list/__init__.py +0 -0
- code_puppy_core_plugins/plugin_list/plugin_contributions.py +348 -0
- code_puppy_core_plugins/plugin_list/plugin_meta.py +67 -0
- code_puppy_core_plugins/plugin_list/plugin_text_utils.py +173 -0
- code_puppy_core_plugins/plugin_list/plugins_menu.py +455 -0
- code_puppy_core_plugins/plugin_list/plugins_menu_layout.py +194 -0
- code_puppy_core_plugins/plugin_list/plugins_menu_render.py +431 -0
- code_puppy_core_plugins/plugin_list/project_trust_flow.py +162 -0
- code_puppy_core_plugins/plugin_list/register_callbacks.py +281 -0
- code_puppy_core_plugins/pop_command/__init__.py +1 -0
- code_puppy_core_plugins/pop_command/register_callbacks.py +191 -0
- code_puppy_core_plugins/prompt_newline/__init__.py +13 -0
- code_puppy_core_plugins/prompt_newline/config.py +21 -0
- code_puppy_core_plugins/prompt_newline/register_callbacks.py +163 -0
- code_puppy_core_plugins/prune/__init__.py +1 -0
- code_puppy_core_plugins/prune/prune_menu.py +308 -0
- code_puppy_core_plugins/prune/prune_model.py +517 -0
- code_puppy_core_plugins/prune/prune_render.py +354 -0
- code_puppy_core_plugins/prune/register_callbacks.py +388 -0
- code_puppy_core_plugins/puppy_kennel/README.md +203 -0
- code_puppy_core_plugins/puppy_kennel/__init__.py +6 -0
- code_puppy_core_plugins/puppy_kennel/commands.py +206 -0
- code_puppy_core_plugins/puppy_kennel/config.py +36 -0
- code_puppy_core_plugins/puppy_kennel/kennel.py +368 -0
- code_puppy_core_plugins/puppy_kennel/packer.py +152 -0
- code_puppy_core_plugins/puppy_kennel/recorder.py +83 -0
- code_puppy_core_plugins/puppy_kennel/register_callbacks.py +109 -0
- code_puppy_core_plugins/puppy_kennel/retriever.py +28 -0
- code_puppy_core_plugins/puppy_kennel/schema.py +78 -0
- code_puppy_core_plugins/puppy_kennel/state.py +68 -0
- code_puppy_core_plugins/puppy_kennel/tools.py +449 -0
- code_puppy_core_plugins/puppy_kennel/wings.py +110 -0
- code_puppy_core_plugins/puppy_spinner/README.md +93 -0
- code_puppy_core_plugins/puppy_spinner/__init__.py +11 -0
- code_puppy_core_plugins/puppy_spinner/builtin_frames.py +172 -0
- code_puppy_core_plugins/puppy_spinner/commands.py +116 -0
- code_puppy_core_plugins/puppy_spinner/picker.py +379 -0
- code_puppy_core_plugins/puppy_spinner/register_callbacks.py +193 -0
- code_puppy_core_plugins/puppy_spinner/spinners.py +444 -0
- code_puppy_core_plugins/quick_resume/__init__.py +0 -0
- code_puppy_core_plugins/quick_resume/register_callbacks.py +77 -0
- code_puppy_core_plugins/review_pr/__init__.py +1 -0
- code_puppy_core_plugins/review_pr/register_callbacks.py +162 -0
- code_puppy_core_plugins/shell_safety/__init__.py +6 -0
- code_puppy_core_plugins/shell_safety/agent_shell_safety.py +69 -0
- code_puppy_core_plugins/shell_safety/command_cache.py +156 -0
- code_puppy_core_plugins/shell_safety/register_callbacks.py +203 -0
- code_puppy_core_plugins/stack_dump/__init__.py +1 -0
- code_puppy_core_plugins/stack_dump/register_callbacks.py +79 -0
- code_puppy_core_plugins/statusline/__init__.py +14 -0
- code_puppy_core_plugins/statusline/config.py +68 -0
- code_puppy_core_plugins/statusline/payload.py +138 -0
- code_puppy_core_plugins/statusline/prompt_patch.py +76 -0
- code_puppy_core_plugins/statusline/register_callbacks.py +45 -0
- code_puppy_core_plugins/statusline/runner.py +122 -0
- code_puppy_core_plugins/statusline/statusline_command.py +197 -0
- code_puppy_core_plugins/steer_queue/__init__.py +10 -0
- code_puppy_core_plugins/steer_queue/queue_menu.py +444 -0
- code_puppy_core_plugins/steer_queue/register_callbacks.py +138 -0
- code_puppy_core_plugins/subagent_panel/README.md +102 -0
- code_puppy_core_plugins/subagent_panel/__init__.py +24 -0
- code_puppy_core_plugins/subagent_panel/coalesce_patch.py +242 -0
- code_puppy_core_plugins/subagent_panel/panel_render.py +145 -0
- code_puppy_core_plugins/subagent_panel/register_callbacks.py +535 -0
- code_puppy_core_plugins/subagent_panel/resume_repaint.py +112 -0
- code_puppy_core_plugins/subagent_panel/state.py +231 -0
- code_puppy_core_plugins/switch_agent_resume/__init__.py +5 -0
- code_puppy_core_plugins/switch_agent_resume/register_callbacks.py +314 -0
- code_puppy_core_plugins/theme/README.md +86 -0
- code_puppy_core_plugins/theme/__init__.py +14 -0
- code_puppy_core_plugins/theme/bundled_palettes.py +346 -0
- code_puppy_core_plugins/theme/content_styles.py +146 -0
- code_puppy_core_plugins/theme/osc_palette.py +178 -0
- code_puppy_core_plugins/theme/picker.py +358 -0
- code_puppy_core_plugins/theme/prompt_toolkit_theme.py +113 -0
- code_puppy_core_plugins/theme/register_callbacks.py +348 -0
- code_puppy_core_plugins/theme/rich_themes.py +202 -0
- code_puppy_core_plugins/theme/themes.py +720 -0
- code_puppy_core_plugins/timestamp_heartbeat/__init__.py +1 -0
- code_puppy_core_plugins/timestamp_heartbeat/register_callbacks.py +114 -0
- code_puppy_core_plugins/token_ratio_learner/__init__.py +5 -0
- code_puppy_core_plugins/token_ratio_learner/ratios.py +208 -0
- code_puppy_core_plugins/token_ratio_learner/register_callbacks.py +213 -0
- code_puppy_core_plugins/universal_constructor/__init__.py +13 -0
- code_puppy_core_plugins/universal_constructor/models.py +138 -0
- code_puppy_core_plugins/universal_constructor/provider.py +62 -0
- code_puppy_core_plugins/universal_constructor/register_callbacks.py +75 -0
- code_puppy_core_plugins/universal_constructor/registry.py +302 -0
- code_puppy_core_plugins/universal_constructor/sandbox.py +584 -0
- code_puppy_core_plugins/wide_completion_menu/__init__.py +6 -0
- code_puppy_core_plugins/wide_completion_menu/register_callbacks.py +165 -0
- code_puppy_core_plugins/wiggum/__init__.py +1 -0
- code_puppy_core_plugins/wiggum/goal_runs.py +91 -0
- code_puppy_core_plugins/wiggum/judge.py +299 -0
- code_puppy_core_plugins/wiggum/judge_config.py +249 -0
- code_puppy_core_plugins/wiggum/judges_menu.py +814 -0
- code_puppy_core_plugins/wiggum/register_callbacks.py +569 -0
- code_puppy_core_plugins/wiggum/state.py +89 -0
- code_puppy_core_plugins/yolo_cli/__init__.py +1 -0
- code_puppy_core_plugins/yolo_cli/register_callbacks.py +41 -0
- code_puppy_core_plugins-0.0.2.dist-info/METADATA +64 -0
- code_puppy_core_plugins-0.0.2.dist-info/RECORD +313 -0
- code_puppy_core_plugins-0.0.2.dist-info/WHEEL +4 -0
- code_puppy_core_plugins-0.0.2.dist-info/entry_points.txt +55 -0
- code_puppy_core_plugins-0.0.2.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""AWS Bedrock Plugin for Code Puppy.
|
|
2
|
+
|
|
3
|
+
This plugin enables Code Puppy to use Anthropic Claude models hosted on
|
|
4
|
+
AWS Bedrock with standard AWS credential chain authentication (env vars,
|
|
5
|
+
profiles, IAM roles, SSO).
|
|
6
|
+
|
|
7
|
+
Supported models:
|
|
8
|
+
- Claude Opus 4.7 (1M context)
|
|
9
|
+
- Claude Opus 4.6 (1M context)
|
|
10
|
+
- Claude Sonnet 4.6 (1M context)
|
|
11
|
+
- Claude Haiku 4.5 (200K context)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""Configuration constants for the AWS Bedrock plugin."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import functools
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from code_puppy.config import DATA_DIR
|
|
10
|
+
|
|
11
|
+
ENV_AWS_REGION = "AWS_REGION"
|
|
12
|
+
ENV_AWS_PROFILE = "AWS_PROFILE"
|
|
13
|
+
ENV_BEDROCK_REGION = "BEDROCK_REGION"
|
|
14
|
+
|
|
15
|
+
DEFAULT_REGION = "us-east-1"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@functools.lru_cache(maxsize=1)
|
|
19
|
+
def _detect_region() -> str | None:
|
|
20
|
+
"""Detect region from boto3 session or EC2 instance metadata.
|
|
21
|
+
|
|
22
|
+
Result is cached for the process lifetime: on non-EC2 hosts with no
|
|
23
|
+
AWS config, the IMDS path below incurs two 1-second timeouts, and
|
|
24
|
+
this function is called on every model instantiation.
|
|
25
|
+
"""
|
|
26
|
+
try:
|
|
27
|
+
import boto3
|
|
28
|
+
|
|
29
|
+
region = boto3.Session().region_name
|
|
30
|
+
if region:
|
|
31
|
+
return region
|
|
32
|
+
except Exception:
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
import urllib.request
|
|
37
|
+
|
|
38
|
+
token_req = urllib.request.Request(
|
|
39
|
+
"http://169.254.169.254/latest/api/token",
|
|
40
|
+
method="PUT",
|
|
41
|
+
headers={"X-aws-ec2-metadata-token-ttl-seconds": "30"},
|
|
42
|
+
)
|
|
43
|
+
token = urllib.request.urlopen(token_req, timeout=1).read().decode()
|
|
44
|
+
region_req = urllib.request.Request(
|
|
45
|
+
"http://169.254.169.254/latest/meta-data/placement/region",
|
|
46
|
+
headers={"X-aws-ec2-metadata-token": token},
|
|
47
|
+
)
|
|
48
|
+
return urllib.request.urlopen(region_req, timeout=1).read().decode()
|
|
49
|
+
except Exception:
|
|
50
|
+
return None
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
MODELS: list[dict] = [
|
|
54
|
+
{
|
|
55
|
+
"base_key": "bedrock-opus-4-7",
|
|
56
|
+
"model_id": "us.anthropic.claude-opus-4-7",
|
|
57
|
+
"context_length": 1000000,
|
|
58
|
+
"variants": ["default", "low", "medium", "high", "xhigh", "max"],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"base_key": "bedrock-opus-4-6",
|
|
62
|
+
"model_id": "us.anthropic.claude-opus-4-6-v1:0",
|
|
63
|
+
"context_length": 1000000,
|
|
64
|
+
"variants": ["default", "low", "medium", "high", "max"],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"base_key": "bedrock-sonnet-4-6",
|
|
68
|
+
"model_id": "us.anthropic.claude-sonnet-4-6-v1:0",
|
|
69
|
+
"context_length": 1000000,
|
|
70
|
+
"variants": ["default", "low", "medium", "high", "max"],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"base_key": "bedrock-haiku",
|
|
74
|
+
"model_id": "us.anthropic.claude-haiku-4-5-20251001-v1:0",
|
|
75
|
+
"context_length": 200000,
|
|
76
|
+
"variants": None,
|
|
77
|
+
},
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def get_bedrock_region() -> str:
|
|
82
|
+
"""Get the AWS region for Bedrock.
|
|
83
|
+
|
|
84
|
+
Precedence: BEDROCK_REGION > AWS_REGION > boto3 session > default.
|
|
85
|
+
"""
|
|
86
|
+
return (
|
|
87
|
+
os.environ.get(ENV_BEDROCK_REGION)
|
|
88
|
+
or os.environ.get(ENV_AWS_REGION)
|
|
89
|
+
or _detect_region()
|
|
90
|
+
or DEFAULT_REGION
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def get_aws_profile() -> str | None:
|
|
95
|
+
"""Get the AWS profile name from environment."""
|
|
96
|
+
return os.environ.get(ENV_AWS_PROFILE)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def get_extra_models_path() -> Path:
|
|
100
|
+
"""Get the path to the extra_models.json file."""
|
|
101
|
+
return Path(DATA_DIR) / "extra_models.json"
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"""AWS Bedrock Plugin callbacks for Code Puppy CLI.
|
|
2
|
+
|
|
3
|
+
This plugin enables Code Puppy to use Anthropic Claude models hosted on
|
|
4
|
+
AWS Bedrock with standard AWS credential chain authentication.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from code_puppy.callbacks import register_callback
|
|
13
|
+
from code_puppy.messaging import emit_error, emit_info, emit_success, emit_warning
|
|
14
|
+
|
|
15
|
+
from .config import (
|
|
16
|
+
get_aws_profile,
|
|
17
|
+
get_bedrock_region,
|
|
18
|
+
)
|
|
19
|
+
from .utils import (
|
|
20
|
+
add_bedrock_models_to_config,
|
|
21
|
+
get_bedrock_models_from_config,
|
|
22
|
+
remove_bedrock_models_from_config,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# ============================================================================
|
|
29
|
+
# Slash Command Handlers
|
|
30
|
+
# ============================================================================
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _handle_bedrock_status() -> None:
|
|
34
|
+
"""Handle the /bedrock-status command."""
|
|
35
|
+
emit_info("")
|
|
36
|
+
emit_info("AWS Bedrock Status")
|
|
37
|
+
emit_info("=" * 40)
|
|
38
|
+
|
|
39
|
+
region = get_bedrock_region()
|
|
40
|
+
profile = get_aws_profile()
|
|
41
|
+
|
|
42
|
+
emit_info(f"Region: {region}")
|
|
43
|
+
if profile:
|
|
44
|
+
emit_info(f"Profile: {profile}")
|
|
45
|
+
else:
|
|
46
|
+
emit_info("Profile: (default credential chain)")
|
|
47
|
+
|
|
48
|
+
# Check AWS credentials
|
|
49
|
+
try:
|
|
50
|
+
import boto3
|
|
51
|
+
|
|
52
|
+
session = boto3.Session(profile_name=profile, region_name=region)
|
|
53
|
+
sts = session.client("sts")
|
|
54
|
+
identity = sts.get_caller_identity()
|
|
55
|
+
arn = identity.get("Arn", "unknown")
|
|
56
|
+
emit_success(f"Authenticated: {arn}")
|
|
57
|
+
except ImportError:
|
|
58
|
+
emit_warning("boto3 not installed - cannot verify credentials")
|
|
59
|
+
except Exception as e:
|
|
60
|
+
emit_warning(f"Authentication: {e}")
|
|
61
|
+
|
|
62
|
+
emit_info("")
|
|
63
|
+
bedrock_models = get_bedrock_models_from_config()
|
|
64
|
+
if bedrock_models:
|
|
65
|
+
emit_info(f"Configured Models ({len(bedrock_models)}):")
|
|
66
|
+
for model_key, config in bedrock_models.items():
|
|
67
|
+
model_id = config.get("name", "unknown")
|
|
68
|
+
emit_info(f" - {model_key}: {model_id}")
|
|
69
|
+
else:
|
|
70
|
+
emit_info("Configured Models: None")
|
|
71
|
+
emit_info(" Run /bedrock-setup to configure models")
|
|
72
|
+
|
|
73
|
+
emit_info("")
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _handle_bedrock_setup() -> None:
|
|
77
|
+
"""Handle the /bedrock-setup command.
|
|
78
|
+
|
|
79
|
+
Region and credentials auto-resolve from the AWS environment
|
|
80
|
+
(IAM role, env vars, ~/.aws/config). No prompts needed.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
added_models = add_bedrock_models_to_config(
|
|
84
|
+
aws_region=get_bedrock_region(),
|
|
85
|
+
aws_profile=get_aws_profile(),
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
if added_models:
|
|
89
|
+
emit_success(f"Bedrock: added {len(added_models)} model(s):")
|
|
90
|
+
for model_key in added_models:
|
|
91
|
+
emit_info(f" - {model_key}")
|
|
92
|
+
|
|
93
|
+
from code_puppy.model_switching import set_model_and_reload_agent
|
|
94
|
+
|
|
95
|
+
set_model_and_reload_agent("bedrock-opus-4-7")
|
|
96
|
+
emit_info("Switched to bedrock-opus-4-7.")
|
|
97
|
+
else:
|
|
98
|
+
emit_warning("Bedrock: no models added — check configuration.")
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _handle_bedrock_remove() -> None:
|
|
102
|
+
"""Handle the /bedrock-remove command."""
|
|
103
|
+
removed = remove_bedrock_models_from_config()
|
|
104
|
+
if removed:
|
|
105
|
+
emit_success(f"Removed {len(removed)} Bedrock model(s):")
|
|
106
|
+
for model_key in removed:
|
|
107
|
+
emit_info(f" - {model_key}")
|
|
108
|
+
else:
|
|
109
|
+
emit_info("No Bedrock models found in configuration.")
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# ============================================================================
|
|
113
|
+
# Custom Command Registration
|
|
114
|
+
# ============================================================================
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _custom_help() -> list[tuple[str, str]]:
|
|
118
|
+
"""Return help entries for custom commands."""
|
|
119
|
+
return [
|
|
120
|
+
("bedrock-status", "Check AWS Bedrock authentication and configuration"),
|
|
121
|
+
("bedrock-setup", "Auto-configure Bedrock Claude models"),
|
|
122
|
+
("bedrock-remove", "Remove all Bedrock model configurations"),
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _handle_custom_command(command: str, name: str) -> bool | None:
|
|
127
|
+
"""Handle custom slash commands for the AWS Bedrock plugin."""
|
|
128
|
+
handlers = {
|
|
129
|
+
"bedrock-status": _handle_bedrock_status,
|
|
130
|
+
"bedrock-setup": _handle_bedrock_setup,
|
|
131
|
+
"bedrock-remove": _handle_bedrock_remove,
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
handler = handlers.get(name)
|
|
135
|
+
if handler is None:
|
|
136
|
+
return None
|
|
137
|
+
|
|
138
|
+
try:
|
|
139
|
+
handler()
|
|
140
|
+
return True
|
|
141
|
+
except Exception as e:
|
|
142
|
+
logger.exception("Error handling /%s command: %s", name, e)
|
|
143
|
+
emit_error(f"Command /{name} failed: {e}")
|
|
144
|
+
return True
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
# ============================================================================
|
|
148
|
+
# Model Type Handler
|
|
149
|
+
# ============================================================================
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _create_aws_bedrock_model(model_name: str, model_config: dict, config: dict) -> Any:
|
|
153
|
+
"""Create an AWS Bedrock model instance.
|
|
154
|
+
|
|
155
|
+
Uses AsyncAnthropicBedrock from the anthropic SDK with standard
|
|
156
|
+
AWS credential chain (env vars, profiles, IAM roles, SSO).
|
|
157
|
+
"""
|
|
158
|
+
try:
|
|
159
|
+
from anthropic import AsyncAnthropicBedrock
|
|
160
|
+
from pydantic_ai.models.anthropic import AnthropicModel
|
|
161
|
+
except ImportError as e:
|
|
162
|
+
emit_error(
|
|
163
|
+
f"Failed to create Bedrock model '{model_name}': Missing dependency - {e}"
|
|
164
|
+
)
|
|
165
|
+
return None
|
|
166
|
+
|
|
167
|
+
from code_puppy.claude_cache_client import patch_anthropic_client_messages
|
|
168
|
+
from code_puppy.config import get_effective_model_settings
|
|
169
|
+
from code_puppy.model_factory import CONTEXT_1M_BETA
|
|
170
|
+
from code_puppy.provider_identity import (
|
|
171
|
+
make_anthropic_provider,
|
|
172
|
+
resolve_provider_identity,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
model_id = model_config.get("name")
|
|
176
|
+
if not model_id:
|
|
177
|
+
emit_warning(f"Model ID not specified for '{model_name}'.")
|
|
178
|
+
return None
|
|
179
|
+
|
|
180
|
+
try:
|
|
181
|
+
effective_settings = get_effective_model_settings(model_name)
|
|
182
|
+
interleaved_thinking = effective_settings.get("interleaved_thinking", True)
|
|
183
|
+
|
|
184
|
+
beta_parts: list[str] = []
|
|
185
|
+
if interleaved_thinking:
|
|
186
|
+
beta_parts.append("interleaved-thinking-2025-05-14")
|
|
187
|
+
|
|
188
|
+
context_length = model_config.get("context_length", 200000)
|
|
189
|
+
if context_length >= 1_000_000:
|
|
190
|
+
beta_parts.append(CONTEXT_1M_BETA)
|
|
191
|
+
|
|
192
|
+
default_headers: dict[str, str] | None = None
|
|
193
|
+
if beta_parts:
|
|
194
|
+
default_headers = {"anthropic-beta": ",".join(beta_parts)}
|
|
195
|
+
|
|
196
|
+
client_kwargs: dict[str, Any] = {
|
|
197
|
+
"aws_region": model_config.get("aws_region") or get_bedrock_region(),
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
aws_profile = model_config.get("aws_profile") or get_aws_profile()
|
|
201
|
+
if aws_profile:
|
|
202
|
+
client_kwargs["aws_profile"] = aws_profile
|
|
203
|
+
|
|
204
|
+
if default_headers:
|
|
205
|
+
client_kwargs["default_headers"] = default_headers
|
|
206
|
+
|
|
207
|
+
anthropic_client = AsyncAnthropicBedrock(**client_kwargs)
|
|
208
|
+
|
|
209
|
+
patch_anthropic_client_messages(anthropic_client)
|
|
210
|
+
|
|
211
|
+
provider_identity = resolve_provider_identity(model_name, model_config)
|
|
212
|
+
provider = make_anthropic_provider(
|
|
213
|
+
provider_identity,
|
|
214
|
+
anthropic_client=anthropic_client,
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
model = AnthropicModel(model_name=model_id, provider=provider)
|
|
218
|
+
logger.info(
|
|
219
|
+
"Created Bedrock model: %s -> %s @ %s",
|
|
220
|
+
model_name,
|
|
221
|
+
model_id,
|
|
222
|
+
client_kwargs.get("aws_region", "auto"),
|
|
223
|
+
)
|
|
224
|
+
return model
|
|
225
|
+
|
|
226
|
+
except Exception as e:
|
|
227
|
+
emit_error(f"Failed to create Bedrock model '{model_name}': {e}")
|
|
228
|
+
logger.exception("Error creating Bedrock model: %s", e)
|
|
229
|
+
return None
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _register_model_types() -> list[dict[str, Any]]:
|
|
233
|
+
"""Register the aws_bedrock model type handler."""
|
|
234
|
+
return [{"type": "aws_bedrock", "handler": _create_aws_bedrock_model}]
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
# ============================================================================
|
|
238
|
+
# Callback Registration
|
|
239
|
+
# ============================================================================
|
|
240
|
+
|
|
241
|
+
register_callback("custom_command_help", _custom_help)
|
|
242
|
+
register_callback("custom_command", _handle_custom_command)
|
|
243
|
+
register_callback("register_model_type", _register_model_types)
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"""Utility functions for the AWS Bedrock plugin."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import logging
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from code_puppy import atomic_io, atomic_json
|
|
10
|
+
|
|
11
|
+
from .config import (
|
|
12
|
+
MODELS,
|
|
13
|
+
get_extra_models_path,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def load_extra_models() -> dict[str, Any]:
|
|
20
|
+
"""Load the extra_models.json configuration file.
|
|
21
|
+
|
|
22
|
+
Bounded and lock-aware via :mod:`code_puppy.atomic_json` -- a large or
|
|
23
|
+
concurrently-being-written file can no longer balloon memory or read a
|
|
24
|
+
torn write. Preserves the original never-raise contract: any failure
|
|
25
|
+
(missing file, invalid JSON, oversized file, I/O error) logs and
|
|
26
|
+
returns ``{}`` rather than propagating.
|
|
27
|
+
"""
|
|
28
|
+
extra_models_path = str(get_extra_models_path())
|
|
29
|
+
try:
|
|
30
|
+
return atomic_json.load_json(extra_models_path, default={})
|
|
31
|
+
except (atomic_json.JsonFileCorrupt, OSError) as e:
|
|
32
|
+
logger.error("Error loading extra_models.json: %s", e)
|
|
33
|
+
return {}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def save_extra_models(models: dict[str, Any]) -> bool:
|
|
37
|
+
"""Save model configurations to extra_models.json (atomic, locked write)."""
|
|
38
|
+
extra_models_path = str(get_extra_models_path())
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
with atomic_io.path_lock(extra_models_path):
|
|
42
|
+
atomic_io.atomic_write_bytes(
|
|
43
|
+
extra_models_path,
|
|
44
|
+
json.dumps(models, indent=2, ensure_ascii=False).encode("utf-8"),
|
|
45
|
+
)
|
|
46
|
+
return True
|
|
47
|
+
except Exception as e:
|
|
48
|
+
logger.error("Error saving extra_models.json: %s", e)
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _build_model_entry(
|
|
53
|
+
model_id: str,
|
|
54
|
+
context_length: int,
|
|
55
|
+
has_effort: bool,
|
|
56
|
+
effort: str | None = None,
|
|
57
|
+
aws_region: str | None = None,
|
|
58
|
+
aws_profile: str | None = None,
|
|
59
|
+
) -> dict[str, Any]:
|
|
60
|
+
"""Build a single model config entry for extra_models.json."""
|
|
61
|
+
supported_settings = [
|
|
62
|
+
"temperature",
|
|
63
|
+
"extended_thinking",
|
|
64
|
+
"budget_tokens",
|
|
65
|
+
"interleaved_thinking",
|
|
66
|
+
]
|
|
67
|
+
if has_effort:
|
|
68
|
+
supported_settings.append("effort")
|
|
69
|
+
|
|
70
|
+
config: dict[str, Any] = {
|
|
71
|
+
"type": "aws_bedrock",
|
|
72
|
+
"provider": "aws_bedrock",
|
|
73
|
+
"name": model_id,
|
|
74
|
+
"context_length": context_length,
|
|
75
|
+
"supported_settings": supported_settings,
|
|
76
|
+
}
|
|
77
|
+
if effort:
|
|
78
|
+
config["default_effort"] = effort
|
|
79
|
+
if aws_region:
|
|
80
|
+
config["aws_region"] = aws_region
|
|
81
|
+
if aws_profile:
|
|
82
|
+
config["aws_profile"] = aws_profile
|
|
83
|
+
|
|
84
|
+
return config
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def add_bedrock_models_to_config(
|
|
88
|
+
aws_region: str | None = None,
|
|
89
|
+
aws_profile: str | None = None,
|
|
90
|
+
) -> list[str]:
|
|
91
|
+
"""Add Bedrock model configurations (with effort variants) to extra_models.json.
|
|
92
|
+
|
|
93
|
+
Uses :func:`code_puppy.atomic_json.mutate_json` so the read and write
|
|
94
|
+
happen inside one locked transaction -- extra_models.json is also
|
|
95
|
+
touched by add_model_menu.py and the ollama_setup/azure_foundry
|
|
96
|
+
plugins, so a read-then-write split across two unlocked calls could
|
|
97
|
+
lose one of those concurrent updates.
|
|
98
|
+
"""
|
|
99
|
+
entries: dict[str, dict[str, Any]] = {}
|
|
100
|
+
for spec in MODELS:
|
|
101
|
+
base_key = spec["base_key"]
|
|
102
|
+
model_id = spec["model_id"]
|
|
103
|
+
context_length = spec["context_length"]
|
|
104
|
+
variants = spec.get("variants")
|
|
105
|
+
|
|
106
|
+
if variants:
|
|
107
|
+
for variant in variants:
|
|
108
|
+
if variant == "default":
|
|
109
|
+
key = base_key
|
|
110
|
+
effort = None
|
|
111
|
+
else:
|
|
112
|
+
key = f"{base_key}-{variant}"
|
|
113
|
+
effort = variant
|
|
114
|
+
|
|
115
|
+
entries[key] = _build_model_entry(
|
|
116
|
+
model_id=model_id,
|
|
117
|
+
context_length=context_length,
|
|
118
|
+
has_effort=True,
|
|
119
|
+
effort=effort,
|
|
120
|
+
aws_region=aws_region,
|
|
121
|
+
aws_profile=aws_profile,
|
|
122
|
+
)
|
|
123
|
+
else:
|
|
124
|
+
entries[base_key] = _build_model_entry(
|
|
125
|
+
model_id=model_id,
|
|
126
|
+
context_length=context_length,
|
|
127
|
+
has_effort=False,
|
|
128
|
+
aws_region=aws_region,
|
|
129
|
+
aws_profile=aws_profile,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
if not entries:
|
|
133
|
+
return []
|
|
134
|
+
|
|
135
|
+
def _mutate(models: dict[str, Any]) -> dict[str, Any]:
|
|
136
|
+
models.update(entries)
|
|
137
|
+
return models
|
|
138
|
+
|
|
139
|
+
extra_models_path = str(get_extra_models_path())
|
|
140
|
+
try:
|
|
141
|
+
atomic_json.mutate_json(extra_models_path, _mutate, default={})
|
|
142
|
+
except (atomic_json.JsonFileCorrupt, OSError) as e:
|
|
143
|
+
logger.error("Error saving extra_models.json: %s", e)
|
|
144
|
+
return []
|
|
145
|
+
|
|
146
|
+
return list(entries.keys())
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def remove_bedrock_models_from_config() -> list[str]:
|
|
150
|
+
"""Remove all Bedrock model configurations from extra_models.json.
|
|
151
|
+
|
|
152
|
+
Uses :func:`code_puppy.atomic_json.mutate_json` so the read and write
|
|
153
|
+
happen inside one locked transaction (see :func:`add_bedrock_models_to_config`).
|
|
154
|
+
"""
|
|
155
|
+
extra_models_path = str(get_extra_models_path())
|
|
156
|
+
removed: list[str] = []
|
|
157
|
+
|
|
158
|
+
def _mutate(models: dict[str, Any]) -> dict[str, Any]:
|
|
159
|
+
removed[:] = [
|
|
160
|
+
key
|
|
161
|
+
for key, cfg in models.items()
|
|
162
|
+
if isinstance(cfg, dict) and cfg.get("type") == "aws_bedrock"
|
|
163
|
+
]
|
|
164
|
+
for key in removed:
|
|
165
|
+
del models[key]
|
|
166
|
+
return models
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
atomic_json.mutate_json(extra_models_path, _mutate, default={})
|
|
170
|
+
except (atomic_json.JsonFileCorrupt, OSError) as e:
|
|
171
|
+
logger.error(
|
|
172
|
+
"Failed to save extra_models.json after removing Bedrock models: %s", e
|
|
173
|
+
)
|
|
174
|
+
return []
|
|
175
|
+
|
|
176
|
+
return removed
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def get_bedrock_models_from_config() -> dict[str, Any]:
|
|
180
|
+
"""Get all Bedrock model configurations from extra_models.json."""
|
|
181
|
+
models = load_extra_models()
|
|
182
|
+
return {
|
|
183
|
+
key: cfg
|
|
184
|
+
for key, cfg in models.items()
|
|
185
|
+
if isinstance(cfg, dict) and cfg.get("type") == "aws_bedrock"
|
|
186
|
+
}
|