hud-python 0.5.2__tar.gz → 0.5.4__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.
Files changed (307) hide show
  1. {hud_python-0.5.2 → hud_python-0.5.4}/PKG-INFO +1 -1
  2. hud_python-0.5.4/hud/agents/__init__.py +82 -0
  3. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/claude.py +12 -4
  4. hud_python-0.5.4/hud/agents/gateway.py +42 -0
  5. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/gemini.py +12 -4
  6. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/openai.py +12 -4
  7. hud_python-0.5.4/hud/agents/resolver.py +70 -0
  8. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/test_openai.py +2 -1
  9. hud_python-0.5.4/hud/agents/tests/test_resolver.py +192 -0
  10. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/eval.py +17 -37
  11. {hud_python-0.5.2 → hud_python-0.5.4}/hud/datasets/loader.py +6 -3
  12. {hud_python-0.5.2 → hud_python-0.5.4}/hud/datasets/runner.py +9 -10
  13. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/environment.py +42 -0
  14. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/scenarios.py +56 -16
  15. hud_python-0.5.4/hud/environment/tests/test_environment.py +329 -0
  16. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/context.py +11 -1
  17. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/task.py +5 -2
  18. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/tests/test_eval.py +1 -1
  19. {hud_python-0.5.2 → hud_python-0.5.4}/hud/telemetry/tests/test_eval_telemetry.py +8 -8
  20. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/__init__.py +2 -0
  21. hud_python-0.5.4/hud/tools/agent.py +216 -0
  22. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/shell.py +3 -3
  23. hud_python-0.5.4/hud/tools/tests/test_agent_tool.py +355 -0
  24. {hud_python-0.5.2 → hud_python-0.5.4}/hud/types.py +5 -3
  25. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/strict_schema.py +1 -1
  26. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/tests/test_version.py +1 -1
  27. {hud_python-0.5.2 → hud_python-0.5.4}/hud/version.py +1 -1
  28. {hud_python-0.5.2 → hud_python-0.5.4}/pyproject.toml +1 -1
  29. hud_python-0.5.2/hud/agents/__init__.py +0 -19
  30. hud_python-0.5.2/hud/environment/tests/test_environment.py +0 -161
  31. {hud_python-0.5.2 → hud_python-0.5.4}/.gitignore +0 -0
  32. {hud_python-0.5.2 → hud_python-0.5.4}/LICENSE +0 -0
  33. {hud_python-0.5.2 → hud_python-0.5.4}/README.md +0 -0
  34. {hud_python-0.5.2 → hud_python-0.5.4}/examples/README.md +0 -0
  35. {hud_python-0.5.2 → hud_python-0.5.4}/hud/__init__.py +0 -0
  36. {hud_python-0.5.2 → hud_python-0.5.4}/hud/__main__.py +0 -0
  37. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/base.py +0 -0
  38. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/gemini_cua.py +0 -0
  39. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/grounded_openai.py +0 -0
  40. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/misc/__init__.py +0 -0
  41. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/misc/integration_test_agent.py +0 -0
  42. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/misc/response_agent.py +0 -0
  43. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/openai_chat.py +0 -0
  44. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/operator.py +0 -0
  45. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/__init__.py +0 -0
  46. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/conftest.py +0 -0
  47. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/test_base.py +0 -0
  48. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/test_base_runtime.py +0 -0
  49. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/test_claude.py +0 -0
  50. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/test_client.py +0 -0
  51. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/test_gemini.py +0 -0
  52. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/test_grounded_openai_agent.py +0 -0
  53. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/test_operator.py +0 -0
  54. {hud_python-0.5.2 → hud_python-0.5.4}/hud/agents/tests/test_run_eval.py +0 -0
  55. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/__init__.py +0 -0
  56. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/__main__.py +0 -0
  57. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/analyze.py +0 -0
  58. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/build.py +0 -0
  59. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/clone.py +0 -0
  60. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/debug.py +0 -0
  61. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/dev.py +0 -0
  62. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/flows/__init__.py +0 -0
  63. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/flows/dev.py +0 -0
  64. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/flows/init.py +0 -0
  65. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/flows/tasks.py +0 -0
  66. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/flows/templates.py +0 -0
  67. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/flows/tests/__init__.py +0 -0
  68. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/flows/tests/test_dev.py +0 -0
  69. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/get.py +0 -0
  70. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/init.py +0 -0
  71. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/list_func.py +0 -0
  72. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/pull.py +0 -0
  73. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/push.py +0 -0
  74. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/remove.py +0 -0
  75. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/rft.py +0 -0
  76. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/rft_status.py +0 -0
  77. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/__init__.py +0 -0
  78. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_analyze.py +0 -0
  79. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_analyze_metadata.py +0 -0
  80. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_analyze_module.py +0 -0
  81. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_build.py +0 -0
  82. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_build_failure.py +0 -0
  83. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_build_module.py +0 -0
  84. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_cli_init.py +0 -0
  85. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_cli_main.py +0 -0
  86. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_cli_more_wrappers.py +0 -0
  87. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_cli_root.py +0 -0
  88. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_clone.py +0 -0
  89. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_convert.py +0 -0
  90. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_cursor.py +0 -0
  91. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_debug.py +0 -0
  92. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_dev.py +0 -0
  93. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_eval.py +0 -0
  94. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_eval_bedrock.py +0 -0
  95. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_init.py +0 -0
  96. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_list_func.py +0 -0
  97. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_main_module.py +0 -0
  98. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_mcp_server.py +0 -0
  99. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_pull.py +0 -0
  100. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_push.py +0 -0
  101. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_push_happy.py +0 -0
  102. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_push_wrapper.py +0 -0
  103. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_registry.py +0 -0
  104. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/tests/test_utils.py +0 -0
  105. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/__init__.py +0 -0
  106. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/celebrate.py +0 -0
  107. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/config.py +0 -0
  108. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/cursor.py +0 -0
  109. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/docker.py +0 -0
  110. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/env_check.py +0 -0
  111. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/environment.py +0 -0
  112. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/git.py +0 -0
  113. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/interactive.py +0 -0
  114. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/local_runner.py +0 -0
  115. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/logging.py +0 -0
  116. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/metadata.py +0 -0
  117. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/package_runner.py +0 -0
  118. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/registry.py +0 -0
  119. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/remote_runner.py +0 -0
  120. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/runner.py +0 -0
  121. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/server.py +0 -0
  122. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/source_hash.py +0 -0
  123. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tasks.py +0 -0
  124. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/__init__.py +0 -0
  125. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_config.py +0 -0
  126. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_docker.py +0 -0
  127. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_docker_hints.py +0 -0
  128. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_env_check.py +0 -0
  129. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_environment.py +0 -0
  130. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_git.py +0 -0
  131. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_interactive_module.py +0 -0
  132. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_local_runner.py +0 -0
  133. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_logging_utils.py +0 -0
  134. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_metadata.py +0 -0
  135. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_package_runner.py +0 -0
  136. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_registry_utils.py +0 -0
  137. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_remote_runner.py +0 -0
  138. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_runner_modules.py +0 -0
  139. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_source_hash.py +0 -0
  140. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/tests/test_tasks.py +0 -0
  141. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/version_check.py +0 -0
  142. {hud_python-0.5.2 → hud_python-0.5.4}/hud/cli/utils/viewer.py +0 -0
  143. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/README.md +0 -0
  144. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/__init__.py +0 -0
  145. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/base.py +0 -0
  146. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/environment.py +0 -0
  147. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/fastmcp.py +0 -0
  148. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/mcp_use.py +0 -0
  149. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/tests/__init__.py +0 -0
  150. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/tests/test_analyze_scenarios.py +0 -0
  151. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/tests/test_client_integration.py +0 -0
  152. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/tests/test_fastmcp.py +0 -0
  153. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/tests/test_mcp_use_retry.py +0 -0
  154. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/tests/test_protocol.py +0 -0
  155. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/utils/__init__.py +0 -0
  156. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/utils/mcp_use_retry.py +0 -0
  157. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/utils/retry.py +0 -0
  158. {hud_python-0.5.2 → hud_python-0.5.4}/hud/clients/utils/retry_transport.py +0 -0
  159. {hud_python-0.5.2 → hud_python-0.5.4}/hud/datasets/__init__.py +0 -0
  160. {hud_python-0.5.2 → hud_python-0.5.4}/hud/datasets/tests/__init__.py +0 -0
  161. {hud_python-0.5.2 → hud_python-0.5.4}/hud/datasets/tests/test_loader.py +0 -0
  162. {hud_python-0.5.2 → hud_python-0.5.4}/hud/datasets/tests/test_utils.py +0 -0
  163. {hud_python-0.5.2 → hud_python-0.5.4}/hud/datasets/utils.py +0 -0
  164. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/__init__.py +0 -0
  165. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/connection.py +0 -0
  166. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/connectors/__init__.py +0 -0
  167. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/connectors/base.py +0 -0
  168. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/connectors/local.py +0 -0
  169. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/connectors/mcp_config.py +0 -0
  170. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/connectors/openai.py +0 -0
  171. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/connectors/remote.py +0 -0
  172. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/integrations/__init__.py +0 -0
  173. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/integrations/adk.py +0 -0
  174. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/integrations/anthropic.py +0 -0
  175. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/integrations/gemini.py +0 -0
  176. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/integrations/langchain.py +0 -0
  177. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/integrations/llamaindex.py +0 -0
  178. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/integrations/openai.py +0 -0
  179. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/mock.py +0 -0
  180. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/router.py +0 -0
  181. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/tests/__init__.py +0 -0
  182. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/tests/test_connection.py +0 -0
  183. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/tests/test_connectors.py +0 -0
  184. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/tests/test_integrations.py +0 -0
  185. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/tests/test_local_connectors.py +0 -0
  186. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/tests/test_scenarios.py +0 -0
  187. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/tests/test_tools.py +0 -0
  188. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/types.py +0 -0
  189. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/utils/__init__.py +0 -0
  190. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/utils/formats.py +0 -0
  191. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/utils/schema.py +0 -0
  192. {hud_python-0.5.2 → hud_python-0.5.4}/hud/environment/utils/tool_wrappers.py +0 -0
  193. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/__init__.py +0 -0
  194. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/display.py +0 -0
  195. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/instrument.py +0 -0
  196. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/manager.py +0 -0
  197. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/parallel.py +0 -0
  198. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/tests/__init__.py +0 -0
  199. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/tests/test_context.py +0 -0
  200. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/tests/test_manager.py +0 -0
  201. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/tests/test_parallel.py +0 -0
  202. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/tests/test_task.py +0 -0
  203. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/types.py +0 -0
  204. {hud_python-0.5.2 → hud_python-0.5.4}/hud/eval/utils.py +0 -0
  205. {hud_python-0.5.2 → hud_python-0.5.4}/hud/native/__init__.py +0 -0
  206. {hud_python-0.5.2 → hud_python-0.5.4}/hud/native/comparator.py +0 -0
  207. {hud_python-0.5.2 → hud_python-0.5.4}/hud/native/tests/__init__.py +0 -0
  208. {hud_python-0.5.2 → hud_python-0.5.4}/hud/native/tests/test_comparator.py +0 -0
  209. {hud_python-0.5.2 → hud_python-0.5.4}/hud/native/tests/test_native_init.py +0 -0
  210. {hud_python-0.5.2 → hud_python-0.5.4}/hud/patches/__init__.py +0 -0
  211. {hud_python-0.5.2 → hud_python-0.5.4}/hud/patches/mcp_patches.py +0 -0
  212. {hud_python-0.5.2 → hud_python-0.5.4}/hud/patches/warnings.py +0 -0
  213. {hud_python-0.5.2 → hud_python-0.5.4}/hud/py.typed +0 -0
  214. {hud_python-0.5.2 → hud_python-0.5.4}/hud/samples/__init__.py +0 -0
  215. {hud_python-0.5.2 → hud_python-0.5.4}/hud/samples/browser.py +0 -0
  216. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/__init__.py +0 -0
  217. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/context.py +0 -0
  218. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/helper/__init__.py +0 -0
  219. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/low_level.py +0 -0
  220. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/router.py +0 -0
  221. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/server.py +0 -0
  222. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/tests/__init__.py +0 -0
  223. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/tests/test_add_tool.py +0 -0
  224. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/tests/test_context.py +0 -0
  225. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/tests/test_mcp_server_handlers.py +0 -0
  226. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/tests/test_mcp_server_integration.py +0 -0
  227. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/tests/test_mcp_server_more.py +0 -0
  228. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/tests/test_run_wrapper.py +0 -0
  229. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/tests/test_server_extra.py +0 -0
  230. {hud_python-0.5.2 → hud_python-0.5.4}/hud/server/tests/test_sigterm_runner.py +0 -0
  231. {hud_python-0.5.2 → hud_python-0.5.4}/hud/settings.py +0 -0
  232. {hud_python-0.5.2 → hud_python-0.5.4}/hud/shared/__init__.py +0 -0
  233. {hud_python-0.5.2 → hud_python-0.5.4}/hud/shared/exceptions.py +0 -0
  234. {hud_python-0.5.2 → hud_python-0.5.4}/hud/shared/hints.py +0 -0
  235. {hud_python-0.5.2 → hud_python-0.5.4}/hud/shared/requests.py +0 -0
  236. {hud_python-0.5.2 → hud_python-0.5.4}/hud/shared/tests/__init__.py +0 -0
  237. {hud_python-0.5.2 → hud_python-0.5.4}/hud/shared/tests/test_exceptions.py +0 -0
  238. {hud_python-0.5.2 → hud_python-0.5.4}/hud/shared/tests/test_hints.py +0 -0
  239. {hud_python-0.5.2 → hud_python-0.5.4}/hud/shared/tests/test_requests.py +0 -0
  240. {hud_python-0.5.2 → hud_python-0.5.4}/hud/telemetry/__init__.py +0 -0
  241. {hud_python-0.5.2 → hud_python-0.5.4}/hud/telemetry/exporter.py +0 -0
  242. {hud_python-0.5.2 → hud_python-0.5.4}/hud/telemetry/instrument.py +0 -0
  243. {hud_python-0.5.2 → hud_python-0.5.4}/hud/telemetry/tests/__init__.py +0 -0
  244. {hud_python-0.5.2 → hud_python-0.5.4}/hud/telemetry/tests/test_exporter.py +0 -0
  245. {hud_python-0.5.2 → hud_python-0.5.4}/hud/telemetry/tests/test_instrument.py +0 -0
  246. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/apply_patch.py +0 -0
  247. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/base.py +0 -0
  248. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/bash.py +0 -0
  249. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/computer/__init__.py +0 -0
  250. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/computer/anthropic.py +0 -0
  251. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/computer/gemini.py +0 -0
  252. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/computer/hud.py +0 -0
  253. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/computer/openai.py +0 -0
  254. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/computer/qwen.py +0 -0
  255. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/computer/settings.py +0 -0
  256. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/edit.py +0 -0
  257. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/executors/__init__.py +0 -0
  258. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/executors/base.py +0 -0
  259. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/executors/pyautogui.py +0 -0
  260. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/executors/tests/__init__.py +0 -0
  261. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/executors/tests/test_base_executor.py +0 -0
  262. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/executors/tests/test_pyautogui_executor.py +0 -0
  263. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/executors/xdo.py +0 -0
  264. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/grounding/__init__.py +0 -0
  265. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/grounding/config.py +0 -0
  266. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/grounding/grounded_tool.py +0 -0
  267. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/grounding/grounder.py +0 -0
  268. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/grounding/tests/__init__.py +0 -0
  269. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/grounding/tests/test_grounded_tool.py +0 -0
  270. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/jupyter.py +0 -0
  271. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/playwright.py +0 -0
  272. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/response.py +0 -0
  273. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/submit.py +0 -0
  274. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/__init__.py +0 -0
  275. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_apply_patch.py +0 -0
  276. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_base.py +0 -0
  277. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_bash.py +0 -0
  278. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_bash_extended.py +0 -0
  279. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_computer.py +0 -0
  280. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_computer_actions.py +0 -0
  281. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_edit.py +0 -0
  282. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_init.py +0 -0
  283. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_jupyter_tool.py +0 -0
  284. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_playwright_tool.py +0 -0
  285. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_response.py +0 -0
  286. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_shell.py +0 -0
  287. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_submit.py +0 -0
  288. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_tools.py +0 -0
  289. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_tools_init.py +0 -0
  290. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_types.py +0 -0
  291. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/tests/test_utils.py +0 -0
  292. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/types.py +0 -0
  293. {hud_python-0.5.2 → hud_python-0.5.4}/hud/tools/utils.py +0 -0
  294. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/__init__.py +0 -0
  295. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/env.py +0 -0
  296. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/hud_console.py +0 -0
  297. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/mcp.py +0 -0
  298. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/pretty_errors.py +0 -0
  299. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/telemetry.py +0 -0
  300. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/tests/__init__.py +0 -0
  301. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/tests/test_init.py +0 -0
  302. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/tests/test_mcp.py +0 -0
  303. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/tests/test_pretty_errors.py +0 -0
  304. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/tests/test_telemetry.py +0 -0
  305. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/tests/test_tool_shorthand.py +0 -0
  306. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/tool_shorthand.py +0 -0
  307. {hud_python-0.5.2 → hud_python-0.5.4}/hud/utils/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hud-python
