anthropic 1.80.0 → 1.81.0

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 (359) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/README.md +1 -1
  4. data/lib/anthropic/client.rb +4 -0
  5. data/lib/anthropic/helpers/aws/client.rb +20 -3
  6. data/lib/anthropic/helpers/bedrock/client.rb +6 -0
  7. data/lib/anthropic/helpers/bedrock/mantle_client.rb +41 -2
  8. data/lib/anthropic/helpers/google_cloud/client.rb +113 -31
  9. data/lib/anthropic/helpers/vertex/client.rb +7 -0
  10. data/lib/anthropic/internal/report_page_cursor.rb +98 -0
  11. data/lib/anthropic/internal/stream.rb +6 -13
  12. data/lib/anthropic/internal/tracing.rb +7 -4
  13. data/lib/anthropic/models/beta/beta_cache_miss_messages_changed.rb +8 -0
  14. data/lib/anthropic/models/beta/beta_cache_miss_model_changed.rb +7 -0
  15. data/lib/anthropic/models/beta/beta_cache_miss_previous_message_not_found.rb +9 -0
  16. data/lib/anthropic/models/beta/beta_cache_miss_reason.rb +22 -0
  17. data/lib/anthropic/models/beta/beta_cache_miss_system_changed.rb +7 -0
  18. data/lib/anthropic/models/beta/beta_cache_miss_tools_changed.rb +7 -0
  19. data/lib/anthropic/models/beta/beta_cache_miss_unavailable.rb +11 -0
  20. data/lib/anthropic/models/beta/beta_deleted_user_profile.rb +29 -0
  21. data/lib/anthropic/models/beta/beta_fallback_param.rb +74 -10
  22. data/lib/anthropic/models/beta/beta_managed_agents_deleted_vault.rb +2 -2
  23. data/lib/anthropic/models/beta/beta_managed_agents_memory_store.rb +28 -19
  24. data/lib/anthropic/models/beta/beta_managed_agents_vault.rb +2 -2
  25. data/lib/anthropic/models/beta/beta_user_profile.rb +31 -28
  26. data/lib/anthropic/models/beta/beta_user_profile_enrollment_url.rb +1 -1
  27. data/lib/anthropic/models/beta/memory_store_archive_params.rb +5 -4
  28. data/lib/anthropic/models/beta/memory_store_create_params.rb +20 -11
  29. data/lib/anthropic/models/beta/memory_store_delete_params.rb +5 -4
  30. data/lib/anthropic/models/beta/memory_store_list_params.rb +7 -9
  31. data/lib/anthropic/models/beta/memory_store_retrieve_params.rb +2 -3
  32. data/lib/anthropic/models/beta/memory_store_update_params.rb +19 -14
  33. data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_content_sha256_precondition.rb +6 -6
  34. data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_deleted_memory.rb +13 -6
  35. data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_error.rb +1 -1
  36. data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory.rb +38 -26
  37. data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory_list_item.rb +17 -10
  38. data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory_path_conflict_error.rb +3 -2
  39. data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory_prefix.rb +7 -6
  40. data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory_version.rb +40 -26
  41. data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory_version_operation.rb +4 -2
  42. data/lib/anthropic/models/beta/memory_stores/beta_managed_agents_memory_view.rb +5 -5
  43. data/lib/anthropic/models/beta/memory_stores/memory_create_params.rb +18 -15
  44. data/lib/anthropic/models/beta/memory_stores/memory_list_params.rb +27 -19
  45. data/lib/anthropic/models/beta/memory_stores/memory_retrieve_params.rb +6 -6
  46. data/lib/anthropic/models/beta/memory_stores/memory_update_params.rb +19 -18
  47. data/lib/anthropic/models/beta/memory_stores/memory_version_list_params.rb +13 -10
  48. data/lib/anthropic/models/beta/memory_stores/memory_version_retrieve_params.rb +6 -6
  49. data/lib/anthropic/models/beta/message_count_tokens_params.rb +1 -1
  50. data/lib/anthropic/models/beta/message_create_params.rb +1 -1
  51. data/lib/anthropic/models/beta/messages/batch_create_params.rb +3 -3
  52. data/lib/anthropic/models/beta/organization/beta_organization_rate_limit.rb +2 -1
  53. data/lib/anthropic/models/beta/organization/beta_plugin.rb +34 -9
  54. data/lib/anthropic/models/beta/organization/plugin_marketplace_validate_repository_params.rb +9 -4
  55. data/lib/anthropic/models/beta/organization/plugins/beta_plugin_version.rb +13 -7
  56. data/lib/anthropic/models/beta/organization/workspaces/beta_workspace_rate_limit.rb +1 -1
  57. data/lib/anthropic/models/beta/organization/workspaces/beta_workspace_rate_limit_type.rb +29 -0
  58. data/lib/anthropic/models/beta/organization/workspaces/beta_workspace_rate_limit_update_value.rb +35 -0
  59. data/lib/anthropic/models/beta/organization/workspaces/rate_limit_update_params.rb +45 -0
  60. data/lib/anthropic/models/beta/user_profile_create_enrollment_url_params.rb +2 -3
  61. data/lib/anthropic/models/beta/user_profile_create_params.rb +12 -11
  62. data/lib/anthropic/models/beta/user_profile_delete_params.rb +48 -0
  63. data/lib/anthropic/models/beta/user_profile_list_params.rb +2 -3
  64. data/lib/anthropic/models/beta/user_profile_retrieve_params.rb +2 -3
  65. data/lib/anthropic/models/beta/user_profile_update_params.rb +11 -11
  66. data/lib/anthropic/models/beta/user_profiles/action_url_create_params.rb +58 -0
  67. data/lib/anthropic/models/beta/user_profiles/beta_user_profile_action_url.rb +44 -0
  68. data/lib/anthropic/models/beta/user_profiles/beta_user_profile_enroll_end_user_action.rb +21 -0
  69. data/lib/anthropic/models/beta/vault_list_params.rb +6 -4
  70. data/lib/anthropic/models/beta/vaults/beta_managed_agents_credential.rb +7 -3
  71. data/lib/anthropic/models/beta/vaults/beta_managed_agents_credential_networking_params.rb +1 -1
  72. data/lib/anthropic/models/beta/vaults/beta_managed_agents_credential_validation.rb +3 -2
  73. data/lib/anthropic/models/beta/vaults/beta_managed_agents_credential_validation_status.rb +2 -2
  74. data/lib/anthropic/models/beta/vaults/beta_managed_agents_deleted_credential.rb +2 -2
  75. data/lib/anthropic/models/beta/vaults/beta_managed_agents_environment_variable_auth_response.rb +1 -1
  76. data/lib/anthropic/models/beta/vaults/beta_managed_agents_environment_variable_create_params.rb +7 -2
  77. data/lib/anthropic/models/beta/vaults/beta_managed_agents_environment_variable_update_params.rb +4 -4
  78. data/lib/anthropic/models/beta/vaults/beta_managed_agents_injection_location_update_params.rb +8 -1
  79. data/lib/anthropic/models/beta/vaults/beta_managed_agents_limited_credential_networking_params.rb +7 -5
  80. data/lib/anthropic/models/beta/vaults/beta_managed_agents_limited_credential_networking_response.rb +6 -4
  81. data/lib/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_auth_response.rb +7 -2
  82. data/lib/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_create_params.rb +10 -4
  83. data/lib/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_params.rb +15 -5
  84. data/lib/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_response.rb +2 -2
  85. data/lib/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_update_params.rb +14 -5
  86. data/lib/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_update_params.rb +14 -4
  87. data/lib/anthropic/models/beta/vaults/beta_managed_agents_mcp_probe.rb +4 -3
  88. data/lib/anthropic/models/beta/vaults/beta_managed_agents_static_bearer_create_params.rb +7 -2
  89. data/lib/anthropic/models/beta/vaults/beta_managed_agents_static_bearer_update_params.rb +2 -2
  90. data/lib/anthropic/models/beta/vaults/beta_managed_agents_token_endpoint_auth_basic_param.rb +7 -2
  91. data/lib/anthropic/models/beta/vaults/beta_managed_agents_token_endpoint_auth_basic_update_param.rb +10 -2
  92. data/lib/anthropic/models/beta/vaults/beta_managed_agents_token_endpoint_auth_post_param.rb +2 -2
  93. data/lib/anthropic/models/beta/vaults/beta_managed_agents_token_endpoint_auth_post_update_param.rb +10 -2
  94. data/lib/anthropic/models/beta/vaults/credential_create_params.rb +8 -4
  95. data/lib/anthropic/models/beta/vaults/credential_list_params.rb +6 -4
  96. data/lib/anthropic/models/beta/vaults/credential_update_params.rb +14 -10
  97. data/lib/anthropic/models/cache_miss_messages_changed.rb +8 -0
  98. data/lib/anthropic/models/cache_miss_model_changed.rb +7 -0
  99. data/lib/anthropic/models/cache_miss_previous_message_not_found.rb +9 -0
  100. data/lib/anthropic/models/cache_miss_reason.rb +22 -0
  101. data/lib/anthropic/models/cache_miss_system_changed.rb +7 -0
  102. data/lib/anthropic/models/cache_miss_tools_changed.rb +7 -0
  103. data/lib/anthropic/models/cache_miss_unavailable.rb +11 -0
  104. data/lib/anthropic/models/deleted_user_profile.rb +25 -0
  105. data/lib/anthropic/models/message_count_tokens_params.rb +1 -1
  106. data/lib/anthropic/models/message_create_params.rb +1 -1
  107. data/lib/anthropic/models/messages/batch_create_params.rb +3 -3
  108. data/lib/anthropic/models/organization/organization_rate_limit.rb +2 -1
  109. data/lib/anthropic/models/organization/workspaces/rate_limit_update_params.rb +43 -0
  110. data/lib/anthropic/models/organization/workspaces/workspace_rate_limit.rb +1 -1
  111. data/lib/anthropic/models/organization/workspaces/workspace_rate_limit_type.rb +29 -0
  112. data/lib/anthropic/models/organization/workspaces/workspace_rate_limit_update_value.rb +35 -0
  113. data/lib/anthropic/models/user_profile.rb +108 -0
  114. data/lib/anthropic/models/user_profile_access_type.rb +23 -0
  115. data/lib/anthropic/models/user_profile_create_params.rb +74 -0
  116. data/lib/anthropic/models/user_profile_cyber_program.rb +52 -0
  117. data/lib/anthropic/models/user_profile_cyber_requirements.rb +35 -0
  118. data/lib/anthropic/models/user_profile_cyber_tier.rb +38 -0
  119. data/lib/anthropic/models/user_profile_delete_params.rb +38 -0
  120. data/lib/anthropic/models/user_profile_efs_feature.rb +38 -0
  121. data/lib/anthropic/models/user_profile_efs_program.rb +40 -0
  122. data/lib/anthropic/models/user_profile_external_user_account_status.rb +27 -0
  123. data/lib/anthropic/models/user_profile_external_user_details.rb +78 -0
  124. data/lib/anthropic/models/user_profile_external_user_details_params.rb +79 -0
  125. data/lib/anthropic/models/user_profile_external_user_entity_type.rb +19 -0
  126. data/lib/anthropic/models/user_profile_list_order.rb +19 -0
  127. data/lib/anthropic/models/user_profile_list_order_by.rb +20 -0
  128. data/lib/anthropic/models/user_profile_list_params.rb +67 -0
  129. data/lib/anthropic/models/user_profile_program_status.rb +23 -0
  130. data/lib/anthropic/models/user_profile_programs.rb +41 -0
  131. data/lib/anthropic/models/user_profile_retrieve_params.rb +38 -0
  132. data/lib/anthropic/models/user_profile_update_params.rb +78 -0
  133. data/lib/anthropic/models/user_profiles/action_url_create_params.rb +48 -0
  134. data/lib/anthropic/models/user_profiles/user_profile_action_url.rb +43 -0
  135. data/lib/anthropic/models/user_profiles/user_profile_enroll_end_user_action.rb +21 -0
  136. data/lib/anthropic/models.rb +44 -0
  137. data/lib/anthropic/resources/beta/memory_stores/memories.rb +17 -17
  138. data/lib/anthropic/resources/beta/memory_stores/memory_versions.rb +6 -6
  139. data/lib/anthropic/resources/beta/memory_stores.rb +19 -19
  140. data/lib/anthropic/resources/beta/messages.rb +63 -111
  141. data/lib/anthropic/resources/beta/organization/analytics/cost_report.rb +2 -2
  142. data/lib/anthropic/resources/beta/organization/analytics/usage_report.rb +2 -2
  143. data/lib/anthropic/resources/beta/organization/analytics/user_cost_report.rb +2 -2
  144. data/lib/anthropic/resources/beta/organization/analytics/user_usage_report.rb +2 -2
  145. data/lib/anthropic/resources/beta/organization/workspaces/rate_limits.rb +53 -0
  146. data/lib/anthropic/resources/beta/user_profiles/action_urls.rb +54 -0
  147. data/lib/anthropic/resources/beta/user_profiles.rb +41 -5
  148. data/lib/anthropic/resources/beta/vaults/credentials.rb +9 -9
  149. data/lib/anthropic/resources/beta/vaults.rb +7 -7
  150. data/lib/anthropic/resources/messages.rb +58 -92
  151. data/lib/anthropic/resources/organization/workspaces/rate_limits.rb +49 -0
  152. data/lib/anthropic/resources/user_profiles/action_urls.rb +50 -0
  153. data/lib/anthropic/resources/user_profiles.rb +196 -0
  154. data/lib/anthropic/version.rb +1 -1
  155. data/lib/anthropic.rb +39 -0
  156. data/rbi/anthropic/client.rbi +3 -0
  157. data/rbi/anthropic/helpers/aws/client.rbi +13 -0
  158. data/rbi/anthropic/helpers/bedrock/client.rbi +4 -0
  159. data/rbi/anthropic/helpers/bedrock/mantle_client.rbi +9 -0
  160. data/rbi/anthropic/helpers/google_cloud/client.rbi +19 -2
  161. data/rbi/anthropic/helpers/vertex/client.rbi +4 -0
  162. data/rbi/anthropic/internal/report_page_cursor.rbi +28 -0
  163. data/rbi/anthropic/internal/tracing.rbi +9 -4
  164. data/rbi/anthropic/models/beta/beta_cache_miss_messages_changed.rbi +7 -0
  165. data/rbi/anthropic/models/beta/beta_cache_miss_model_changed.rbi +6 -0
  166. data/rbi/anthropic/models/beta/beta_cache_miss_previous_message_not_found.rbi +8 -0
  167. data/rbi/anthropic/models/beta/beta_cache_miss_system_changed.rbi +6 -0
  168. data/rbi/anthropic/models/beta/beta_cache_miss_tools_changed.rbi +6 -0
  169. data/rbi/anthropic/models/beta/beta_cache_miss_unavailable.rbi +10 -0
  170. data/rbi/anthropic/models/beta/beta_deleted_user_profile.rbi +40 -0
  171. data/rbi/anthropic/models/beta/beta_fallback_param.rbi +116 -9
  172. data/rbi/anthropic/models/beta/beta_managed_agents_deleted_vault.rbi +2 -2
  173. data/rbi/anthropic/models/beta/beta_managed_agents_memory_store.rbi +44 -26
  174. data/rbi/anthropic/models/beta/beta_managed_agents_vault.rbi +2 -2
  175. data/rbi/anthropic/models/beta/beta_user_profile.rbi +50 -43
  176. data/rbi/anthropic/models/beta/beta_user_profile_enrollment_url.rbi +1 -1
  177. data/rbi/anthropic/models/beta/memory_store_archive_params.rbi +8 -6
  178. data/rbi/anthropic/models/beta/memory_store_create_params.rbi +34 -16
  179. data/rbi/anthropic/models/beta/memory_store_delete_params.rbi +8 -6
  180. data/rbi/anthropic/models/beta/memory_store_list_params.rbi +8 -12
  181. data/rbi/anthropic/models/beta/memory_store_retrieve_params.rbi +2 -4
  182. data/rbi/anthropic/models/beta/memory_store_update_params.rbi +30 -20
  183. data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_content_sha256_precondition.rbi +6 -6
  184. data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_deleted_memory.rbi +13 -6
  185. data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_memory.rbi +54 -36
  186. data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_memory_list_item.rbi +25 -18
  187. data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_memory_path_conflict_error.rbi +3 -2
  188. data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_memory_prefix.rbi +7 -6
  189. data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_memory_version.rbi +60 -38
  190. data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_memory_version_operation.rbi +4 -2
  191. data/rbi/anthropic/models/beta/memory_stores/beta_managed_agents_memory_view.rbi +5 -5
  192. data/rbi/anthropic/models/beta/memory_stores/memory_create_params.rbi +30 -24
  193. data/rbi/anthropic/models/beta/memory_stores/memory_list_params.rbi +44 -28
  194. data/rbi/anthropic/models/beta/memory_stores/memory_retrieve_params.rbi +10 -10
  195. data/rbi/anthropic/models/beta/memory_stores/memory_update_params.rbi +32 -30
  196. data/rbi/anthropic/models/beta/memory_stores/memory_version_list_params.rbi +22 -16
  197. data/rbi/anthropic/models/beta/memory_stores/memory_version_retrieve_params.rbi +10 -10
  198. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +2 -2
  199. data/rbi/anthropic/models/beta/message_create_params.rbi +2 -2
  200. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +6 -6
  201. data/rbi/anthropic/models/beta/organization/beta_organization_rate_limit.rbi +4 -2
  202. data/rbi/anthropic/models/beta/organization/beta_plugin.rbi +49 -11
  203. data/rbi/anthropic/models/beta/organization/plugin_marketplace_validate_repository_params.rbi +18 -8
  204. data/rbi/anthropic/models/beta/organization/plugins/beta_plugin_version.rbi +20 -8
  205. data/rbi/anthropic/models/beta/organization/workspaces/beta_workspace_rate_limit_type.rbi +81 -0
  206. data/rbi/anthropic/models/beta/organization/workspaces/beta_workspace_rate_limit_update_value.rbi +62 -0
  207. data/rbi/anthropic/models/beta/organization/workspaces/rate_limit_update_params.rbi +80 -0
  208. data/rbi/anthropic/models/beta/user_profile_create_enrollment_url_params.rbi +2 -4
  209. data/rbi/anthropic/models/beta/user_profile_create_params.rbi +22 -20
  210. data/rbi/anthropic/models/beta/user_profile_delete_params.rbi +91 -0
  211. data/rbi/anthropic/models/beta/user_profile_list_params.rbi +2 -4
  212. data/rbi/anthropic/models/beta/user_profile_retrieve_params.rbi +2 -4
  213. data/rbi/anthropic/models/beta/user_profile_update_params.rbi +20 -20
  214. data/rbi/anthropic/models/beta/user_profiles/action_url_create_params.rbi +116 -0
  215. data/rbi/anthropic/models/beta/user_profiles/beta_user_profile_action_url.rbi +55 -0
  216. data/rbi/anthropic/models/beta/user_profiles/beta_user_profile_enroll_end_user_action.rbi +31 -0
  217. data/rbi/anthropic/models/beta/vault_list_params.rbi +8 -4
  218. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_credential.rbi +4 -3
  219. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_credential_networking_params.rbi +6 -4
  220. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_credential_validation.rbi +4 -2
  221. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_credential_validation_status.rbi +2 -2
  222. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_deleted_credential.rbi +2 -2
  223. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_environment_variable_auth_response.rbi +5 -3
  224. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_environment_variable_create_params.rbi +4 -2
  225. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_environment_variable_update_params.rbi +4 -4
  226. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_injection_location_update_params.rbi +8 -1
  227. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_limited_credential_networking_params.rbi +12 -8
  228. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_limited_credential_networking_response.rbi +10 -6
  229. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_auth_response.rbi +4 -2
  230. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_create_params.rbi +8 -4
  231. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_params.rbi +10 -5
  232. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_response.rbi +2 -2
  233. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_refresh_update_params.rbi +11 -5
  234. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_mcp_oauth_update_params.rbi +16 -4
  235. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_mcp_probe.rbi +6 -4
  236. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_static_bearer_create_params.rbi +4 -2
  237. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_static_bearer_update_params.rbi +2 -2
  238. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_token_endpoint_auth_basic_param.rbi +4 -2
  239. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_token_endpoint_auth_basic_update_param.rbi +10 -2
  240. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_token_endpoint_auth_post_param.rbi +2 -2
  241. data/rbi/anthropic/models/beta/vaults/beta_managed_agents_token_endpoint_auth_post_update_param.rbi +10 -2
  242. data/rbi/anthropic/models/beta/vaults/credential_create_params.rbi +8 -4
  243. data/rbi/anthropic/models/beta/vaults/credential_list_params.rbi +8 -4
  244. data/rbi/anthropic/models/beta/vaults/credential_update_params.rbi +17 -11
  245. data/rbi/anthropic/models/cache_miss_messages_changed.rbi +7 -0
  246. data/rbi/anthropic/models/cache_miss_model_changed.rbi +6 -0
  247. data/rbi/anthropic/models/cache_miss_previous_message_not_found.rbi +8 -0
  248. data/rbi/anthropic/models/cache_miss_system_changed.rbi +6 -0
  249. data/rbi/anthropic/models/cache_miss_tools_changed.rbi +6 -0
  250. data/rbi/anthropic/models/cache_miss_unavailable.rbi +10 -0
  251. data/rbi/anthropic/models/deleted_user_profile.rbi +33 -0
  252. data/rbi/anthropic/models/message_count_tokens_params.rbi +2 -2
  253. data/rbi/anthropic/models/message_create_params.rbi +2 -2
  254. data/rbi/anthropic/models/messages/batch_create_params.rbi +6 -6
  255. data/rbi/anthropic/models/organization/organization_rate_limit.rbi +4 -2
  256. data/rbi/anthropic/models/organization/workspaces/rate_limit_update_params.rbi +78 -0
  257. data/rbi/anthropic/models/organization/workspaces/workspace_rate_limit_type.rbi +81 -0
  258. data/rbi/anthropic/models/organization/workspaces/workspace_rate_limit_update_value.rbi +62 -0
  259. data/rbi/anthropic/models/user_profile.rbi +152 -0
  260. data/rbi/anthropic/models/user_profile_access_type.rbi +34 -0
  261. data/rbi/anthropic/models/user_profile_create_params.rbi +135 -0
  262. data/rbi/anthropic/models/user_profile_cyber_program.rbi +95 -0
  263. data/rbi/anthropic/models/user_profile_cyber_requirements.rbi +52 -0
  264. data/rbi/anthropic/models/user_profile_cyber_tier.rbi +69 -0
  265. data/rbi/anthropic/models/user_profile_delete_params.rbi +67 -0
  266. data/rbi/anthropic/models/user_profile_efs_feature.rbi +69 -0
  267. data/rbi/anthropic/models/user_profile_efs_program.rbi +66 -0
  268. data/rbi/anthropic/models/user_profile_external_user_account_status.rbi +52 -0
  269. data/rbi/anthropic/models/user_profile_external_user_details.rbi +125 -0
  270. data/rbi/anthropic/models/user_profile_external_user_details_params.rbi +131 -0
  271. data/rbi/anthropic/models/user_profile_external_user_entity_type.rbi +46 -0
  272. data/rbi/anthropic/models/user_profile_list_order.rbi +28 -0
  273. data/rbi/anthropic/models/user_profile_list_order_by.rbi +30 -0
  274. data/rbi/anthropic/models/user_profile_list_params.rbi +110 -0
  275. data/rbi/anthropic/models/user_profile_program_status.rbi +34 -0
  276. data/rbi/anthropic/models/user_profile_programs.rbi +77 -0
  277. data/rbi/anthropic/models/user_profile_retrieve_params.rbi +67 -0
  278. data/rbi/anthropic/models/user_profile_update_params.rbi +130 -0
  279. data/rbi/anthropic/models/user_profiles/action_url_create_params.rbi +86 -0
  280. data/rbi/anthropic/models/user_profiles/user_profile_action_url.rbi +55 -0
  281. data/rbi/anthropic/models/user_profiles/user_profile_enroll_end_user_action.rbi +32 -0
  282. data/rbi/anthropic/models.rbi +48 -0
  283. data/rbi/anthropic/resources/beta/memory_stores/memories.rbi +65 -51
  284. data/rbi/anthropic/resources/beta/memory_stores/memory_versions.rbi +19 -16
  285. data/rbi/anthropic/resources/beta/memory_stores.rbi +53 -38
  286. data/rbi/anthropic/resources/beta/messages/batches.rbi +3 -4
  287. data/rbi/anthropic/resources/beta/messages.rbi +192 -198
  288. data/rbi/anthropic/resources/beta/organization/analytics/cost_report.rbi +1 -1
  289. data/rbi/anthropic/resources/beta/organization/analytics/usage_report.rbi +1 -1
  290. data/rbi/anthropic/resources/beta/organization/analytics/user_cost_report.rbi +1 -1
  291. data/rbi/anthropic/resources/beta/organization/analytics/user_usage_report.rbi +1 -1
  292. data/rbi/anthropic/resources/beta/organization/plugin_marketplaces.rbi +9 -4
  293. data/rbi/anthropic/resources/beta/organization/workspaces/rate_limits.rbi +35 -0
  294. data/rbi/anthropic/resources/beta/user_profiles/action_urls.rbi +46 -0
  295. data/rbi/anthropic/resources/beta/user_profiles.rbi +51 -28
  296. data/rbi/anthropic/resources/beta/vaults/credentials.rbi +13 -11
  297. data/rbi/anthropic/resources/beta/vaults.rbi +10 -7
  298. data/rbi/anthropic/resources/messages/batches.rbi +3 -4
  299. data/rbi/anthropic/resources/messages.rbi +122 -132
  300. data/rbi/anthropic/resources/organization/workspaces/rate_limits.rbi +33 -0
  301. data/rbi/anthropic/resources/user_profiles/action_urls.rbi +40 -0
  302. data/rbi/anthropic/resources/user_profiles.rbi +184 -0
  303. data/sig/anthropic/client.rbs +2 -0
  304. data/sig/anthropic/helpers/bedrock/client.rbs +2 -0
  305. data/sig/anthropic/helpers/google_cloud/client.rbs +10 -1
  306. data/sig/anthropic/helpers/vertex/client.rbs +2 -0
  307. data/sig/anthropic/internal/report_page_cursor.rbs +17 -0
  308. data/sig/anthropic/internal/tracing.rbs +7 -4
  309. data/sig/anthropic/models/beta/beta_deleted_user_profile.rbs +20 -0
  310. data/sig/anthropic/models/beta/beta_user_profile.rbs +8 -8
  311. data/sig/anthropic/models/beta/organization/workspaces/beta_workspace_rate_limit_type.rbs +36 -0
  312. data/sig/anthropic/models/beta/organization/workspaces/beta_workspace_rate_limit_update_value.rbs +31 -0
  313. data/sig/anthropic/models/beta/organization/workspaces/rate_limit_update_params.rbs +42 -0
  314. data/sig/anthropic/models/beta/user_profile_delete_params.rbs +44 -0
  315. data/sig/anthropic/models/beta/user_profiles/action_url_create_params.rbs +51 -0
  316. data/sig/anthropic/models/beta/user_profiles/beta_user_profile_action_url.rbs +30 -0
  317. data/sig/anthropic/models/beta/user_profiles/beta_user_profile_enroll_end_user_action.rbs +18 -0
  318. data/sig/anthropic/models/beta/vaults/beta_managed_agents_credential_validation_status.rbs +2 -2
  319. data/sig/anthropic/models/deleted_user_profile.rbs +15 -0
  320. data/sig/anthropic/models/organization/workspaces/rate_limit_update_params.rbs +40 -0
  321. data/sig/anthropic/models/organization/workspaces/workspace_rate_limit_type.rbs +36 -0
  322. data/sig/anthropic/models/organization/workspaces/workspace_rate_limit_update_value.rbs +31 -0
  323. data/sig/anthropic/models/user_profile.rbs +60 -0
  324. data/sig/anthropic/models/user_profile_access_type.rbs +17 -0
  325. data/sig/anthropic/models/user_profile_create_params.rbs +58 -0
  326. data/sig/anthropic/models/user_profile_cyber_program.rbs +30 -0
  327. data/sig/anthropic/models/user_profile_cyber_requirements.rbs +16 -0
  328. data/sig/anthropic/models/user_profile_cyber_tier.rbs +29 -0
  329. data/sig/anthropic/models/user_profile_delete_params.rbs +30 -0
  330. data/sig/anthropic/models/user_profile_efs_feature.rbs +29 -0
  331. data/sig/anthropic/models/user_profile_efs_program.rbs +25 -0
  332. data/sig/anthropic/models/user_profile_external_user_account_status.rbs +21 -0
  333. data/sig/anthropic/models/user_profile_external_user_details.rbs +50 -0
  334. data/sig/anthropic/models/user_profile_external_user_details_params.rbs +52 -0
  335. data/sig/anthropic/models/user_profile_external_user_entity_type.rbs +17 -0
  336. data/sig/anthropic/models/user_profile_list_order.rbs +17 -0
  337. data/sig/anthropic/models/user_profile_list_order_by.rbs +17 -0
  338. data/sig/anthropic/models/user_profile_list_params.rbs +60 -0
  339. data/sig/anthropic/models/user_profile_program_status.rbs +20 -0
  340. data/sig/anthropic/models/user_profile_programs.rbs +25 -0
  341. data/sig/anthropic/models/user_profile_retrieve_params.rbs +30 -0
  342. data/sig/anthropic/models/user_profile_update_params.rbs +59 -0
  343. data/sig/anthropic/models/user_profiles/action_url_create_params.rbs +40 -0
  344. data/sig/anthropic/models/user_profiles/user_profile_action_url.rbs +30 -0
  345. data/sig/anthropic/models/user_profiles/user_profile_enroll_end_user_action.rbs +17 -0
  346. data/sig/anthropic/models.rbs +44 -0
  347. data/sig/anthropic/resources/beta/messages.rbs +24 -24
  348. data/sig/anthropic/resources/beta/organization/analytics/cost_report.rbs +1 -1
  349. data/sig/anthropic/resources/beta/organization/analytics/usage_report.rbs +1 -1
  350. data/sig/anthropic/resources/beta/organization/analytics/user_cost_report.rbs +1 -1
  351. data/sig/anthropic/resources/beta/organization/analytics/user_usage_report.rbs +1 -1
  352. data/sig/anthropic/resources/beta/organization/workspaces/rate_limits.rbs +7 -0
  353. data/sig/anthropic/resources/beta/user_profiles/action_urls.rbs +19 -0
  354. data/sig/anthropic/resources/beta/user_profiles.rbs +9 -0
  355. data/sig/anthropic/resources/messages.rbs +19 -19
  356. data/sig/anthropic/resources/organization/workspaces/rate_limits.rbs +7 -0
  357. data/sig/anthropic/resources/user_profiles/action_urls.rbs +16 -0
  358. data/sig/anthropic/resources/user_profiles.rbs +49 -0
  359. metadata +119 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e0c2457772d14d2f544f1e29c0257bb58470949ad75041d38a87337ef6588eb
