2026-05-26 10:29:50 -04:00

179 lines
6.0 KiB
Python

"""hermes-agent-anthropic: Anthropic Messages API adapter for Hermes Agent."""
from hermes_agent_anthropic.adapter import ( # noqa: F401
ADAPTIVE_EFFORT_MAP,
THINKING_BUDGET,
_ANTHROPIC_DEFAULT_OUTPUT_LIMIT,
_ANTHROPIC_OUTPUT_LIMITS,
_ADAPTIVE_THINKING_SUBSTRINGS,
_CLAUDE_CODE_SYSTEM_PREFIX,
_CLAUDE_CODE_VERSION_FALLBACK,
_COMMON_BETAS,
_CONTEXT_1M_BETA,
_FAST_MODE_BETA,
_FAST_MODE_SUPPORTED_SUBSTRINGS,
_HERMES_OAUTH_FILE,
_KIMI_FAMILY_MODEL_PREFIXES,
_MCP_TOOL_PREFIX,
_NO_SAMPLING_PARAMS_SUBSTRINGS,
_OAUTH_CLIENT_ID,
_OAUTH_ONLY_BETAS,
_OAUTH_REDIRECT_URI,
_OAUTH_SCOPES,
_OAUTH_TOKEN_URL,
_TOOL_STREAMING_BETA,
_XHIGH_EFFORT_SUBSTRINGS,
_build_anthropic_client_with_bearer_hook,
_common_betas_for_base_url,
_content_parts_to_anthropic_blocks,
_convert_assistant_message,
_convert_content_part_to_anthropic,
_convert_content_to_anthropic,
_convert_tool_message_to_result,
_convert_user_message,
_detect_claude_code_version,
_evict_old_screenshots,
_extract_preserved_thinking_blocks,
_forbids_sampling_params,
_generate_pkce,
_get_anthropic_max_output,
_get_anthropic_sdk,
_get_claude_code_version,
_image_source_from_openai_url,
_is_azure_anthropic_endpoint,
_is_bedrock_model_id,
_is_deepseek_anthropic_endpoint,
_is_kimi_coding_endpoint,
_is_kimi_family_endpoint,
_is_minimax_anthropic_endpoint,
_is_oauth_token,
_is_third_party_anthropic_endpoint,
_manage_thinking_signatures,
_merge_consecutive_roles,
_model_name_is_kimi_family,
_normalize_base_url_text,
_normalize_tool_input_schema,
_prefer_refreshable_claude_code_token,
_read_claude_code_credentials_from_keychain,
_refresh_oauth_token,
_requires_bearer_auth,
_resolve_anthropic_messages_max_tokens,
_resolve_claude_code_token_from_credentials,
_resolve_positive_anthropic_max_tokens,
_sanitize_tool_id,
_strip_orphaned_tool_blocks,
_supports_adaptive_thinking,
_supports_fast_mode,
_supports_xhigh_effort,
_write_claude_code_credentials,
_base_url_needs_context_1m_beta,
build_anthropic_bedrock_client,
build_anthropic_client,
build_anthropic_kwargs,
convert_messages_to_anthropic,
convert_tools_to_anthropic,
is_claude_code_token_valid,
normalize_model_name,
read_claude_code_credentials,
read_claude_managed_key,
read_hermes_oauth_credentials,
refresh_anthropic_oauth_pure,
resolve_anthropic_token,
run_hermes_oauth_login_pure,
run_oauth_setup_token,
)
def register(ctx):
"""Entry point for the hermes_agent.plugins entry point group."""
from hermes_agent_anthropic import adapter
# Register every public symbol that __init__.py re-exports from adapter
# as a provider service so core code can look them up via the registry
# instead of importing from hermes_agent_anthropic directly.
_symbols = [
"ADAPTIVE_EFFORT_MAP",
"THINKING_BUDGET",
"_ANTHROPIC_DEFAULT_OUTPUT_LIMIT",
"_ANTHROPIC_OUTPUT_LIMITS",
"_ADAPTIVE_THINKING_SUBSTRINGS",
"_CLAUDE_CODE_SYSTEM_PREFIX",
"_CLAUDE_CODE_VERSION_FALLBACK",
"_COMMON_BETAS",
"_CONTEXT_1M_BETA",
"_FAST_MODE_BETA",
"_FAST_MODE_SUPPORTED_SUBSTRINGS",
"_HERMES_OAUTH_FILE",
"_KIMI_FAMILY_MODEL_PREFIXES",
"_MCP_TOOL_PREFIX",
"_NO_SAMPLING_PARAMS_SUBSTRINGS",
"_OAUTH_CLIENT_ID",
"_OAUTH_ONLY_BETAS",
"_OAUTH_REDIRECT_URI",
"_OAUTH_SCOPES",
"_OAUTH_TOKEN_URL",
"_TOOL_STREAMING_BETA",
"_XHIGH_EFFORT_SUBSTRINGS",
"_build_anthropic_client_with_bearer_hook",
"_common_betas_for_base_url",
"_content_parts_to_anthropic_blocks",
"_convert_assistant_message",
"_convert_content_part_to_anthropic",
"_convert_content_to_anthropic",
"_convert_tool_message_to_result",
"_convert_user_message",
"_detect_claude_code_version",
"_evict_old_screenshots",
"_extract_preserved_thinking_blocks",
"_forbids_sampling_params",
"_generate_pkce",
"_get_anthropic_max_output",
"_get_anthropic_sdk",
"_get_claude_code_version",
"_image_source_from_openai_url",
"_is_azure_anthropic_endpoint",
"_is_bedrock_model_id",
"_is_deepseek_anthropic_endpoint",
"_is_kimi_coding_endpoint",
"_is_kimi_family_endpoint",
"_is_minimax_anthropic_endpoint",
"_is_oauth_token",
"_is_third_party_anthropic_endpoint",
"_manage_thinking_signatures",
"_merge_consecutive_roles",
"_model_name_is_kimi_family",
"_normalize_base_url_text",
"_normalize_tool_input_schema",
"_prefer_refreshable_claude_code_token",
"_read_claude_code_credentials_from_keychain",
"_refresh_oauth_token",
"_requires_bearer_auth",
"_resolve_anthropic_messages_max_tokens",
"_resolve_claude_code_token_from_credentials",
"_resolve_positive_anthropic_max_tokens",
"_sanitize_tool_id",
"_strip_orphaned_tool_blocks",
"_supports_adaptive_thinking",
"_supports_fast_mode",
"_supports_xhigh_effort",
"_write_claude_code_credentials",
"_base_url_needs_context_1m_beta",
"build_anthropic_bedrock_client",
"build_anthropic_client",
"build_anthropic_kwargs",
"convert_messages_to_anthropic",
"convert_tools_to_anthropic",
"is_claude_code_token_valid",
"normalize_model_name",
"read_claude_code_credentials",
"read_claude_managed_key",
"read_hermes_oauth_credentials",
"refresh_anthropic_oauth_pure",
"resolve_anthropic_token",
"run_hermes_oauth_login_pure",
"run_oauth_setup_token",
]
ctx.register_provider_services("anthropic", {
name: getattr(adapter, name) for name in _symbols
})