code-puppy 0.0.948__tar.gz → 0.0.950__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {code_puppy-0.0.948 → code_puppy-0.0.950}/PKG-INFO +5 -5
- {code_puppy-0.0.948 → code_puppy-0.0.950}/README.md +1 -1
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_builder.py +3 -1
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_code_mode.py +4 -4
- code_puppy-0.0.950/code_puppy/agents/_code_mode_session.py +80 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_history.py +3 -1
- code_puppy-0.0.950/code_puppy/agents/_model_message_transform.py +158 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/claude_cache_client.py +2 -2
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/file_index.py +23 -6
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/file_path_completion.py +15 -10
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/gemini_code_assist.py +9 -2
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/gemini_common.py +17 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/gemini_model.py +3 -29
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/model_factory.py +4 -25
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/model_utils.py +0 -36
- {code_puppy-0.0.948 → code_puppy-0.0.950}/pyproject.toml +5 -5
- code_puppy-0.0.948/code_puppy/agents/_code_mode_session.py +0 -183
- code_puppy-0.0.948/code_puppy/agents/_model_message_transform.py +0 -130
- {code_puppy-0.0.948 → code_puppy-0.0.950}/.gitignore +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/LICENSE +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/__main__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/_plugin_i18n_lifecycle.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/_pydantic_tool_helpers.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/_pydantic_video_patch.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agent_completion_inbox.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agent_execution_context.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_code_mode_guidance.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_compaction.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_diagnostics.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_foreign_thinking.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_key_listeners.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_mcp.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_multimodal_error_hint.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_non_streaming_render.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_output_limits.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_rules.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_run_signals.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_runtime.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_steer_processor.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_subagent_recursion.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_token_limit_hint.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_tty_modes.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_windows_console.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/_wire_tool_names.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/agent_code_puppy.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/agent_creator_agent.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/agent_helios.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/agent_manager.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/agent_model_judge.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/agent_planning.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/agent_qa_kitten.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/agent_web_retriever.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/base_agent.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/event_stream_handler.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/json_agent.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/retry_checkpoint.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/retry_profiles.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/run_invocation.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/run_stats.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/smooth_stream.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/stream_status.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/subagent_stream_handler.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/agents/thinking_output.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/asyncio_cleanup.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/atomic_io.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/atomic_json.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/ca_bundle.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/callbacks.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/capabilities/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/capabilities/compaction.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/capabilities/eager_timing.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/chatgpt_codex_client.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/claude_oauth_transport.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/claude_thinking_display.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/cli_runner.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/add_model_details.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/add_model_menu.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/add_model_menus.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/add_model_vllm.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/agent_menu.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/attachments.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/autosave_menu.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/autosave_search.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/clipboard.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/colors_menu.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/command_handler.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/command_registry.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/completers.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/completion_cache.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/config_apply.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/config_commands.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/core_commands.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/help_catalog.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/help_overlay.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/image_utils.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/load_context_completion.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/base.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/catalog_server_installer.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/custom_server_form.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/custom_server_installer.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/edit_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/handler.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/help_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/install_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/install_menu.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/list_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/logs_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/mcp_servers_store.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/remove_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/restart_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/search_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/silence_warning_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/start_all_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/start_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/status_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/stop_all_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/stop_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/trust_command.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/utils.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp/wizard_utils.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp_binding_menu.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/mcp_completion.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/menu_session.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/model_picker_completion.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/model_settings_defs.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/model_settings_menu.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/onboarding_slides.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/onboarding_wizard.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/pagination.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/pin_command_completion.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/refresh_models.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/session_browser.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/session_browser_data.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/session_commands.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/set_menu.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/set_menu_catalog.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/set_menu_schema.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/set_menu_settings.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/set_menu_shims.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/set_menu_values.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/shell_passthrough.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/skills_completion.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/tui_style.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/uc_menu.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/command_line/utils.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/config.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/config_file.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/context_accounting.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/diagnostics.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/error_logging.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/events/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/events/bridge.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/file_completion_io.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/file_completion_tokens.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/hook_engine/README.md +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/hook_engine/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/hook_engine/aliases.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/hook_engine/engine.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/hook_engine/executor.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/hook_engine/matcher.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/hook_engine/models.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/hook_engine/registry.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/hook_engine/validator.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/http_retry.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/http_utils.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/httpx2_utils.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/audit.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/catalog.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/formats.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/interpolation.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/locale.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/locales/en-US.json +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/locales/es.json +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/locales/fr-CA.json +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/plugin_catalog.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/plurals.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/pseudo.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/i18n/translate.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/kennel_provider.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/keymap.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/list_filtering.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/main.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/malloc_noise_guard.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/agent_bindings.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/async_lifecycle.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/blocking_startup.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/circuit_breaker.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/config_wizard.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/dashboard.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/error_isolation.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/examples/retry_example.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/health_monitor.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/http_auth.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/managed_server.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/manager.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/manager_lifecycle.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/mcp_logs.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/project_config.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/registry.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/retry_manager.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/server_registry_catalog.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/status_tracker.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/system_tools.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/tool_arg_coercion.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_/toolset_utils.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_prompts/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/mcp_prompts/hook_creator.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/bar_painters.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/bar_rendering.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/bottom_bar.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/bus.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/chords.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/commands.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/editor_actions.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/editor_completion.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/editor_display.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/editor_history.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/editor_keys.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/editor_paste.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/editor_queue.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/editor_submission.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/editor_undo.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/external_editor.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/identity_line.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/idle_status.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/inline_bar.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/line_editor.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/markdown_patches.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/menu_lifecycle.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/message_queue.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/messages.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/pause_controller.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/prompt_prefix_style.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/queue_console.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/renderers.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/rich_renderer.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/run_ui.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/run_ui_wiring.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/safe_console.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/safe_stream.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/speculation_line.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/speculation_stats.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/speculation_toggle.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/spinner/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/status_line.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/subagent_console.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/theme_accent.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/tool_output.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/messaging/transcript_guard.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/model_descriptions.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/model_switching.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/models.json +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/models_dev_api.json +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/models_dev_family.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/models_dev_parser.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/observability.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/platform_utils.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/plugins/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/plugins/config.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/plugins/oauth_pasteback.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/plugins/oauth_puppy_html.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/plugins/trust.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/plugins/trust_notice.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/private_inference.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/provider_credentials.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/provider_identity.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/pydantic_patches.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/reopenable_async_client.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/round_robin_model.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/secret_store.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/secret_store_backends.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/session_format_migration.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/session_lifecycle.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/session_migration.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/session_storage.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/session_surrogate_unpickler.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/shared_credentials.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/skill_provider.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/splash.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/status_display.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/steer_metadata.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/terminal_utils.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/token_usage.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/_browser_registry.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/_lazy.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/agent_tools.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/approval_feedback.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ask_user_question/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ask_user_question/constants.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ask_user_question/demo_tui.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ask_user_question/handler.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ask_user_question/models.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ask_user_question/registration.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ask_user_question/renderers.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ask_user_question/terminal_ui.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ask_user_question/theme.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ask_user_question/tui_loop.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/__init__.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_control.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_interactions.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_locator_resolver.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_locators.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_manager.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_navigation.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_page_snapshot.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_screenshot.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_scripts.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_semantic_interactions.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/browser_workflows.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/browser/tool_registry.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/command_runner.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/common.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/display.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/file_modifications.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/file_operations.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/file_permission_state.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/fs_access.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/image_tools.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/io_backends.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/model_tools.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/ripgrep.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/shell_backgrounding.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/skills_tools.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/subagent_context.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/subagent_invocation.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/subagent_usage_metrics.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/tools_content.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/universal_constructor.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/tools/win_shell_io.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/undo_manager.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/universal_constructor_provider.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/version_checker.py +0 -0
- {code_puppy-0.0.948 → code_puppy-0.0.950}/code_puppy/zai_model.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: code-puppy
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.950
|
|
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
|
|
@@ -32,9 +32,9 @@ Requires-Dist: openai>=2.45.0
|
|
|
32
32
|
Requires-Dist: packaging>=24.0
|
|
33
33
|
Requires-Dist: pillow>=10.0.0
|
|
34
34
|
Requires-Dist: playwright>=1.40.0; sys_platform != 'android'
|
|
35
|
-
Requires-Dist: pydantic-ai-harness[code-mode]==0.
|
|
36
|
-
Requires-Dist: pydantic-ai-slim[anthropic,mcp,openai]==2.
|
|
37
|
-
Requires-Dist: pydantic-monty<1
|
|
35
|
+
Requires-Dist: pydantic-ai-harness[code-mode]==0.62.0
|
|
36
|
+
Requires-Dist: pydantic-ai-slim[anthropic,mcp,openai]==2.62.0
|
|
37
|
+
Requires-Dist: pydantic-monty<2,>=1.0.0
|
|
38
38
|
Requires-Dist: pydantic>=2.4.0
|
|
39
39
|
Requires-Dist: pyfiglet>=0.8.post1
|
|
40
40
|
Requires-Dist: python-dotenv>=1.0.0
|
|
@@ -422,7 +422,7 @@ Use `custom_openai` for OpenAI-compatible Chat Completions endpoints. If an endp
|
|
|
422
422
|
|
|
423
423
|
## Multiple System Messages
|
|
424
424
|
|
|
425
|
-
Custom OpenAI-compatible endpoints (`custom_openai`, `openrouter`, `cerebras`, and Zhipu `zai_coding`/`zai_api`) default to merging consecutive leading `system` messages into one. Strict backends (SGLang, some vLLM deployments) reject more than one leading system message — this surfaces
|
|
425
|
+
Custom OpenAI-compatible endpoints (`custom_openai`, `openrouter`, `cerebras`, and Zhipu `zai_coding`/`zai_api`) default to merging consecutive leading `system` messages into one. Strict backends (SGLang, some vLLM deployments) reject more than one leading system message — this surfaces when the agent's own system instructions are followed by further system prompts (for example from plugins), as a `400: System message must be at the beginning.`
|
|
426
426
|
|
|
427
427
|
The merge is harmless for endpoints that *do* support multiple system messages. If you know your endpoint handles them, opt out per model with `"supports_multiple_system_messages": true` (a JSON boolean):
|
|
428
428
|
|
|
@@ -368,7 +368,7 @@ Use `custom_openai` for OpenAI-compatible Chat Completions endpoints. If an endp
|
|
|
368
368
|
|
|
369
369
|
## Multiple System Messages
|
|
370
370
|
|
|
371
|
-
Custom OpenAI-compatible endpoints (`custom_openai`, `openrouter`, `cerebras`, and Zhipu `zai_coding`/`zai_api`) default to merging consecutive leading `system` messages into one. Strict backends (SGLang, some vLLM deployments) reject more than one leading system message — this surfaces
|
|
371
|
+
Custom OpenAI-compatible endpoints (`custom_openai`, `openrouter`, `cerebras`, and Zhipu `zai_coding`/`zai_api`) default to merging consecutive leading `system` messages into one. Strict backends (SGLang, some vLLM deployments) reject more than one leading system message — this surfaces when the agent's own system instructions are followed by further system prompts (for example from plugins), as a `400: System message must be at the beginning.`
|
|
372
372
|
|
|
373
373
|
The merge is harmless for endpoints that *do* support multiple system messages. If you know your endpoint handles them, opt out per model with `"supports_multiple_system_messages": true` (a JSON boolean):
|
|
374
374
|
|
|
@@ -447,7 +447,9 @@ def build_pydantic_agent(
|
|
|
447
447
|
# ToolOutputLimits reduces oversized tool returns on a different
|
|
448
448
|
# hook (after_tool_execute), so its position is inert; the
|
|
449
449
|
# response clamp runs before_model_request after compaction and
|
|
450
|
-
# steering. The plugin transform
|
|
450
|
+
# steering. The plugin transform is the innermost capability
|
|
451
|
+
# (before_model_request runs it last), so it sees the final
|
|
452
|
+
# compacted, steered request.
|
|
451
453
|
capabilities=[
|
|
452
454
|
*build_tool_output_limits(),
|
|
453
455
|
history_compaction,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Speculative CodeMode capability wiring, switched by one config flag.
|
|
2
2
|
|
|
3
|
-
Uses speculative programmatic tool calling from pydantic-ai-harness
|
|
3
|
+
Uses speculative programmatic tool calling from pydantic-ai-harness.
|
|
4
4
|
|
|
5
5
|
When ``enable_speculative_code_mode`` is on, every agent (main and sub-agent)
|
|
6
6
|
has its whole tool surface, MCP servers and plugin tools included, folded
|
|
@@ -39,7 +39,7 @@ from pydantic_monty import MountDir, OSAccess
|
|
|
39
39
|
from pydantic_ai_harness.code_mode import CodeMode
|
|
40
40
|
|
|
41
41
|
from code_puppy.agents._code_mode_guidance import CodeModeGuidance
|
|
42
|
-
from code_puppy.agents._code_mode_session import
|
|
42
|
+
from code_puppy.agents._code_mode_session import FileReplStore, repl_path_for
|
|
43
43
|
from code_puppy.agents._wire_tool_names import StreamedToolNameNormalizer
|
|
44
44
|
from code_puppy.capabilities.eager_timing import EagerTiming
|
|
45
45
|
from code_puppy.config import get_speculative_code_mode_enabled
|
|
@@ -238,8 +238,8 @@ def build_speculative_code_mode(
|
|
|
238
238
|
workspace = os.getcwd()
|
|
239
239
|
mount_path = sandbox_mount_path(workspace)
|
|
240
240
|
return [
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
CodeMode(
|
|
242
|
+
repl_store=FileReplStore(repl_path) if repl_path is not None else None,
|
|
243
243
|
tools=_sandbox_tool,
|
|
244
244
|
speculate=speculate,
|
|
245
245
|
# Composed tiers: eager runs each streamed statement in the live REPL as it
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Keep the code-mode REPL alive across runs of one session.
|
|
2
|
+
|
|
3
|
+
The harness gives every agent run a fresh Monty REPL, and each user prompt is a
|
|
4
|
+
new run, so variables vanished between turns. Here the idle REPL is saved when
|
|
5
|
+
a run ends and restored when the next run with the same session key starts,
|
|
6
|
+
through the harness's ``CodeModeReplStore`` hook.
|
|
7
|
+
Main-agent state sits beside the autosave as ``<session>_repl.bin``, so
|
|
8
|
+
``/resume`` brings it back and session deletion removes it; a sub-agent's sits
|
|
9
|
+
beside its ``subagent_sessions/<session_id>.json``.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import logging
|
|
15
|
+
import os
|
|
16
|
+
import tempfile
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Callable
|
|
19
|
+
|
|
20
|
+
import anyio
|
|
21
|
+
from pydantic_ai import RunContext
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger(__name__)
|
|
24
|
+
|
|
25
|
+
REPL_SUFFIX = "_repl.bin"
|
|
26
|
+
# A dump holds every live variable; don't write a runaway one to disk.
|
|
27
|
+
MAX_REPL_BYTES = 32 * 1024 * 1024
|
|
28
|
+
|
|
29
|
+
ReplPath = Callable[[], "Path | None"]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def repl_path_for(directory: Path | str, session_key: str) -> Path:
|
|
33
|
+
"""Where the REPL dump for ``session_key`` lives inside ``directory``."""
|
|
34
|
+
return Path(directory) / f"{session_key}{REPL_SUFFIX}"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _write_atomic(path: Path, data: bytes) -> None:
|
|
38
|
+
path.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
39
|
+
fd, tmp = tempfile.mkstemp(dir=path.parent, prefix=f".{path.name}.")
|
|
40
|
+
try:
|
|
41
|
+
with os.fdopen(fd, "wb") as stream:
|
|
42
|
+
stream.write(data)
|
|
43
|
+
os.replace(tmp, path)
|
|
44
|
+
except BaseException:
|
|
45
|
+
Path(tmp).unlink(missing_ok=True)
|
|
46
|
+
raise
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _read(path: Path) -> bytes | None:
|
|
50
|
+
try:
|
|
51
|
+
return path.read_bytes() or None
|
|
52
|
+
except FileNotFoundError:
|
|
53
|
+
return None
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class FileReplStore:
|
|
57
|
+
"""``CodeModeReplStore`` that keeps one REPL state file per session."""
|
|
58
|
+
|
|
59
|
+
def __init__(self, repl_path: ReplPath) -> None:
|
|
60
|
+
self._repl_path = repl_path
|
|
61
|
+
|
|
62
|
+
async def load(self, ctx: RunContext[object]) -> bytes | None:
|
|
63
|
+
path = self._repl_path()
|
|
64
|
+
if path is None:
|
|
65
|
+
return None
|
|
66
|
+
return await anyio.to_thread.run_sync(_read, path)
|
|
67
|
+
|
|
68
|
+
async def save(self, ctx: RunContext[object], state: bytes | None) -> None:
|
|
69
|
+
path = self._repl_path()
|
|
70
|
+
if path is None:
|
|
71
|
+
return
|
|
72
|
+
if state is not None and len(state) > MAX_REPL_BYTES:
|
|
73
|
+
logger.warning(
|
|
74
|
+
"code mode: REPL state is %d bytes; not saving it", len(state)
|
|
75
|
+
)
|
|
76
|
+
state = None
|
|
77
|
+
if state is None:
|
|
78
|
+
await anyio.to_thread.run_sync(lambda: path.unlink(missing_ok=True))
|
|
79
|
+
return
|
|
80
|
+
await anyio.to_thread.run_sync(_write_atomic, path, state)
|
|
@@ -345,7 +345,9 @@ def estimate_context_overhead(
|
|
|
345
345
|
# call/return pairing: tool-call/-return, builtin-tool-call/-return (claude
|
|
346
346
|
# extended-thinking / provider-executed), and retry-prompt (acts as a response
|
|
347
347
|
# only when it is tool-bound — a nameless retry is validation feedback, not a
|
|
348
|
-
# result).
|
|
348
|
+
# result). Since pydantic-ai 2.60 a tool-bound retry is a regular tool-return
|
|
349
|
+
# with ``outcome='retried'``; retry-prompt remains for legacy parts until v3.
|
|
350
|
+
# ``_classify_tool_part`` and these sets describe that full vocabulary
|
|
349
351
|
# for consumers that want every id-bearing part. The repair and
|
|
350
352
|
# pending-detection logic instead uses the narrower ``_is_repairable_*``
|
|
351
353
|
# predicates below, which exclude builtin parts.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Plugin transforms for final outbound model messages."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import replace
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from pydantic_ai import RunContext
|
|
7
|
+
from pydantic_ai.capabilities import (
|
|
8
|
+
CapabilityOrdering,
|
|
9
|
+
Hooks,
|
|
10
|
+
WrapModelRequestHandler,
|
|
11
|
+
)
|
|
12
|
+
from pydantic_ai.messages import ModelMessage, ModelResponse
|
|
13
|
+
from pydantic_ai.models import Model, ModelRequestContext
|
|
14
|
+
from pydantic_ai.models.wrapper import WrapperModel
|
|
15
|
+
|
|
16
|
+
from code_puppy.agents._foreign_thinking import strip_foreign_thinking
|
|
17
|
+
from code_puppy.callbacks import on_transform_model_messages
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class _ContinuationObserver(WrapperModel):
|
|
21
|
+
"""Observe a suspended->continued chain *before* pydantic-ai merges it.
|
|
22
|
+
|
|
23
|
+
``continuation_delay`` runs on intermediate suspended responses before
|
|
24
|
+
their usage can merge. This request-local wrapper preserves the real
|
|
25
|
+
model's delay behavior while marking the final response ineligible for
|
|
26
|
+
a receipt. The framework's durable-execution capabilities use the same
|
|
27
|
+
request-model swap seam. Provider details and billing limitations live
|
|
28
|
+
in ``docs/API_CONTEXT_ACCOUNTING.md``.
|
|
29
|
+
|
|
30
|
+
It also carries this request's accounting state from the
|
|
31
|
+
``before_model_request`` leg to the ``after_model_request`` leg: the
|
|
32
|
+
durable history the request was built from, and its prefix fingerprint.
|
|
33
|
+
``prefix`` is ``None`` when the outbound messages diverged from that
|
|
34
|
+
history, so no anchor is stamped. The model object is the one thing every
|
|
35
|
+
later hook and the core hand on unchanged.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
wrapped: Model,
|
|
41
|
+
*,
|
|
42
|
+
durable_messages: list[ModelMessage],
|
|
43
|
+
prefix: str | None,
|
|
44
|
+
):
|
|
45
|
+
super().__init__(wrapped)
|
|
46
|
+
self.continued = False
|
|
47
|
+
self.durable_messages = durable_messages
|
|
48
|
+
self.prefix = prefix
|
|
49
|
+
|
|
50
|
+
def continuation_delay(self, response: ModelResponse) -> float | None:
|
|
51
|
+
self.continued = True
|
|
52
|
+
return super().continuation_delay(response)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def build_model_message_transform(agent_name: str | None, owner: Any = None) -> Hooks:
|
|
56
|
+
"""Build the request-only plugin transform for an agent.
|
|
57
|
+
|
|
58
|
+
The transform runs in ``before_model_request`` as the innermost
|
|
59
|
+
capability, so it sees what the request really sends: the history after
|
|
60
|
+
compaction and every other ``before_model_request`` rewrite.
|
|
61
|
+
|
|
62
|
+
``owner`` is the Code Puppy agent (or agent-shaped object) whose
|
|
63
|
+
``_context_overhead`` compaction just computed for this same request --
|
|
64
|
+
see ``CodePuppyCompactionStore.context_overhead``. Passing it lets the
|
|
65
|
+
stamped receipt record the *exact* overhead the compaction trigger used,
|
|
66
|
+
so the next request's ``context_tokens`` call reconstructs the same
|
|
67
|
+
total instead of silently drifting by whatever overhead changed between
|
|
68
|
+
the two reads. ``None`` (sub-agents/tests that don't wire one) just
|
|
69
|
+
stamps ``overhead=0``, which only costs an extra estimate on that one
|
|
70
|
+
anchor -- never a wrong total, because ``context_tokens`` always folds
|
|
71
|
+
the caller's *current* overhead back in.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
async def prepare(
|
|
75
|
+
_ctx: RunContext[Any], request_context: ModelRequestContext
|
|
76
|
+
) -> ModelRequestContext:
|
|
77
|
+
from code_puppy.context_accounting import fingerprint
|
|
78
|
+
|
|
79
|
+
durable_messages = list(request_context.messages)
|
|
80
|
+
# Snapshot *before* anything can touch the messages. strip_foreign_thinking
|
|
81
|
+
# is a no-op pass-through for non-Anthropic models (same list AND same
|
|
82
|
+
# message objects by reference, not a copy) -- so a plugin transform
|
|
83
|
+
# that mutates in place would otherwise mutate ``durable_messages`` too,
|
|
84
|
+
# and a fingerprint taken afterwards would never see the divergence.
|
|
85
|
+
original_fingerprint = fingerprint(durable_messages)
|
|
86
|
+
|
|
87
|
+
outbound = strip_foreign_thinking(list(durable_messages), request_context.model)
|
|
88
|
+
await on_transform_model_messages(agent_name, outbound)
|
|
89
|
+
|
|
90
|
+
# The anchor must describe what the *durable history* looked like,
|
|
91
|
+
# because that's what next turn's ``context_tokens`` re-fingerprints
|
|
92
|
+
# against. If anything between the snapshot above and the model call
|
|
93
|
+
# -- the built-in foreign-thinking strip, or a plugin's rewrite, in
|
|
94
|
+
# place or not -- changed what's actually sent, the response's usage no
|
|
95
|
+
# longer describes ``durable_messages`` and must not anchor it.
|
|
96
|
+
prefix = original_fingerprint
|
|
97
|
+
if fingerprint(outbound) != prefix:
|
|
98
|
+
prefix = None
|
|
99
|
+
|
|
100
|
+
# Wrap *after* the fingerprint check above (which needs the real
|
|
101
|
+
# model for foreign-thinking detection), so the continuation loop
|
|
102
|
+
# inside the core drives this wrapper's `continuation_delay`.
|
|
103
|
+
observer = _ContinuationObserver(
|
|
104
|
+
request_context.model, durable_messages=durable_messages, prefix=prefix
|
|
105
|
+
)
|
|
106
|
+
return replace(request_context, messages=outbound, model=observer)
|
|
107
|
+
|
|
108
|
+
async def invalidate_on_failure(
|
|
109
|
+
_ctx: RunContext[Any],
|
|
110
|
+
*,
|
|
111
|
+
request_context: ModelRequestContext,
|
|
112
|
+
handler: WrapModelRequestHandler,
|
|
113
|
+
) -> ModelResponse:
|
|
114
|
+
# ``on_model_request_error`` only sees failures of the core call;
|
|
115
|
+
# failures of other hooks and cancellation reach only a wrapper.
|
|
116
|
+
try:
|
|
117
|
+
return await handler(request_context)
|
|
118
|
+
except BaseException:
|
|
119
|
+
from code_puppy.context_accounting import invalidate_anchors
|
|
120
|
+
|
|
121
|
+
observer = request_context.model
|
|
122
|
+
invalidate_anchors(
|
|
123
|
+
observer.durable_messages
|
|
124
|
+
if isinstance(observer, _ContinuationObserver)
|
|
125
|
+
else request_context.messages
|
|
126
|
+
)
|
|
127
|
+
raise
|
|
128
|
+
|
|
129
|
+
async def stamp(
|
|
130
|
+
_ctx: RunContext[Any],
|
|
131
|
+
*,
|
|
132
|
+
request_context: ModelRequestContext,
|
|
133
|
+
response: ModelResponse,
|
|
134
|
+
) -> ModelResponse:
|
|
135
|
+
from code_puppy.context_accounting import model_names, record_anchor
|
|
136
|
+
|
|
137
|
+
observer = request_context.model
|
|
138
|
+
if not isinstance(observer, _ContinuationObserver):
|
|
139
|
+
return response
|
|
140
|
+
# Usage on a continued response is a cumulative sum across segments,
|
|
141
|
+
# not one measured prompt -- decline to anchor it. Billing/usage
|
|
142
|
+
# itself is untouched; only our own receipt is suppressed.
|
|
143
|
+
if observer.prefix is not None and not observer.continued:
|
|
144
|
+
record_anchor(
|
|
145
|
+
observer.durable_messages,
|
|
146
|
+
response,
|
|
147
|
+
context_overhead=getattr(owner, "_context_overhead", 0),
|
|
148
|
+
prefix=observer.prefix,
|
|
149
|
+
request_model=model_names(observer.wrapped),
|
|
150
|
+
)
|
|
151
|
+
return response
|
|
152
|
+
|
|
153
|
+
return Hooks(
|
|
154
|
+
before_model_request=prepare,
|
|
155
|
+
model_request=invalidate_on_failure,
|
|
156
|
+
after_model_request=stamp,
|
|
157
|
+
ordering=CapabilityOrdering(position="innermost"),
|
|
158
|
+
)
|
|
@@ -147,8 +147,8 @@ class ClaudeCacheAsyncClient(ClaudeOAuthTransport, httpx2.AsyncClient):
|
|
|
147
147
|
text = first.get("text") if isinstance(first, dict) else None
|
|
148
148
|
if text == CLAUDE_CODE_SYSTEM_PROMPT:
|
|
149
149
|
return None
|
|
150
|
-
#
|
|
151
|
-
#
|
|
150
|
+
# Adjacent system prompts can be joined to the signature by the
|
|
151
|
+
# SDK. A matching prefix is not a standalone identity block.
|
|
152
152
|
# Keep metadata (including cache_control) on the remainder so its
|
|
153
153
|
# cache boundary still follows all the original content.
|
|
154
154
|
if isinstance(text, str) and text.startswith(CLAUDE_CODE_SYSTEM_PROMPT):
|
|
@@ -20,7 +20,7 @@ import os
|
|
|
20
20
|
import threading
|
|
21
21
|
import time
|
|
22
22
|
from dataclasses import dataclass, field
|
|
23
|
-
from typing import List, Optional
|
|
23
|
+
from typing import Iterable, List, Optional
|
|
24
24
|
|
|
25
25
|
# Cap so we don't blow up RAM on absurdly huge repos. 200k paths is plenty
|
|
26
26
|
# for fuzzy ranking; anything beyond that is almost certainly noise.
|
|
@@ -34,8 +34,9 @@ class Index:
|
|
|
34
34
|
|
|
35
35
|
root: str
|
|
36
36
|
paths: tuple[str, ...] = field(default_factory=tuple)
|
|
37
|
-
lowered: tuple[str, ...] = field(default_factory=tuple)
|
|
38
37
|
basenames_lower: tuple[str, ...] = field(default_factory=tuple)
|
|
38
|
+
dirs: tuple[str, ...] = field(default_factory=tuple)
|
|
39
|
+
dir_basenames_lower: tuple[str, ...] = field(default_factory=tuple)
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
_EMPTY_INDEX = Index(root="")
|
|
@@ -126,16 +127,32 @@ def _run_ripgrep(root: str) -> Optional[List[str]]:
|
|
|
126
127
|
return read_paths(rg, root, MAX_INDEXED_PATHS, INDEX_BUILD_TIMEOUT_SECONDS)
|
|
127
128
|
|
|
128
129
|
|
|
130
|
+
def _ancestor_dirs(paths: Iterable[str]) -> List[str]:
|
|
131
|
+
# rg --files emits files only; every ancestor of an emitted file is a
|
|
132
|
+
# non-ignored directory, so this inherits rg's ignore rules for free.
|
|
133
|
+
found: set[str] = set()
|
|
134
|
+
for path in paths:
|
|
135
|
+
parent = os.path.dirname(path)
|
|
136
|
+
while parent and parent not in found:
|
|
137
|
+
found.add(parent)
|
|
138
|
+
parent = os.path.dirname(parent)
|
|
139
|
+
return sorted(found)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _basenames_lower(paths: Iterable[str]) -> tuple[str, ...]:
|
|
143
|
+
return tuple(os.path.basename(p).lower() for p in paths)
|
|
144
|
+
|
|
145
|
+
|
|
129
146
|
def _make_index(root: str, paths: List[str]) -> Index:
|
|
130
147
|
# Normalize once up front so every fuzzy lookup is a cheap tuple read.
|
|
131
148
|
normalized = tuple(paths)
|
|
132
|
-
|
|
133
|
-
basenames = tuple(os.path.basename(p).lower() for p in normalized)
|
|
149
|
+
dirs = tuple(_ancestor_dirs(normalized))
|
|
134
150
|
return Index(
|
|
135
151
|
root=root,
|
|
136
152
|
paths=normalized,
|
|
137
|
-
|
|
138
|
-
|
|
153
|
+
basenames_lower=_basenames_lower(normalized),
|
|
154
|
+
dirs=dirs,
|
|
155
|
+
dir_basenames_lower=_basenames_lower(dirs),
|
|
139
156
|
)
|
|
140
157
|
|
|
141
158
|
|
|
@@ -9,6 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
|
|
10
10
|
import heapq
|
|
11
11
|
import os
|
|
12
|
+
from itertools import chain, repeat
|
|
12
13
|
from typing import Iterable, List
|
|
13
14
|
|
|
14
15
|
from code_puppy.file_completion_tokens import active_reference, quote_path
|
|
@@ -24,10 +25,11 @@ MAX_FUZZY_RESULTS = 20
|
|
|
24
25
|
# --------------------------------------------------------------------- scoring
|
|
25
26
|
|
|
26
27
|
|
|
27
|
-
def _score(basename_lower: str,
|
|
28
|
-
"""Tiered substring score, pi-style. 0 means 'no match'.
|
|
28
|
+
def _score(basename_lower: str, query_lower: str) -> int:
|
|
29
|
+
"""Tiered basename substring score, pi-style. 0 means 'no match'.
|
|
29
30
|
|
|
30
31
|
Higher is better. Cheap and predictable — no Levenshtein, no fuse.js.
|
|
32
|
+
Only the basename is scored because that is the name the menu displays.
|
|
31
33
|
"""
|
|
32
34
|
if not query_lower:
|
|
33
35
|
return 1 # everything is a "match" for an empty query
|
|
@@ -37,8 +39,6 @@ def _score(basename_lower: str, path_lower: str, query_lower: str) -> int:
|
|
|
37
39
|
return 80
|
|
38
40
|
if query_lower in basename_lower:
|
|
39
41
|
return 50
|
|
40
|
-
if query_lower in path_lower:
|
|
41
|
-
return 30
|
|
42
42
|
return 0
|
|
43
43
|
|
|
44
44
|
|
|
@@ -58,17 +58,21 @@ def _ensure_index_for_cwd() -> None:
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
def _fuzzy_completions(query: str, start_position: int) -> List[Completion]:
|
|
61
|
-
"""Pi-style ranked completions from the
|
|
61
|
+
"""Pi-style ranked completions of files and folders from the index."""
|
|
62
62
|
_ensure_index_for_cwd()
|
|
63
63
|
snap = file_index.get_index()
|
|
64
64
|
if snap.root != os.path.abspath(os.getcwd()) or not snap.paths:
|
|
65
65
|
return []
|
|
66
66
|
|
|
67
67
|
q_lower = query.lower()
|
|
68
|
+
entries = chain(
|
|
69
|
+
zip(snap.paths, snap.basenames_lower, repeat(False)),
|
|
70
|
+
zip(snap.dirs, snap.dir_basenames_lower, repeat(True)),
|
|
71
|
+
)
|
|
68
72
|
candidates = (
|
|
69
|
-
(-score, path)
|
|
70
|
-
for path,
|
|
71
|
-
if (score := _score(base,
|
|
73
|
+
(-score, path, is_dir)
|
|
74
|
+
for path, base, is_dir in entries
|
|
75
|
+
if (score := _score(base, q_lower)) > 0
|
|
72
76
|
)
|
|
73
77
|
top = heapq.nsmallest(MAX_FUZZY_RESULTS, candidates)
|
|
74
78
|
|
|
@@ -77,9 +81,10 @@ def _fuzzy_completions(query: str, start_position: int) -> List[Completion]:
|
|
|
77
81
|
path,
|
|
78
82
|
start_position=start_position,
|
|
79
83
|
display=os.path.basename(path),
|
|
80
|
-
|
|
84
|
+
# full relpath disambiguates; trailing separator marks folders
|
|
85
|
+
display_meta=path + os.sep if is_dir else path,
|
|
81
86
|
)
|
|
82
|
-
for _neg_score, path in top
|
|
87
|
+
for _neg_score, path, is_dir in top
|
|
83
88
|
]
|
|
84
89
|
|
|
85
90
|
|
|
@@ -18,6 +18,7 @@ from typing import Any, Dict, Optional
|
|
|
18
18
|
|
|
19
19
|
import httpx
|
|
20
20
|
from pydantic_ai.messages import (
|
|
21
|
+
ERROR_OUTCOMES,
|
|
21
22
|
ModelMessage,
|
|
22
23
|
ModelRequest,
|
|
23
24
|
ModelResponse,
|
|
@@ -36,6 +37,7 @@ from code_puppy.gemini_common import (
|
|
|
36
37
|
_build_tools,
|
|
37
38
|
_parse_candidate_parts,
|
|
38
39
|
_build_generation_config,
|
|
40
|
+
sendable_request_parts,
|
|
39
41
|
)
|
|
40
42
|
|
|
41
43
|
logger = logging.getLogger(__name__)
|
|
@@ -148,7 +150,7 @@ class GeminiCodeAssistModel(Model):
|
|
|
148
150
|
|
|
149
151
|
for msg in messages:
|
|
150
152
|
if isinstance(msg, ModelRequest):
|
|
151
|
-
for part in msg.parts:
|
|
153
|
+
for part in sendable_request_parts(msg.parts):
|
|
152
154
|
if isinstance(part, SystemPromptPart):
|
|
153
155
|
# Collect system prompt.
|
|
154
156
|
if system_instruction is None:
|
|
@@ -178,6 +180,11 @@ class GeminiCodeAssistModel(Model):
|
|
|
178
180
|
except (TypeError, ValueError):
|
|
179
181
|
content = str(content)
|
|
180
182
|
|
|
183
|
+
# Gemini's function-response schema reports a failed or
|
|
184
|
+
# retried call under ``error`` rather than ``result``.
|
|
185
|
+
result_key = (
|
|
186
|
+
"error" if part.outcome in ERROR_OUTCOMES else "result"
|
|
187
|
+
)
|
|
181
188
|
contents.append(
|
|
182
189
|
{
|
|
183
190
|
"role": "user",
|
|
@@ -185,7 +192,7 @@ class GeminiCodeAssistModel(Model):
|
|
|
185
192
|
{
|
|
186
193
|
"functionResponse": {
|
|
187
194
|
"name": part.tool_name,
|
|
188
|
-
"response": {
|
|
195
|
+
"response": {result_key: content},
|
|
189
196
|
}
|
|
190
197
|
}
|
|
191
198
|
],
|
|
@@ -7,6 +7,7 @@ Wire-format knowledge for the Gemini API should live in exactly one place.
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
import uuid
|
|
10
|
+
from collections.abc import Iterator, Sequence
|
|
10
11
|
from typing import Any
|
|
11
12
|
|
|
12
13
|
from pydantic_ai import (
|
|
@@ -16,6 +17,8 @@ from pydantic_ai import (
|
|
|
16
17
|
ToolCallPart,
|
|
17
18
|
RequestUsage,
|
|
18
19
|
)
|
|
20
|
+
from pydantic_ai.messages import ModelRequestPart
|
|
21
|
+
from pydantic_ai.models import _sendable_request_parts
|
|
19
22
|
from pydantic_ai.tools import ToolDefinition
|
|
20
23
|
from pydantic_ai.settings import ModelSettings
|
|
21
24
|
|
|
@@ -25,6 +28,20 @@ def generate_tool_call_id() -> str:
|
|
|
25
28
|
return str(uuid.uuid4())
|
|
26
29
|
|
|
27
30
|
|
|
31
|
+
def sendable_request_parts(
|
|
32
|
+
parts: Sequence[ModelRequestPart],
|
|
33
|
+
) -> Iterator[ModelRequestPart]:
|
|
34
|
+
"""Request parts as a stock pydantic-ai adapter would map them.
|
|
35
|
+
|
|
36
|
+
A compaction summary written by the harness is a provider-less
|
|
37
|
+
``CompactionPart``; pydantic-ai leaves it for each adapter to render as
|
|
38
|
+
framed user text, so an adapter that skips this step drops the summary.
|
|
39
|
+
The helper is private upstream, hence the single seam (exact version pins
|
|
40
|
+
keep it stable; ``tests/test_gemini_compaction_summary.py`` pins its output).
|
|
41
|
+
"""
|
|
42
|
+
return _sendable_request_parts(parts)
|
|
43
|
+
|
|
44
|
+
|
|
28
45
|
def _flatten_union_to_object_gemini(union_items: list, defs: dict, resolve_fn) -> dict:
|
|
29
46
|
"""Flatten a union of object types into a single object with all properties.
|
|
30
47
|
|
|
@@ -24,7 +24,6 @@ from pydantic_ai.messages import (
|
|
|
24
24
|
ModelRequest,
|
|
25
25
|
ModelResponse,
|
|
26
26
|
ModelResponseStreamEvent,
|
|
27
|
-
RetryPromptPart,
|
|
28
27
|
SystemPromptPart,
|
|
29
28
|
TextPart,
|
|
30
29
|
ThinkingPart,
|
|
@@ -40,6 +39,7 @@ from code_puppy.gemini_common import (
|
|
|
40
39
|
_build_tools,
|
|
41
40
|
_parse_candidate_parts,
|
|
42
41
|
generate_tool_call_id,
|
|
42
|
+
sendable_request_parts,
|
|
43
43
|
_build_generation_config,
|
|
44
44
|
)
|
|
45
45
|
from code_puppy.steer_metadata import is_steer_request
|
|
@@ -215,7 +215,7 @@ class GeminiModel(Model):
|
|
|
215
215
|
if is_steer_request(m):
|
|
216
216
|
tool_parts: list[dict[str, Any]] = []
|
|
217
217
|
steer_parts: list[dict[str, Any]] = []
|
|
218
|
-
for part in m.parts:
|
|
218
|
+
for part in sendable_request_parts(m.parts):
|
|
219
219
|
if isinstance(part, SystemPromptPart):
|
|
220
220
|
system_parts.append({"text": part.content})
|
|
221
221
|
elif isinstance(part, UserPromptPart):
|
|
@@ -230,19 +230,6 @@ class GeminiModel(Model):
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
)
|
|
233
|
-
elif isinstance(part, RetryPromptPart):
|
|
234
|
-
if part.tool_name is None:
|
|
235
|
-
steer_parts.append({"text": part.model_response()})
|
|
236
|
-
else:
|
|
237
|
-
tool_parts.append(
|
|
238
|
-
{
|
|
239
|
-
"function_response": {
|
|
240
|
-
"name": part.tool_name,
|
|
241
|
-
"response": {"error": part.model_response()},
|
|
242
|
-
"id": part.tool_call_id,
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
)
|
|
246
233
|
|
|
247
234
|
if tool_parts:
|
|
248
235
|
# Tool returns (e.g. spliced by prune_interrupted_tool_calls)
|
|
@@ -273,7 +260,7 @@ class GeminiModel(Model):
|
|
|
273
260
|
if isinstance(m, ModelRequest):
|
|
274
261
|
message_parts: list[dict[str, Any]] = []
|
|
275
262
|
|
|
276
|
-
for part in m.parts:
|
|
263
|
+
for part in sendable_request_parts(m.parts):
|
|
277
264
|
if isinstance(part, SystemPromptPart):
|
|
278
265
|
system_parts.append({"text": part.content})
|
|
279
266
|
elif isinstance(part, UserPromptPart):
|
|
@@ -289,19 +276,6 @@ class GeminiModel(Model):
|
|
|
289
276
|
}
|
|
290
277
|
}
|
|
291
278
|
)
|
|
292
|
-
elif isinstance(part, RetryPromptPart):
|
|
293
|
-
if part.tool_name is None:
|
|
294
|
-
message_parts.append({"text": part.model_response()})
|
|
295
|
-
else:
|
|
296
|
-
message_parts.append(
|
|
297
|
-
{
|
|
298
|
-
"function_response": {
|
|
299
|
-
"name": part.tool_name,
|
|
300
|
-
"response": {"error": part.model_response()},
|
|
301
|
-
"id": part.tool_call_id,
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
)
|
|
305
279
|
|
|
306
280
|
if message_parts:
|
|
307
281
|
# Merge with previous user message if exists
|