4
- data.tar.gz: f3a5fe15373f2aa6391d7ed66ed73687b46523d92fb359e4a9621df437183063
3
+ metadata.gz: 154fbf0eeb1ef7997d8bc33f44e588fbe3fb3327aed6be57fba6d6459703d580
4
+ data.tar.gz: 974d03138f614db3ecc816de5c3d25e4862951faf84b0679ee8058758a89789e
5
5
  SHA512:
6
- metadata.gz: 519eadd659c81d42cff516a695728b4bf93f69f6ad8fe7b931e765673421e427f6f8f00c35154c41ed4e5b211119150ce9949bc97cbe19d63893738ca15c2dbd
7
- data.tar.gz: '088cd32906704806d4be30d6ddf5291d4a3565b1780bf9f6ba87b1a2bf26fa501a2d158e7743d5afe2a4adda9c8762d94acbe6df91a077db75319d64ce065fc5'
6
+ metadata.gz: e8701990520600baf05a9a240c836ba0245272b08a4df77a52d13da4d6c29cfaf4c884671ec3d2e8cec60a067ab5a859feff5630dbe1d3b796372bf691402408
7
+ data.tar.gz: bdad1379435404bc3ad2ab1534024c9a7baaa3bfbce296080e51fec7a31c9f1a95650f86c3e42ff94eb9b1dcd30c3f412bca8718148cbbd50b05b33c05624392
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.81.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.80.0...v1.81.0) (2026-10-20)
4
+
5
+ ### Features
6
+
7
+ * **api:** add data_refreshed_at and has_more to analytics report pages
8
+ * **api:** add workspace rate-limit updates to the Admin API
9
+ * **api:** make User Profiles generally available
10
+ * **client:** yield server-sent events with unrecognized event names
11
+ * **google-cloud:** use the v1 endpoints and add the organization endpoint
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * **client:** `messages.stream` and `beta.messages.stream` now take the same parameters as `stream_raw`; their Sorbet and RBS signatures take one params hash
17
+ * **types:** type the keyword parameters of messages.stream and beta.messages.stream
18
+
19
+
20
+ ### Chores
21
+
22
+ * **ci:** publish gems from a fixed Ubuntu 24.04 runner
23
+ * **ci:** set up Ruby 3.2 with a newer setup-ruby in the build and dependency version jobs
24
+ * **ci:** skip the changelog check on draft pull requests
25
+ * **docs:** add credential expiry descriptions to the Managed Agents API reference
26
+ * **docs:** add Messages API request descriptions
27
+ * **docs:** correct plugin manifest_version and reach descriptions
28
+ * **docs:** improve Managed Agents memory store descriptions
29
+ * **docs:** improve Managed Agents vault and credential descriptions
30
+ * **tests:** cover per-request timeouts and later union variants
31
+ * **tests:** make the tracing tests independent of test order
32
+ * **tests:** send events that the stream yields in the tracing test
33
+
3
34
  ## [1.80.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.79.0...v1.80.0) (2026-10-15)
4
35
 
5
36
  ### Features
data/README.md CHANGED
@@ -15,7 +15,7 @@ Add to your application's Gemfile:
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "anthropic", "~> 1.80.0"
18
+ gem "anthropic", "~> 1.81.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -82,6 +82,9 @@ module Anthropic
82
82
  # @return [Anthropic::Resources::Skills]
83
83
  attr_reader :skills
84
84
 
85
+ # @return [Anthropic::Resources::UserProfiles]
86
+ attr_reader :user_profiles
87
+
85
88
  # @return [Anthropic::Resources::Organization]
86
89
  attr_reader :organization
87
90
 
@@ -342,6 +345,7 @@ module Anthropic
342
345
  @models = Anthropic::Resources::Models.new(client: self)
343
346
  @files = Anthropic::Resources::Files.new(client: self)
344
347
  @skills = Anthropic::Resources::Skills.new(client: self)
348
+ @user_profiles = Anthropic::Resources::UserProfiles.new(client: self)
345
349
  @organization = Anthropic::Resources::Organization.new(client: self)
346
350
  @beta = Anthropic::Resources::Beta.new(client: self)
347
351
  end
@@ -91,9 +91,9 @@ module Anthropic
91
91
 
92
92
  # In API-key mode the gateway key rides the base client's `api_key`