3
- Version: 0.5.2
3
+ Version: 0.5.4
4
4
  Summary: SDK for the HUD platform.
5
5
  Project-URL: Homepage, https://github.com/hud-evals/hud-python
6
6
  Project-URL: Bug Tracker, https://github.com/hud-evals/hud-python/issues
@@ -0,0 +1,82 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ from .base import MCPAgent
6
+ from .openai import OpenAIAgent
7
+ from .openai_chat import OpenAIChatAgent
8
+ from .operator import OperatorAgent
9
+
10
+ __all__ = [
11
+ "MCPAgent",
12
+ "OpenAIAgent",
13
+ "OpenAIChatAgent",
14
+ "OperatorAgent",
15
+ "create_agent",
16
+ ]
17
+
18
+
19
+ def create_agent(model: str, **kwargs: Any) -> MCPAgent:
20
+ """Create an agent for a gateway model.
21
+
22
+ This routes ALL requests through the HUD gateway. For direct API access
23
+ (using your own API keys), use the agent classes directly.
24
+
25
+ Args:
26
+ model: Model name (e.g., "gpt-4o", "claude-sonnet-4-5").
27
+ **kwargs: Additional params passed to agent.create().
28
+
29
+ Returns:
30
+ Configured MCPAgent instance with gateway routing.
31
+
32
+ Example:
33
+ ```python
34
+ # Gateway routing (recommended)
35
+ agent = create_agent("gpt-4o")
36
+ agent = create_agent("claude-sonnet-4-5", temperature=0.7)
37
+
38
+ # Direct API access (use agent classes)
39
+ from hud.agents.claude import ClaudeAgent
40
+
41
+ agent = ClaudeAgent.create(model="claude-sonnet-4-5")
42
+ ```
43
+ """
44
+ from hud.agents.gateway import build_gateway_client
45
+ from hud.agents.resolver import resolve_cls
46
+
47
+ # Resolve class and gateway info
48
+ agent_cls, gateway_info = resolve_cls(model)
49
+
50
+ # Get model ID from gateway info or use input
51
+ model_id = model
52
+ if gateway_info:
53
+ model_id = gateway_info.get("model") or gateway_info.get("id") or model
54
+
55
+ # Determine provider: from gateway info, or infer from agent class
56
+ if gateway_info:
57
+ provider = gateway_info.get("provider") or "openai"
58
+ else:
59
+ # Map agent class to provider for known types
60
+ from hud.agents.claude import ClaudeAgent
61
+ from hud.agents.gemini import GeminiAgent
62
+
63
+ _AGENT_TO_PROVIDER = {
64
+ ClaudeAgent: "anthropic",
65
+ GeminiAgent: "google",
66
+ }
67
+ provider = _AGENT_TO_PROVIDER.get(agent_cls, "openai")
68
+
69
+ client = build_gateway_client(provider)
70
+
71
+ # Set up kwargs
72
+ kwargs.setdefault("model", model_id)
73
+
74
+ # Use correct client key based on agent type
75
+ if agent_cls == OpenAIChatAgent:
76
+ kwargs.setdefault("openai_client", client)
77
+ else:
78
+ # Claude and other agents use model_client and validate_api_key
79
+ kwargs.setdefault("model_client", client)
80
+ kwargs.setdefault("validate_api_key", False)
81
+
82
+ return agent_cls.create(**kwargs)
@@ -76,10 +76,18 @@ class ClaudeAgent(MCPAgent):
76
76
 