93
93
  # slot; {#resolve_default_credentials?} keeps first-party credential
94
- # auto-discovery out of the picture when it is absent. The gateway
95
- # serves the full first-party API, so every resource the parent wires
96
- # up stays available.
94
+ # auto-discovery out of the picture when it is absent. Every resource
95
+ # the parent wires up stays available; {#build_request} rejects the
96
+ # one route the gateway does not serve.
97
97
  super(
98
98
  api_key: effective_api_key,
99
99
  base_url: resolved_base_url,
@@ -105,6 +105,23 @@ module Anthropic
105
105
  )
106
106
  end
107
107
 
108
+ # @api private
109
+ #
110
+ # Fails fast on user profile action URLs, which the gateway does not serve.
111
+ #
112
+ # @param req [Hash{Symbol=>Object}]
113
+ # @param opts [Hash{Symbol=>Object}]
114
+ # @return [Hash{Symbol=>Object}]
115
+ private def build_request(req, opts)
116
+ # Id-parameterized routes pass `path` as an Array whose first element
117
+ # is the format string (e.g. `["v1/user_profiles/%1$s/action_urls", id]`).
118
+ if Array(req[:path]).first.to_s.match?(%r{\Av1/user_profiles/[^/]+/action_urls})
119
+ raise NotImplementedError.new("User profile action URLs are not supported on the AWS gateway.")
120
+ end
121
+
122
+ super
123
+ end
124
+
108
125
  # @api private
109
126
  #
110
127
  # @return [String]
@@ -169,6 +169,10 @@ module Anthropic
169
169
  raise NotImplementedError, "Skills are not supported on Bedrock."
170
170
  end
171
171
 
172
+ def user_profiles
173
+ raise NotImplementedError, "User profiles are not supported on Bedrock."
174
+ end
175
+
172
176
  # @api private
173
177
  #
174
178
  # @param req [Hash{Symbol=>Object}] .
@@ -318,6 +322,8 @@ module Anthropic
318
322
  message = "Please instead use https://docs.anthropic.com/en/api/claude-on-amazon-bedrock#list-available-models to list available models on Bedrock."
319
323
  # rubocop:enable Layout/LineLength
320
324
  raise NotImplementedError.new(message)
325
+ in %r{^v1/user_profiles}
326
+ raise NotImplementedError.new("User profiles are not supported on Bedrock.")
321
327
  else
322
328
  end
323
329
  end
@@ -131,6 +131,13 @@ module Anthropic
131
131
  "Skills are not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported."
132
132
  end
133
133
 
134
+ # User profiles are not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported.
135
+ def user_profiles
136
+ raise NotImplementedError,
137
+ "User profiles are not supported on Bedrock Mantle. " \
138
+ "Only Messages (/v1/messages) is supported."
139
+ end
140
+
134
141
  # @api private
135
142
  #
136
143
  # @return [Hash{String=>String}]
@@ -146,10 +153,36 @@ module Anthropic
146
153
  # @api private
147
154
  #
148
155
  # @return [#call]
149
- private def provider_middleware = method(:aws_auth_provider)
156
+ private def provider_middleware
157
+ ->(req, nxt) { aws_auth_provider(adapt_request(req), nxt) }
158
+ end
159
+
160
+ # @api private
161
+ #
162
+ # Mantle drops custom request headers, so Messages and token counting send the user profile ID
163
+ # in the body.
164
+ #
165
+ # @param req [Anthropic::APIRequest]
166
+ # @return [Anthropic::APIRequest]
167
+ private def adapt_request(req)
168
+ path = req.url.path.to_s
169
+ return req unless req.method == :post && path.end_with?("/v1/messages", "/v1/messages/count_tokens")
170
+
171
+ body = req.body
172
+ profile_headers, headers = req.headers.partition do |name, _|
173
+ name.to_s.casecmp?("anthropic-user-profile-id")
174
+ end
175
+ user_profile_id = profile_headers.last&.last
176
+ return req if user_profile_id.to_s.empty? || !body.is_a?(Hash)
177
+
178
+ unless body.keys.any? { _1.to_s == "user_profile_id" }
179
+ body = {**body, user_profile_id: user_profile_id}
180
+ end
181
+ req.with(headers: headers.to_h, body: body)
182
+ end
150
183
 
151
184
  # Restricted Beta service that only exposes messages. Other beta resources
152
- # (models, files, skills) are not supported on Bedrock Mantle.
185
+ # (models, files, skills, user profiles) are not supported on Bedrock Mantle.
153
186
  class MantleBeta
154
187
  # @return [Anthropic::Resources::Beta::Messages]
155
188
  attr_reader :messages
@@ -173,6 +206,12 @@ module Anthropic
173
206
  raise NotImplementedError,
174
207
  "Beta skills are not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported."
175
208
  end
209
+
210
+ def user_profiles
211
+ raise NotImplementedError,
212
+ "Beta user profiles are not supported on Bedrock Mantle. " \
213
+ "Only Messages (/v1/messages) is supported."
214
+ end
176
215
  end
177
216
  end
178
217
  end
@@ -10,17 +10,26 @@ module Anthropic
10
10
  # `:rawPredict` publisher-model API (publisher model IDs, messages
11
11
  # only). This client speaks the full first-party Anthropic API: requests
12
12
  # pass through the gateway unchanged — standard `/v1/*` paths, standard
13
- # model names, the complete API surface. The deprecated text Completions
14
- # endpoint is intentionally not exposed.
13
+ # model names. The deprecated text Completions endpoint is intentionally
14
+ # not exposed, and the gateway does not serve the User Profiles API.
15
15
  class Client < Anthropic::Client
16
16
  # OAuth2 scope required to call the gateway.
17
17
  SCOPE = "https://www.googleapis.com/auth/cloud-platform"
18
18
 
19
+ LOCATION_URL_TEMPLATE =
20
+ "https://claude.googleapis.com/v1/projects/%<project>s/locations/%<location>s"
21
+
19
22
  # Gateway base URL template; override via `base_url` or
20
23
  # `ANTHROPIC_GOOGLE_CLOUD_BASE_URL`.
21
- URL_TEMPLATE =
22
- "https://claude.googleapis.com/v1alpha" \
23
- "/projects/%<project>s/locations/%<location>s/workspaces/%<workspace_id>s/invoke"
24
+ URL_TEMPLATE = "#{LOCATION_URL_TEMPLATE}/workspaces/%<workspace_id>s/invoke".freeze
25
+
26
+ # Gateway base URL template for organization-level routes, which are
27
+ # served from a base with no workspace in it.
28
+ ORGANIZATION_URL_TEMPLATE = "#{LOCATION_URL_TEMPLATE}/claudeOrganization/invoke".freeze
29
+
30
+ ORGANIZATION_PATH_PREFIX = "/v1/organizations/"
31
+
32
+ private_constant :LOCATION_URL_TEMPLATE, :ORGANIZATION_PATH_PREFIX
24
33
 
25
34
  # @return [String, nil]
26
35
  attr_reader :project
@@ -53,12 +62,14 @@ module Anthropic
53
62
  # explicit `nil` falls back to the same defaults.
54
63
  #
55
64
  # @param workspace_id [String, nil] Defaults to
56
- # `ENV["ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID"]`. Required unless
57
- # `skip_auth` is true and an explicit `base_url` is given.
65
+ # `ENV["ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID"]`. Required when the base
66
+ # URL is derived, except for organization-level routes
67
+ # (`/v1/organizations/`), which need no workspace ID.
58
68
  #
59
- # @param base_url [String, nil] Override the gateway base URL. Defaults to
60
- # `ENV["ANTHROPIC_GOOGLE_CLOUD_BASE_URL"]`, otherwise derived from
61
- # `project`, `location`, and `workspace_id` via {URL_TEMPLATE}.
69
+ # @param base_url [String, nil] Override the gateway base URL for every
70
+ # route. Defaults to `ENV["ANTHROPIC_GOOGLE_CLOUD_BASE_URL"]`, otherwise
71
+ # derived from `project`, `location`, and `workspace_id` via
72
+ # {URL_TEMPLATE}.
62
73
  #
63
74
  # @param google_credentials [#apply, nil] A `googleauth`-compatible
64
75
  # credentials object. Mutually exclusive with `skip_auth`.
@@ -67,10 +78,9 @@ module Anthropic
67
78
  # token string. Takes precedence over `google_credentials`. Mutually
68
79
  # exclusive with `skip_auth`.
69
80
  #
70
- # @param skip_auth [Boolean] When true, no token is attached and
71
- # `workspace_id` is only required when the base URL must be derived.
72
- # For callers fronting with their own authenticated proxy. Mutually
73
- # exclusive with `token_provider` and `google_credentials`.
81
+ # @param skip_auth [Boolean] When true, no token is attached. For callers
82
+ # fronting with their own authenticated proxy. Mutually exclusive with
83
+ # `token_provider` and `google_credentials`.
74
84
  #
75
85
  # @param max_retries [Integer] Max number of retries to attempt after a
76
86
  # failed retryable request.
@@ -132,23 +142,23 @@ module Anthropic
132
142
  # so nil can't reach the derived URL (matches the other SDKs).
133
143
  @location = location || ENV["ANTHROPIC_GOOGLE_CLOUD_LOCATION"] || "global"
134
144
 
135
- if workspace_id.nil? && !skip_auth
136
- raise ArgumentError.new(
137
- "No workspace ID was given. Set the `workspace_id` argument or the " \
138
- "`ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID` environment variable."
139
- )
140
- end
141
145
  @workspace_id = workspace_id
142
146
 
143
147
  base_url = nil if base_url.to_s.empty?
144
- base_url ||= derive_base_url
148
+ unless base_url
149
+ @organization_base_url = URI.parse(derive_base_url(ORGANIZATION_URL_TEMPLATE))
150
+ # Without a workspace ID there is no workspace base to derive, so
151
+ # `base_url` is the organization base.
152
+ base_url = @workspace_id.nil? ? @organization_base_url.to_s : derive_base_url(URL_TEMPLATE)
153
+ end
145
154
 
146
155
  # No first-party credential is ever passed up, and
147
156
  # {#resolve_default_credentials?} keeps the parent from discovering
148
157
  # one; `base_url` is always resolved by this point, so the parent's
149
158
  # `ANTHROPIC_BASE_URL` fallback never applies. The parent wires up
150
- # every resource; {#completions} withholds the one the gateway does
151
- # not serve.
159
+ # every resource; {#completions} and {#user_profiles} withhold the
160
+ # ones the gateway does not serve, and {#build_request} refuses the
161
+ # user profile routes however the resource is reached.
152
162
  super(
153
163
  base_url: base_url,
154
164
  timeout: timeout,
@@ -176,6 +186,83 @@ module Anthropic
176
186
  )
177
187
  end
178
188
 
189
+ # User profiles are not supported on the Google Cloud gateway.
190
+ #
191
+ # @raise [NotImplementedError]
192
+ def user_profiles
193
+ raise NotImplementedError.new("User profiles are not supported on the Google Cloud gateway.")
194
+ end
195
+
196
+ # @api private
197
+ #
198
+ # @param req [Hash{Symbol=>Object}] .
199
+ #
200
+ # @option req [Symbol] :method
201
+ #
202
+ # @option req [String, Array<String>] :path
203
+ #
204
+ # @option req [Hash{String=>Array<String>, String, nil}, nil] :query
205
+ #
206
+ # @option req [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}, nil] :headers
207
+ #
208
+ # @option req [Object, nil] :body
209
+ #
210
+ # @option req [Symbol, Integer, Array<Symbol, Integer>, Proc, nil] :unwrap
211
+ #
212
+ # @option req [Class<Anthropic::Internal::Type::BasePage>, nil] :page
213
+ #
214
+ # @option req [Class<Anthropic::Internal::Type::BaseStream>, nil] :stream
215
+ #
216
+ # @option req [Anthropic::Internal::Type::Converter, Class, nil] :model
217
+ #
218
+ # @param opts [Hash{Symbol=>Object}] .
219
+ #
220
+ # @option opts [String, nil] :idempotency_key
221
+ #
222
+ # @option opts [Hash{String=>Array<String>, String, nil}, nil] :extra_query
223
+ #
224
+ # @option opts [Hash{String=>String, nil}, nil] :extra_headers
225
+ #
226
+ # @option opts [Object, nil] :extra_body
227
+ #
228
+ # @option opts [Integer, nil] :max_retries
229
+ #
230
+ # @option opts [Float, nil] :timeout
231
+ #
232
+ # @raise [ArgumentError]
233
+ # @raise [NotImplementedError]
234
+ # @return [Hash{Symbol=>Object}]
235
+ private def build_request(req, opts)
236
+ # Id-parameterized routes pass `path` as an Array whose first element
237
+ # is the format string (e.g. `["v1/user_profiles/%1$s", id]`).
238
+ if Array(req[:path]).first.to_s.start_with?("v1/user_profiles")
239
+ raise NotImplementedError.new("User profiles are not supported on the Google Cloud gateway.")
240
+ end
241
+
242
+ request = super
243
+ return request if @organization_base_url.nil?
244
+
245
+ url = request.fetch(:url)
246
+ under_base_url =
247
+ url.path.start_with?("#{base_url.path}/") &&
248
+ Anthropic::Internal::Util.uri_origin(url) == Anthropic::Internal::Util.uri_origin(base_url)
249
+ return request unless under_base_url
250
+
251
+ path = url.path.delete_prefix(base_url.path)
252
+ if path.start_with?(ORGANIZATION_PATH_PREFIX)
253
+ url = url.dup
254
+ url.path = "#{@organization_base_url.path}#{path}"
255
+ {**request, url: url}
256
+ elsif @workspace_id.nil?
257
+ raise ArgumentError.new(
258
+ "No workspace ID was given. Set the `workspace_id` argument or the " \
259
+ "`ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID` environment variable."
260
+ )
261
+ else
262
+ request
263
+ end
264
+ end
265
+
179
266
  # @api private
180
267
  #
181
268
  # Hard guarantee that no first-party `X-Api-Key` / `Authorization`
@@ -230,9 +317,10 @@ module Anthropic
230
317
 
231
318
  # @api private
232
319
  #
320
+ # @param template [String]
233
321
  # @return [String]
234
322
  # @raise [ArgumentError]
235
- private def derive_base_url
323
+ private def derive_base_url(template)
236
324
  if @project.nil?
237
325
  raise ArgumentError.new(
238
326
  "No project found. Set the `project` argument, set the " \
@@ -240,13 +328,7 @@ module Anthropic
240
328
  "application default credentials with a project."
241
329
  )
242
330
  end
243
- if @workspace_id.nil?
244
- raise ArgumentError.new(
245
- "No workspace ID was given. Set the `workspace_id` argument or the " \
246
- "`ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID` environment variable."
247
- )
248
- end
249
- format(URL_TEMPLATE, project: @project, location: @location, workspace_id: @workspace_id)
331
+ format(template, project: @project, location: @location, workspace_id: @workspace_id)
250
332
  end
251
333
 
252
334
  # @api private
@@ -141,6 +141,10 @@ module Anthropic
141
141
  raise NotImplementedError, "Skills are not supported on Vertex."
142
142
  end
143
143
 
144
+ def user_profiles
145
+ raise NotImplementedError, "Managing user profiles is not supported on Vertex."
146
+ end
147
+
144
148
  # @api private
145
149
  #
146
150
  # @param req [Hash{Symbol=>Object}] .
@@ -185,6 +189,9 @@ module Anthropic
185
189
  if path.start_with?("v1/messages/batches")
186
190
  raise NotImplementedError.new("The Batch API is not supported in the Vertex client yet")
187
191
  end
192
+ if path.start_with?("v1/user_profiles")
193
+ raise NotImplementedError.new("Managing user profiles is not supported on Vertex.")
194
+ end
188
195
 
189
196
  super
190
197
  end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Internal
5
+ # @generic Elem
6
+ #
7
+ # @example
8
+ # if report_page_cursor.has_next?
9
+ # report_page_cursor = report_page_cursor.next_page
10
+ # end
11
+ #
12
+ # @example
13
+ # report_page_cursor.auto_paging_each do |usage_report|
14
+ # puts(usage_report)
15
+ # end
16
+ class ReportPageCursor
17
+ include Anthropic::Internal::Type::BasePage
18
+
19
+ # @return [Array<generic<Elem>>, nil]
20
+ attr_accessor :data
21
+
22
+ # @return [String, nil]
23
+ attr_accessor :next_page_
24
+
25
+ # @return [Boolean]
26
+ attr_accessor :has_more
27
+
28
+ # @return [Time, nil]
29
+ attr_accessor :data_refreshed_at
30
+
31
+ # @return [Boolean]
32
+ def next_page?
33
+ return false if has_more == false
34
+
35
+ !next_page_.to_s.empty?
36
+ end
37
+
38
+ # @raise [Anthropic::HTTP::Error]
39
+ # @return [self]
40
+ def next_page
41
+ unless next_page?
42
+ message = "No more pages available. Please check #next_page? before calling ##{__method__}"
43
+ raise RuntimeError.new(message)
44
+ end
45
+
46
+ req = Anthropic::Internal::Util.deep_merge(@req, {query: {page: next_page_}})
47
+ @client.request(req)
48
+ end
49
+
50
+ # @param blk [Proc]
51
+ #
52
+ # @yieldparam [generic<Elem>]
53
+ def auto_paging_each(&blk)
54
+ unless block_given?
55
+ raise ArgumentError.new("A block must be given to ##{__method__}")
56
+ end
57
+
58
+ page = self
59
+ loop do
60
+ page.data&.each(&blk)
61
+
62
+ break unless page.next_page?
63
+ page = page.next_page
64
+ end
65
+ end
66
+
67
+ # @api private
68
+ #
69
+ # @param client [Anthropic::Internal::Transport::BaseClient]
70
+ # @param req [Hash{Symbol=>Object}]
71
+ # @param headers [Hash{String=>String}]
72
+ # @param page_data [Hash{Symbol=>Object}]
73
+ def initialize(client:, req:, headers:, page_data:)
74
+ super
75
+
76
+ case page_data
77
+ in {data: Array => data}
78
+ @data = data.map { Anthropic::Internal::Type::Converter.coerce(@model, _1) }
79
+ else
80
+ end
81
+ @next_page_ = page_data[:next_page]
82
+ @has_more = page_data[:has_more]
83
+ @data_refreshed_at = page_data[:data_refreshed_at]
84
+ end
85
+
86
+ # @api private
87
+ #
88
+ # @return [String]
89
+ def inspect
90
+ # rubocop:disable Layout/LineLength
91
+ model = Anthropic::Internal::Type::Converter.inspect(@model, depth: 1)
92
+
93
+ "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)} next_page_=#{next_page_.inspect} has_more=#{has_more.inspect} data_refreshed_at=#{data_refreshed_at.inspect}>"
94
+ # rubocop:enable Layout/LineLength
95
+ end
96
+ end
97
+ end
98
+ end
@@ -16,24 +16,14 @@ module Anthropic
16
16
  # @return [Enumerable<generic<Elem>>]
17
17
  private def iterator
18
18
  # rubocop:disable Metrics/BlockLength
19
- # rubocop:disable Layout/LineLength
20
19
  # rubocop:disable Lint/DuplicateBranch
21
20
  @iterator ||= Anthropic::Internal::Util.chain_fused(@stream) do |y|
22
21
  @stream.each do |msg|
23
22
  case msg
24
- in {event: "completion", data: String => data}
25
- decoded = JSON.parse(data, symbolize_names: true)
26
- unwrapped = Anthropic::Internal::Util.dig(decoded, @unwrap)
27
- y << Anthropic::Internal::Type::Converter.coerce(@model, unwrapped)
28
- in {
29
- event: "message_start" | "message_delta" | "message_stop" | "content_block_start" | "content_block_delta" | "content_block_stop" | "message" | "user.message" | "user.interrupt" | "user.tool_confirmation" | "user.custom_tool_result" | "user.tool_result" | "agent.message" | "agent.thinking" | "agent.tool_use" | "agent.tool_result" | "agent.mcp_tool_use" | "agent.mcp_tool_result" | "agent.custom_tool_use" | "agent.thread_context_compacted" | "session.status_running" | "session.status_idle" | "session.status_rescheduled" | "session.status_terminated" | "session.error" | "session.deleted" | "session.updated" | "span.model_request_start" | "span.model_request_end" | "span.outcome_evaluation_start" | "span.outcome_evaluation_ongoing" | "span.outcome_evaluation_end" | "user.define_outcome" | "agent.thread_message_received" | "agent.thread_message_sent" | "agent.session_thread_message_received" | "agent.session_thread_message_sent" | "session.thread_created" | "session.thread_status_created" | "session.thread_status_running" | "session.thread_status_idle" | "session.thread_status_rescheduled" | "session.thread_status_terminated" | "event_start" | "event_delta" | "system.message" | "workflow_run.created" | "workflow_run.status_running" | "workflow_run.status_idle" | "workflow_run.status_ended" | "workflow_run.error" | "workflow_run.phase_started" | "workflow_run.phase_ended",
30
- data: String => data
31
- }
32
- decoded = JSON.parse(data, symbolize_names: true)
33
- unwrapped = Anthropic::Internal::Util.dig(decoded, @unwrap)
34
- y << Anthropic::Internal::Type::Converter.coerce(@model, unwrapped)
35
23
  in {event: "ping"}
36
24
  next
25
+ in {event: nil}
26
+ next
37
27
  in {event: "error", data: String => data}
38
28
  decoded = Kernel.then do
39
29
  JSON.parse(data, symbolize_names: true)
@@ -49,12 +39,15 @@ module Anthropic
49
39
  response: @response
50
40
  )
51
41
  raise err
42
+ in {data: String => data} unless data.chomp.empty?
43
+ decoded = JSON.parse(data, symbolize_names: true)
44
+ unwrapped = Anthropic::Internal::Util.dig(decoded, @unwrap)
45
+ y << Anthropic::Internal::Type::Converter.coerce(@model, unwrapped)
52
46
  else
53
47
  end
54
48
  end
55
49
  end
56
50
  # rubocop:enable Lint/DuplicateBranch
57
- # rubocop:enable Layout/LineLength
58
51
  # rubocop:enable Metrics/BlockLength
59
52
  end
60
53
  end
@@ -111,6 +111,12 @@ module Anthropic
111
111
  SKILLS_VERSIONS_RETRIEVE = "anthropic.skills.versions.retrieve"
112
112
  SKILLS_VERSIONS_LIST = "anthropic.skills.versions.list"
113
113
  SKILLS_VERSIONS_DELETE = "anthropic.skills.versions.delete"
114
+ USER_PROFILES_CREATE = "anthropic.user_profiles.create"
115
+ USER_PROFILES_RETRIEVE = "anthropic.user_profiles.retrieve"
116
+ USER_PROFILES_UPDATE = "anthropic.user_profiles.update"
117
+ USER_PROFILES_LIST = "anthropic.user_profiles.list"
118
+ USER_PROFILES_DELETE = "anthropic.user_profiles.delete"
119
+ USER_PROFILES_ACTION_URLS_CREATE = "anthropic.user_profiles.action_urls.create"
114
120
  ORGANIZATION_RETRIEVE = "anthropic.organization.retrieve"
115
121
  ORGANIZATION_API_KEYS_RETRIEVE = "anthropic.organization.api_keys.retrieve"
116
122
  ORGANIZATION_API_KEYS_UPDATE = "anthropic.organization.api_keys.update"
@@ -157,6 +163,7 @@ module Anthropic
157
163
  ORGANIZATION_WORKSPACES_UPDATE = "anthropic.organization.workspaces.update"
158
164
  ORGANIZATION_WORKSPACES_LIST = "anthropic.organization.workspaces.list"
159
165
  ORGANIZATION_WORKSPACES_ARCHIVE = "anthropic.organization.workspaces.archive"
166
+ ORGANIZATION_WORKSPACES_RATE_LIMITS_UPDATE = "anthropic.organization.workspaces.rate_limits.update"
160
167
  ORGANIZATION_WORKSPACES_RATE_LIMITS_LIST = "anthropic.organization.workspaces.rate_limits.list"
161
168
  ORGANIZATION_WORKSPACES_MEMBERS_RETRIEVE = "anthropic.organization.workspaces.members.retrieve"
162
169
  ORGANIZATION_WORKSPACES_MEMBERS_UPDATE = "anthropic.organization.workspaces.members.update"
@@ -251,10 +258,6 @@ module Anthropic
251
258
  MEMORY_STORES_MEMORY_VERSIONS_LIST = "anthropic.memory_stores.memory_versions.list"
252
259
  MEMORY_STORES_MEMORY_VERSIONS_REDACT = "anthropic.memory_stores.memory_versions.redact"
253
260
  SKILLS_VERSIONS_DOWNLOAD = "anthropic.skills.versions.download"
254
- USER_PROFILES_CREATE = "anthropic.user_profiles.create"
255
- USER_PROFILES_RETRIEVE = "anthropic.user_profiles.retrieve"
256
- USER_PROFILES_UPDATE = "anthropic.user_profiles.update"
257
- USER_PROFILES_LIST = "anthropic.user_profiles.list"
258
261
  USER_PROFILES_CREATE_ENROLLMENT_URL = "anthropic.user_profiles.create_enrollment_url"
259
262
  DREAMS_CREATE = "anthropic.dreams.create"
260
263
  DREAMS_RETRIEVE = "anthropic.dreams.retrieve"
@@ -17,6 +17,14 @@ module Anthropic
17
17
  required :type, const: :messages_changed
18
18
 
19
19
  # @!method initialize(cache_missed_input_tokens:, type: :messages_changed)
20
+ # A `cache_miss_reason` for a request whose `messages` differ from the previous
21
+ # request's in an earlier entry, instead of only having entries appended. The
22
+ # `model`, `system`, and `tools` match.
23
+ #
24
+ # See the
25
+ # [cache diagnostics guide](https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics#cache-miss-reason-types)
26
+ # to learn what to change for each reason.
27
+ #
20
28
  # Some parameter documentations has been truncated, see
21
29
  # {Anthropic::Models::Beta::BetaCacheMissMessagesChanged} for more details.
22
30
  #
@@ -17,6 +17,13 @@ module Anthropic
17
17
  required :type, const: :model_changed
18
18
 
19
19
  # @!method initialize(cache_missed_input_tokens:, type: :model_changed)
20
+ # A `cache_miss_reason` for a request whose `model` or `speed` differs from the
21
+ # previous request's.
22
+ #
23
+ # See the
24
+ # [cache diagnostics guide](https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics#cache-miss-reason-types)
25
+ # to learn what to change for each reason.
26
+ #
20
27
  # Some parameter documentations has been truncated, see
21
28
  # {Anthropic::Models::Beta::BetaCacheMissModelChanged} for more details.
22
29
  #
@@ -10,6 +10,15 @@ module Anthropic
10
10
  required :type, const: :previous_message_not_found
11
11
 
12
12
  # @!method initialize(type: :previous_message_not_found)
13
+ # A `cache_miss_reason` for when the API doesn't have a stored record of the
14
+ # request that `diagnostics.previous_message_id` references.
15
+ #
16
+ # This doesn't mean that this request changed.
17
+ #
18
+ # See the
19
+ # [cache diagnostics guide](https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics#cache-miss-reason-types)
20
+ # to learn what to change for each reason.
21
+ #
13
22
  # @param type [Symbol, :previous_message_not_found]
14
23
  end
15
24
  end