77
77
  model_client = self.config.model_client
78
78
  if model_client is None:
79
- api_key = settings.anthropic_api_key
80
- if not api_key:
81
- raise ValueError("Anthropic API key not found. Set ANTHROPIC_API_KEY.")
82
- model_client = AsyncAnthropic(api_key=api_key)
79
+ # Default to HUD gateway when HUD_API_KEY is available
80
+ if settings.api_key:
81
+ from hud.agents.gateway import build_gateway_client
82
+
83
+ model_client = build_gateway_client("anthropic")
84
+ elif settings.anthropic_api_key:
85
+ model_client = AsyncAnthropic(api_key=settings.anthropic_api_key)
86
+ else:
87
+ raise ValueError(
88
+ "No API key found. Set HUD_API_KEY for HUD gateway, "
89
+ "or ANTHROPIC_API_KEY for direct Anthropic access."
90
+ )
83
91
 
84
92
  self.anthropic_client = model_client
85
93
  self.max_tokens = self.config.max_tokens
@@ -0,0 +1,42 @@
1
+ """Gateway client utilities for HUD inference gateway."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+
8
+ def build_gateway_client(provider: str) -> Any:
9
+ """Build a client configured for HUD gateway routing.
10
+
11
+ Args:
12
+ provider: Provider name ("anthropic", "openai", "gemini", etc.)
13
+
14
+ Returns:
15
+ Configured async client for the provider.
16
+ """
17
+ from hud.settings import settings
18
+
19
+ provider = provider.lower()
20
+
21
+ if provider == "anthropic":
22
+ from anthropic import AsyncAnthropic
23
+
24
+ return AsyncAnthropic(api_key=settings.api_key, base_url=settings.hud_gateway_url)
25
+
26
+ if provider == "gemini":
27
+ from google import genai
28
+ from google.genai.types import HttpOptions
29
+
30
+ return genai.Client(
31
+ api_key="PLACEHOLDER",
32
+ http_options=HttpOptions(
33
+ api_version="v1beta",
34
+ base_url=settings.hud_gateway_url,
35
+ headers={"Authorization": f"Bearer {settings.api_key}"},
36
+ ),
37
+ )
38
+
39
+ # OpenAI-compatible (openai, azure, together, groq, fireworks, etc.)
40
+ from openai import AsyncOpenAI
41
+
42
+ return AsyncOpenAI(api_key=settings.api_key, base_url=settings.hud_gateway_url)
@@ -61,10 +61,18 @@ class GeminiAgent(MCPAgent):
61
61
 
62
62
  model_client = self.config.model_client
63
63
  if model_client is None:
64
- api_key = settings.gemini_api_key
65
- if not api_key:
66
- raise ValueError("Gemini API key not found. Set GEMINI_API_KEY.")
67
- model_client = genai.Client(api_key=api_key)
64
+ # Default to HUD gateway when HUD_API_KEY is available
65
+ if settings.api_key:
66
+ from hud.agents.gateway import build_gateway_client
67
+
68
+ model_client = build_gateway_client("gemini")
69
+ elif settings.gemini_api_key:
70
+ model_client = genai.Client(api_key=settings.gemini_api_key)
71
+ else:
72
+ raise ValueError(
73
+ "No API key found. Set HUD_API_KEY for HUD gateway, "
74
+ "or GEMINI_API_KEY for direct Gemini access."
75
+ )
68
76
 
69
77
  if self.config.validate_api_key:
70
78
  try:
@@ -79,10 +79,18 @@ class OpenAIAgent(MCPAgent):
79
79
 
80
80
  model_client = self.config.model_client
81
81
  if model_client is None:
82
- api_key = settings.openai_api_key
83
- if not api_key:
84
- raise ValueError("OpenAI API key not found. Set OPENAI_API_KEY.")
85
- model_client = AsyncOpenAI(api_key=api_key)
82
+ # Default to HUD gateway when HUD_API_KEY is available
83
+ if settings.api_key:
84
+ from hud.agents.gateway import build_gateway_client
85
+
86
+ model_client = build_gateway_client("openai")
87
+ elif settings.openai_api_key:
88
+ model_client = AsyncOpenAI(api_key=settings.openai_api_key)
89
+ else:
90
+ raise ValueError(
91
+ "No API key found. Set HUD_API_KEY for HUD gateway, "
92
+ "or OPENAI_API_KEY for direct OpenAI access."
93
+ )
86
94
 
87
95
  if self.config.validate_api_key:
88
96
  try:
@@ -0,0 +1,70 @@
1
+ """Model resolution - maps model strings to agent classes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any
6
+
7
+ if TYPE_CHECKING:
8
+ from hud.agents.base import MCPAgent
9
+
10
+ __all__ = ["resolve_cls"]
11
+
12
+ _models_cache: list[dict[str, Any]] | None = None
13
+
14
+ # Provider name → AgentType value (only anthropic differs)
15
+ _PROVIDER_TO_AGENT = {"anthropic": "claude"}
16
+
17
+
18
+ def _fetch_gateway_models() -> list[dict[str, Any]]:
19
+ """Fetch available models from HUD gateway (cached)."""
20
+ global _models_cache
21
+ if _models_cache is not None:
22
+ return _models_cache
23
+
24
+ import httpx
25
+
26
+ from hud.settings import settings
27
+
28
+ if not settings.api_key:
29
+ return []
30
+
31
+ try:
32
+ resp = httpx.get(
33
+ f"{settings.hud_gateway_url}/models",
34
+ headers={"Authorization": f"Bearer {settings.api_key}"},
35
+ timeout=10.0,
36
+ )
37
+ resp.raise_for_status()
38
+ data = resp.json()
39
+ _models_cache = data.get("data", data) if isinstance(data, dict) else data
40
+ return _models_cache or []
41
+ except Exception:
42
+ return []
43
+
44
+
45
+ def resolve_cls(model: str) -> tuple[type[MCPAgent], dict[str, Any] | None]:
46
+ """Resolve model string to (agent_class, gateway_info).
47
+
48
+ Returns:
49
+ (agent_class, None) for known AgentTypes
50
+ (agent_class, gateway_model_info) for gateway models
51
+ """
52
+ from hud.types import AgentType
53
+
54
+ # Known AgentType → no gateway info
55
+ try:
56
+ return AgentType(model).cls, None
57
+ except ValueError:
58
+ pass
59
+
60
+ # Gateway lookup
61
+ for m in _fetch_gateway_models():
62
+ if model in (m.get("id"), m.get("name"), m.get("model")):
63
+ provider = (m.get("provider") or "openai_compatible").lower()
64
+ agent_str = _PROVIDER_TO_AGENT.get(provider, provider)
65
+ try:
66
+ return AgentType(agent_str).cls, m
67
+ except ValueError:
68
+ return AgentType.OPENAI_COMPATIBLE.cls, m
69
+
70
+ raise ValueError(f"Model '{model}' not found")
@@ -128,8 +128,9 @@ class TestOpenAIAgent:
128
128
  async def test_init_without_client_no_api_key(self) -> None:
129
129
  """Test agent initialization fails without API key."""
130
130
  with patch("hud.agents.openai.settings") as mock_settings:
131
+ mock_settings.api_key = None
131
132
  mock_settings.openai_api_key = None
132
- with pytest.raises(ValueError, match="OpenAI API key not found"):
133
+ with pytest.raises(ValueError, match="No API key found"):
133
134
  OpenAIAgent.create()
134
135
 
135
136
  @pytest.mark.asyncio
@@ -0,0 +1,192 @@
1
+ """Tests for model resolution and create_agent."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from unittest.mock import MagicMock, patch
6
+
7
+ import pytest
8
+
9
+ from hud.agents import create_agent
10
+ from hud.agents.resolver import resolve_cls
11
+
12
+
13
+ class TestResolveCls:
14
+ """Tests for resolve_cls function."""
15
+
16
+ def test_resolves_known_agent_type(self) -> None:
17
+ """Known AgentType strings resolve to their class."""
18
+ from hud.agents.claude import ClaudeAgent
19
+
20
+ cls, gateway_info = resolve_cls("claude")
21
+ assert cls == ClaudeAgent
22
+ assert gateway_info is None
23
+
24
+ def test_resolves_openai(self) -> None:
25
+ """Resolves 'openai' to OpenAIAgent."""
26
+ from hud.agents import OpenAIAgent
27
+
28
+ cls, _gateway_info = resolve_cls("openai")
29
+ assert cls == OpenAIAgent
30
+
31
+ def test_resolves_gemini(self) -> None:
32
+ """Resolves 'gemini' to GeminiAgent."""
33
+ from hud.agents.gemini import GeminiAgent
34
+
35
+ cls, _gateway_info = resolve_cls("gemini")
36
+ assert cls == GeminiAgent
37
+
38
+ def test_unknown_model_without_gateway_raises(self) -> None:
39
+ """Unknown model with no gateway models raises ValueError."""
40
+ with (
41
+ patch("hud.agents.resolver._fetch_gateway_models", return_value=[]),
42
+ pytest.raises(ValueError, match="not found"),
43
+ ):
44
+ resolve_cls("unknown-model-xyz")
45
+
46
+ def test_resolves_gateway_model(self) -> None:
47
+ """Resolves model found in gateway."""
48
+ from hud.agents import OpenAIAgent
49
+
50
+ mock_models = [
51
+ {"id": "gpt-4o", "model": "gpt-4o", "provider": "openai"},
52
+ ]
53
+
54
+ with patch("hud.agents.resolver._fetch_gateway_models", return_value=mock_models):
55
+ cls, info = resolve_cls("gpt-4o")
56
+ assert cls == OpenAIAgent
57
+ assert info is not None
58
+ assert info["id"] == "gpt-4o"
59
+
60
+ def test_resolves_anthropic_provider_to_claude(self) -> None:
61
+ """Provider 'anthropic' maps to ClaudeAgent."""
62
+ from hud.agents.claude import ClaudeAgent
63
+
64
+ mock_models = [
65
+ {"id": "claude-sonnet", "model": "claude-3-sonnet", "provider": "anthropic"},
66
+ ]
67
+
68
+ with patch("hud.agents.resolver._fetch_gateway_models", return_value=mock_models):
69
+ cls, _info = resolve_cls("claude-sonnet")
70
+ assert cls == ClaudeAgent
71
+
72
+ def test_resolves_unknown_provider_to_openai_compatible(self) -> None:
73
+ """Unknown provider maps to OpenAIChatAgent."""
74
+ from hud.agents.openai_chat import OpenAIChatAgent
75
+
76
+ mock_models = [
77
+ {"id": "custom-model", "model": "custom", "provider": "custom-provider"},
78
+ ]
79
+
80
+ with patch("hud.agents.resolver._fetch_gateway_models", return_value=mock_models):
81
+ cls, _info = resolve_cls("custom-model")
82
+ assert cls == OpenAIChatAgent
83
+
84
+
85
+ class TestCreateAgent:
86
+ """Tests for create_agent function - gateway-only."""
87
+
88
+ def test_creates_with_gateway_client(self) -> None:
89
+ """create_agent always uses gateway routing."""
90
+ from hud.agents import OpenAIAgent
91
+
92
+ mock_models = [
93
+ {"id": "gpt-4o", "model": "gpt-4o", "provider": "openai"},
94
+ ]
95
+
96
+ with (
97
+ patch("hud.agents.resolver._fetch_gateway_models", return_value=mock_models),
98
+ patch.object(OpenAIAgent, "create") as mock_create,
99
+ patch("hud.agents.gateway.build_gateway_client") as mock_build_client,
100
+ ):
101
+ mock_client = MagicMock()
102
+ mock_build_client.return_value = mock_client
103
+ mock_agent = MagicMock()
104
+ mock_create.return_value = mock_agent
105
+
106
+ agent = create_agent("gpt-4o")
107
+
108
+ # Should have set model and model_client
109
+ call_kwargs = mock_create.call_args.kwargs
110
+ assert call_kwargs["model"] == "gpt-4o"
111
+ assert "model_client" in call_kwargs
112
+ assert agent == mock_agent
113
+
114
+ def test_passes_kwargs_to_create(self) -> None:
115
+ """Extra kwargs are passed to agent.create()."""
116
+ from hud.agents import OpenAIAgent
117
+
118
+ mock_models = [
119
+ {"id": "gpt-4o", "model": "gpt-4o", "provider": "openai"},
120
+ ]
121
+
122
+ with (
123
+ patch("hud.agents.resolver._fetch_gateway_models", return_value=mock_models),
124
+ patch.object(OpenAIAgent, "create") as mock_create,
125
+ patch("hud.agents.gateway.build_gateway_client"),
126
+ ):
127
+ mock_create.return_value = MagicMock()
128
+
129
+ create_agent("gpt-4o", temperature=0.5, max_tokens=1000)
130
+
131
+ call_kwargs = mock_create.call_args.kwargs
132
+ assert call_kwargs["temperature"] == 0.5
133
+ assert call_kwargs["max_tokens"] == 1000
134
+
135
+ def test_known_agent_type_also_uses_gateway(self) -> None:
136
+ """Even 'claude' string uses gateway (it's a gateway shortcut)."""
137
+ from hud.agents.claude import ClaudeAgent
138
+
139
+ with (
140
+ patch.object(ClaudeAgent, "create") as mock_create,
141
+ patch("hud.agents.gateway.build_gateway_client") as mock_build_client,
142
+ ):
143
+ mock_client = MagicMock()
144
+ mock_build_client.return_value = mock_client
145
+ mock_create.return_value = MagicMock()
146
+
147
+ create_agent("claude")
148
+
149
+ # Should still build gateway client
150
+ mock_build_client.assert_called_once()
151
+ call_kwargs = mock_create.call_args.kwargs
152
+ assert "model_client" in call_kwargs
153
+
154
+
155
+ class TestBuildGatewayClient:
156
+ """Tests for build_gateway_client function."""
157
+
158
+ def test_builds_anthropic_client(self) -> None:
159
+ """Builds AsyncAnthropic for anthropic provider."""
160
+ from hud.agents.gateway import build_gateway_client
161
+
162
+ with patch("hud.settings.settings") as mock_settings:
163
+ mock_settings.api_key = "test-key"
164
+ mock_settings.hud_gateway_url = "https://gateway.hud.ai"
165
+
166
+ with patch("anthropic.AsyncAnthropic") as mock_client_cls:
167
+ build_gateway_client("anthropic")
168
+ mock_client_cls.assert_called_once()
169
+
170
+ def test_builds_openai_client_for_openai(self) -> None:
171
+ """Builds AsyncOpenAI for openai provider."""
172
+ from hud.agents.gateway import build_gateway_client
173
+
174
+ with patch("hud.settings.settings") as mock_settings:
175
+ mock_settings.api_key = "test-key"
176
+ mock_settings.hud_gateway_url = "https://gateway.hud.ai"
177
+
178
+ with patch("openai.AsyncOpenAI") as mock_client_cls:
179
+ build_gateway_client("openai")
180
+ mock_client_cls.assert_called_once()
181
+
182
+ def test_builds_openai_client_for_unknown(self) -> None:
183
+ """Builds AsyncOpenAI for unknown providers (openai-compatible)."""
184
+ from hud.agents.gateway import build_gateway_client
185
+
186
+ with patch("hud.settings.settings") as mock_settings:
187
+ mock_settings.api_key = "test-key"
188
+ mock_settings.hud_gateway_url = "https://gateway.hud.ai"
189
+
190
+ with patch("openai.AsyncOpenAI") as mock_client_cls:
191
+ build_gateway_client("together")
192
+ mock_client_cls.assert_called_once()
@@ -338,47 +338,27 @@ class EvalConfig(BaseModel):
338
338
 
339
339
  # Configure gateway mode - route LLM API calls through HUD gateway
340
340
  if self.gateway:
341
- hud_api_key = settings.api_key
342
- if not hud_api_key:
341
+ if not settings.api_key:
343
342
  raise typer.Exit(1) # Already validated in validate_api_keys()
344
343
 
345
- if self.agent_type == AgentType.CLAUDE:
346
- from anthropic import AsyncAnthropic
347
-
348
- kwargs["model_client"] = AsyncAnthropic(
349
- api_key=hud_api_key,
350
- base_url=settings.hud_gateway_url,
351
- )
352
- hud_console.info("🌐 Using HUD Gateway for Claude API")
353
- elif self.agent_type in (AgentType.OPENAI, AgentType.OPERATOR):
354
- from openai import AsyncOpenAI
344
+ from hud.agents.gateway import build_gateway_client
355
345
 
356
- kwargs["model_client"] = AsyncOpenAI(
357
- api_key=hud_api_key,
358
- base_url=settings.hud_gateway_url,
359
- )
360
- hud_console.info("🌐 Using HUD Gateway for OpenAI API")
361
- elif self.agent_type == AgentType.OPENAI_COMPATIBLE:
362
- from openai import AsyncOpenAI
346
+ # Map AgentType to provider
347
+ agent_to_provider = {
348
+ AgentType.CLAUDE: "anthropic",
349
+ AgentType.OPENAI: "openai",
350
+ AgentType.OPERATOR: "openai",
351
+ AgentType.GEMINI: "gemini",
352
+ AgentType.GEMINI_CUA: "gemini",
353
+ AgentType.OPENAI_COMPATIBLE: "openai",
354
+ }
355
+ provider = agent_to_provider.get(self.agent_type, "openai")
356
+ client = build_gateway_client(provider)
363
357
 
364
- kwargs["openai_client"] = AsyncOpenAI(
365
- api_key=hud_api_key,
366
- base_url=settings.hud_gateway_url,
367
- )
368
- hud_console.info("🌐 Using HUD Gateway for OpenAI-compatible API")
369
- elif self.agent_type in (AgentType.GEMINI, AgentType.GEMINI_CUA):
370
- from google import genai
371
- from google.genai.types import HttpOptions
372
-
373
- kwargs["model_client"] = genai.Client(
374
- api_key="PLACEHOLDER",
375
- http_options=HttpOptions(
376
- api_version="v1beta",
377
- base_url=settings.hud_gateway_url,
378
- headers={"Authorization": f"Bearer {hud_api_key}"},
379
- ),
380
- )
381
- hud_console.info("🌐 Using HUD Gateway for Gemini API")
358
+ # OpenAI-compatible uses openai_client key
359
+ is_oai_compat = self.agent_type == AgentType.OPENAI_COMPATIBLE
360
+ kwargs["openai_client" if is_oai_compat else "model_client"] = client
361
+ hud_console.info(f"🌐 Using HUD Gateway for {provider} API")
382
362
 
383
363
  return kwargs
384
364
 
@@ -63,7 +63,8 @@ def _load_from_file(path: Path) -> list[Task]:
63
63
  from hud.eval.task import Task
64
64
 
65
65
  raw_items = _load_raw_from_file(path)
66
- return [Task(**item) for item in raw_items]
66
+ # Default args to {} for runnable tasks (None = template)
67
+ return [Task(**{**item, "args": item.get("args") or {}}) for item in raw_items]
67
68
 
68
69
 
69
70
  def _load_raw_from_huggingface(dataset_name: str) -> list[dict[str, Any]]:
@@ -99,7 +100,8 @@ def _load_from_huggingface(dataset_name: str) -> list[Task]:
99
100
  raw_items = _load_raw_from_huggingface(dataset_name)
100
101
  from hud.eval.task import Task
101
102
 
102
- return [Task(**item) for item in raw_items]
103
+ # Default args to {} for runnable tasks (None = template)
104
+ return [Task(**{**item, "args": item.get("args") or {}}) for item in raw_items]
103
105
 
104
106
 
105
107
  def _load_raw_from_api(dataset_name: str) -> list[dict[str, Any]]:
@@ -138,7 +140,8 @@ def _load_from_api(dataset_name: str) -> list[Task]:
138
140
  from hud.eval.task import Task
139
141
 
140
142
  raw_items = _load_raw_from_api(dataset_name)
141
- return [Task(**item) for item in raw_items]
143
+ # Default args to {} for runnable tasks (None = template)
144
+ return [Task(**{**item, "args": item.get("args") or {}}) for item in raw_items]
142
145
 
143
146
 
144
147
  @overload
@@ -40,7 +40,7 @@ async def run_dataset(
40
40
  - A source string (file path, API slug) - loaded via load_tasks()
41
41
  - A single TaskInput (Task, LegacyTask, or dict)
42
42
  - A list of TaskInput objects
43
- agent_type: Type of agent to create (e.g., "claude", "openai", AgentType.CLAUDE).
43
+ agent_type: Agent type (e.g., "claude", "openai", AgentType.CLAUDE).
44
44
  agent_params: Parameters to pass to agent.create().
45
45
  max_steps: Maximum steps per task.
46
46
  max_concurrent: Maximum concurrent tasks (for parallel execution).
@@ -70,6 +70,10 @@ async def run_dataset(
70
70
  from hud.datasets.loader import load_tasks
71
71
  from hud.eval.task import Task
72
72
 
73
+ # Normalize agent_type to AgentType enum
74
+ if isinstance(agent_type, str):
75
+ agent_type = AgentType(agent_type)
76
+
73
77
  # Normalize tasks to list[Task]
74
78
  task_list: list[Task]
75
79
  if isinstance(tasks, str):
@@ -86,10 +90,6 @@ async def run_dataset(
86
90
  if not task_list:
87
91
  raise ValueError("No tasks to run")
88
92
 
89
- # Resolve agent class
90
- agent_type_enum = agent_type if isinstance(agent_type, AgentType) else AgentType(agent_type)
91
- agent_cls = agent_type_enum.cls
92
-
93
93
  # Use hud.eval() for both single and parallel execution
94
94
  async with hud.eval(
95
95
  task_list,
@@ -97,8 +97,8 @@ async def run_dataset(
97
97
  max_concurrent=max_concurrent,
98
98
  quiet=quiet,
99
99
  ) as ctx:
100
- # Create agent fresh for each context (ensures correct tool initialization)
101
- agent = agent_cls.create(**(agent_params or {}))
100
+ # Create agent using AgentType.cls.create()
101
+ agent = agent_type.cls.create(**(agent_params or {}))
102
102
  await agent.run(ctx, max_steps=max_steps)
103
103
  # Reward is computed by EvalContext.__aexit__ from evaluate tools
104
104
 
@@ -198,9 +198,8 @@ async def run_single_task(
198
198
  if ctx.system_prompt and "system_prompt" not in final_agent_params:
199
199
  final_agent_params["system_prompt"] = ctx.system_prompt
200
200
 
201
- # Create agent inside ctx so it has access to context-derived values
202
- agent_cls = agent_type.cls
203
- agent = agent_cls.create(**final_agent_params)
201
+ # Create agent using AgentType.cls.create()
202
+ agent = agent_type.cls.create(**final_agent_params)
204
203
 
205
204
  # Store metadata if provided
206
205
  if metadata: