arkruntime 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (714) hide show
  1. arkruntime/__init__.py +11 -0
  2. arkruntime/_base_client.py +1373 -0
  3. arkruntime/_client.py +585 -0
  4. arkruntime/_compat.py +265 -0
  5. arkruntime/_constants.py +55 -0
  6. arkruntime/_exceptions.py +188 -0
  7. arkruntime/_files.py +122 -0
  8. arkruntime/_legacy_response.py +438 -0
  9. arkruntime/_managed_agents_serialize.py +55 -0
  10. arkruntime/_models.py +733 -0
  11. arkruntime/_qs.py +164 -0
  12. arkruntime/_request_options.py +118 -0
  13. arkruntime/_resource.py +41 -0
  14. arkruntime/_response.py +599 -0
  15. arkruntime/_streaming.py +460 -0
  16. arkruntime/_types.py +207 -0
  17. arkruntime/_utils/__init__.py +144 -0
  18. arkruntime/_utils/_key_agreement.py +217 -0
  19. arkruntime/_utils/_logs.py +28 -0
  20. arkruntime/_utils/_model_breaker.py +87 -0
  21. arkruntime/_utils/_streams.py +17 -0
  22. arkruntime/_utils/_transform.py +463 -0
  23. arkruntime/_utils/_typing.py +157 -0
  24. arkruntime/_utils/_utils.py +473 -0
  25. arkruntime/common/__init__.py +6 -0
  26. arkruntime/common/_parsing/__init__.py +31 -0
  27. arkruntime/common/_parsing/_completions.py +272 -0
  28. arkruntime/common/_parsing/_responses.py +174 -0
  29. arkruntime/common/_pydantic.py +166 -0
  30. arkruntime/common/_tools.py +85 -0
  31. arkruntime/common/streaming/__init__.py +4 -0
  32. arkruntime/common/streaming/_deltas.py +68 -0
  33. arkruntime/common/streaming/chat/__init__.py +49 -0
  34. arkruntime/common/streaming/chat/_completions.py +732 -0
  35. arkruntime/common/streaming/chat/_events.py +96 -0
  36. arkruntime/common/streaming/chat/_types.py +28 -0
  37. arkruntime/pagination.py +128 -0
  38. arkruntime/resources/__init__.py +75 -0
  39. arkruntime/resources/agents/__init__.py +3 -0
  40. arkruntime/resources/agents/agents.py +372 -0
  41. arkruntime/resources/batch/__init__.py +6 -0
  42. arkruntime/resources/batch/_utils.py +156 -0
  43. arkruntime/resources/batch/batch.py +40 -0
  44. arkruntime/resources/batch/chat/__init__.py +6 -0
  45. arkruntime/resources/batch/chat/chat.py +22 -0
  46. arkruntime/resources/batch/chat/completions.py +217 -0
  47. arkruntime/resources/batch/embeddings.py +150 -0
  48. arkruntime/resources/batch/multimodal_embeddings.py +160 -0
  49. arkruntime/resources/beta/__init__.py +4 -0
  50. arkruntime/resources/beta/beta.py +73 -0
  51. arkruntime/resources/beta/chat/__init__.py +13 -0
  52. arkruntime/resources/beta/chat/chat.py +23 -0
  53. arkruntime/resources/beta/chat/completions.py +356 -0
  54. arkruntime/resources/chat/__init__.py +7 -0
  55. arkruntime/resources/chat/chat.py +23 -0
  56. arkruntime/resources/chat/completions.py +242 -0
  57. arkruntime/resources/content_generation/__init__.py +7 -0
  58. arkruntime/resources/content_generation/content_generation.py +21 -0
  59. arkruntime/resources/content_generation/tasks.py +331 -0
  60. arkruntime/resources/embeddings/__init__.py +6 -0
  61. arkruntime/resources/embeddings/embeddings.py +140 -0
  62. arkruntime/resources/encryption.py +187 -0
  63. arkruntime/resources/environments/__init__.py +3 -0
  64. arkruntime/resources/environments/environments.py +216 -0
  65. arkruntime/resources/files/__init__.py +6 -0
  66. arkruntime/resources/files/files.py +401 -0
  67. arkruntime/resources/images/__init__.py +10 -0
  68. arkruntime/resources/images/images.py +152 -0
  69. arkruntime/resources/memory_stores/__init__.py +7 -0
  70. arkruntime/resources/memory_stores/memories.py +262 -0
  71. arkruntime/resources/memory_stores/memory_stores.py +223 -0
  72. arkruntime/resources/multimodal_embeddings/__init__.py +9 -0
  73. arkruntime/resources/multimodal_embeddings/multimodal_embeddings.py +150 -0
  74. arkruntime/resources/responses/__init__.py +8 -0
  75. arkruntime/resources/responses/input_items.py +241 -0
  76. arkruntime/resources/responses/responses.py +467 -0
  77. arkruntime/resources/sessions/__init__.py +24 -0
  78. arkruntime/resources/sessions/session_events.py +336 -0
  79. arkruntime/resources/sessions/session_resources.py +89 -0
  80. arkruntime/resources/sessions/session_threads.py +275 -0
  81. arkruntime/resources/sessions/sessions.py +331 -0
  82. arkruntime/resources/skills/__init__.py +3 -0
  83. arkruntime/resources/skills/skills.py +112 -0
  84. arkruntime/resources/tokenization/__init__.py +9 -0
  85. arkruntime/resources/tokenization/tokenization.py +131 -0
  86. arkruntime/resources/vaults/__init__.py +4 -0
  87. arkruntime/resources/vaults/credentials.py +253 -0
  88. arkruntime/resources/vaults/vaults.py +197 -0
  89. arkruntime/types/__init__.py +7 -0
  90. arkruntime/types/agent/__init__.py +56 -0
  91. arkruntime/types/agent/_init_extras_shim.py +12 -0
  92. arkruntime/types/agent/agent.py +86 -0
  93. arkruntime/types/agent/agent_ref.py +32 -0
  94. arkruntime/types/agent/agent_ref_type.py +18 -0
  95. arkruntime/types/agent/agent_skill_ref.py +32 -0
  96. arkruntime/types/agent/create_agent_request.py +65 -0
  97. arkruntime/types/agent/delete_agent_response.py +20 -0
  98. arkruntime/types/agent/list_agents_response.py +32 -0
  99. arkruntime/types/agent/mcp_server.py +30 -0
  100. arkruntime/types/agent/mcp_server_type.py +16 -0
  101. arkruntime/types/agent/model_config.py +28 -0
  102. arkruntime/types/agent/model_speed.py +18 -0
  103. arkruntime/types/agent/multiagent_config.py +29 -0
  104. arkruntime/types/agent/multiagent_type.py +16 -0
  105. arkruntime/types/agent/permission_policy.py +22 -0
  106. arkruntime/types/agent/permission_policy_type.py +18 -0
  107. arkruntime/types/agent/skill_ref_type.py +19 -0
  108. arkruntime/types/agent/tag.py +26 -0
  109. arkruntime/types/agent/tool_config.py +32 -0
  110. arkruntime/types/agent/tool_default_config.py +28 -0
  111. arkruntime/types/agent/tool_item.py +57 -0
  112. arkruntime/types/agent/update_agent_request.py +70 -0
  113. arkruntime/types/chat/__init__.py +212 -0
  114. arkruntime/types/chat/_init_extras_shim.py +73 -0
  115. arkruntime/types/chat/chat_completion_choice_logprobs.py +20 -0
  116. arkruntime/types/chat/chat_completion_content_part.py +32 -0
  117. arkruntime/types/chat/chat_completion_content_part_audio.py +23 -0
  118. arkruntime/types/chat/chat_completion_content_part_audio_input_audio.py +30 -0
  119. arkruntime/types/chat/chat_completion_content_part_audio_input_audio_param.py +25 -0
  120. arkruntime/types/chat/chat_completion_content_part_audio_param.py +22 -0
  121. arkruntime/types/chat/chat_completion_content_part_file.py +21 -0
  122. arkruntime/types/chat/chat_completion_content_part_file_file.py +30 -0
  123. arkruntime/types/chat/chat_completion_content_part_file_file_param.py +25 -0
  124. arkruntime/types/chat/chat_completion_content_part_file_param.py +22 -0
  125. arkruntime/types/chat/chat_completion_content_part_image.py +23 -0
  126. arkruntime/types/chat/chat_completion_content_part_image_image_url.py +33 -0
  127. arkruntime/types/chat/chat_completion_content_part_image_image_url_param.py +28 -0
  128. arkruntime/types/chat/chat_completion_content_part_image_param.py +22 -0
  129. arkruntime/types/chat/chat_completion_content_part_param.py +29 -0
  130. arkruntime/types/chat/chat_completion_content_part_text.py +22 -0
  131. arkruntime/types/chat/chat_completion_content_part_text_param.py +19 -0
  132. arkruntime/types/chat/chat_completion_content_part_video.py +23 -0
  133. arkruntime/types/chat/chat_completion_content_part_video_param.py +22 -0
  134. arkruntime/types/chat/chat_completion_content_part_video_video_url.py +36 -0
  135. arkruntime/types/chat/chat_completion_content_part_video_video_url_param.py +30 -0
  136. arkruntime/types/chat/chat_completion_message_content.py +17 -0
  137. arkruntime/types/chat/chat_completion_message_content_param.py +15 -0
  138. arkruntime/types/chat/chat_completion_message_tool_call.py +29 -0
  139. arkruntime/types/chat/chat_completion_message_tool_call_chunk.py +31 -0
  140. arkruntime/types/chat/chat_completion_message_tool_call_chunk_function.py +16 -0
  141. arkruntime/types/chat/chat_completion_message_tool_call_function.py +23 -0
  142. arkruntime/types/chat/chat_completion_message_tool_call_function_param.py +22 -0
  143. arkruntime/types/chat/chat_completion_message_tool_call_param.py +26 -0
  144. arkruntime/types/chat/chat_completion_named_tool_choice.py +21 -0
  145. arkruntime/types/chat/chat_completion_named_tool_choice_param.py +22 -0
  146. arkruntime/types/chat/chat_completion_request.py +129 -0
  147. arkruntime/types/chat/chat_completion_request_assistant_message.py +39 -0
  148. arkruntime/types/chat/chat_completion_request_assistant_message_param.py +36 -0
  149. arkruntime/types/chat/chat_completion_request_message.py +32 -0
  150. arkruntime/types/chat/chat_completion_request_message_param.py +29 -0
  151. arkruntime/types/chat/chat_completion_request_param.py +122 -0
  152. arkruntime/types/chat/chat_completion_request_system_message.py +25 -0
  153. arkruntime/types/chat/chat_completion_request_system_message_param.py +23 -0
  154. arkruntime/types/chat/chat_completion_request_tool_message.py +29 -0
  155. arkruntime/types/chat/chat_completion_request_tool_message_param.py +26 -0
  156. arkruntime/types/chat/chat_completion_request_user_message.py +29 -0
  157. arkruntime/types/chat/chat_completion_request_user_message_param.py +27 -0
  158. arkruntime/types/chat/chat_completion_response.py +52 -0
  159. arkruntime/types/chat/chat_completion_response_choice.py +36 -0
  160. arkruntime/types/chat/chat_completion_response_format.py +28 -0
  161. arkruntime/types/chat/chat_completion_response_format_json_schema.py +33 -0
  162. arkruntime/types/chat/chat_completion_response_format_json_schema_param.py +31 -0
  163. arkruntime/types/chat/chat_completion_response_format_param.py +27 -0
  164. arkruntime/types/chat/chat_completion_response_message.py +37 -0
  165. arkruntime/types/chat/chat_completion_role.py +16 -0
  166. arkruntime/types/chat/chat_completion_service_status.py +17 -0
  167. arkruntime/types/chat/chat_completion_stop.py +13 -0
  168. arkruntime/types/chat/chat_completion_stop_param.py +11 -0
  169. arkruntime/types/chat/chat_completion_stream_choice_logprobs.py +17 -0
  170. arkruntime/types/chat/chat_completion_stream_options.py +22 -0
  171. arkruntime/types/chat/chat_completion_stream_options_param.py +19 -0
  172. arkruntime/types/chat/chat_completion_stream_response.py +34 -0
  173. arkruntime/types/chat/chat_completion_stream_response_choice.py +27 -0
  174. arkruntime/types/chat/chat_completion_stream_response_delta.py +36 -0
  175. arkruntime/types/chat/chat_completion_token_logprob.py +26 -0
  176. arkruntime/types/chat/chat_completion_token_logprob_top_logprob.py +17 -0
  177. arkruntime/types/chat/chat_completion_tool.py +20 -0
  178. arkruntime/types/chat/chat_completion_tool_choice.py +18 -0
  179. arkruntime/types/chat/chat_completion_tool_choice_function.py +13 -0
  180. arkruntime/types/chat/chat_completion_tool_choice_function_param.py +13 -0
  181. arkruntime/types/chat/chat_completion_tool_choice_param.py +16 -0
  182. arkruntime/types/chat/chat_completion_tool_param.py +20 -0
  183. arkruntime/types/chat/completion_tokens_details.py +16 -0
  184. arkruntime/types/chat/completion_usage.py +35 -0
  185. arkruntime/types/chat/error.py +28 -0
  186. arkruntime/types/chat/error_response.py +15 -0
  187. arkruntime/types/chat/finish_reason.py +16 -0
  188. arkruntime/types/chat/function_object.py +35 -0
  189. arkruntime/types/chat/function_object_param.py +38 -0
  190. arkruntime/types/chat/image_detail.py +16 -0
  191. arkruntime/types/chat/image_pixel_limit.py +16 -0
  192. arkruntime/types/chat/image_pixel_limit_param.py +17 -0
  193. arkruntime/types/chat/model_fallback_status.py +20 -0
  194. arkruntime/types/chat/moderation_hit_type.py +14 -0
  195. arkruntime/types/chat/parsed_chat_completion_shim.py +52 -0
  196. arkruntime/types/chat/parsed_function_tool_call_shim.py +29 -0
  197. arkruntime/types/chat/prompt_tokens_details.py +34 -0
  198. arkruntime/types/chat/reasoning_effort.py +19 -0
  199. arkruntime/types/chat/request_service_tier.py +15 -0
  200. arkruntime/types/chat/response_format_type.py +15 -0
  201. arkruntime/types/chat/response_service_tier.py +15 -0
  202. arkruntime/types/chat/thinking.py +17 -0
  203. arkruntime/types/chat/thinking_mode.py +15 -0
  204. arkruntime/types/chat/thinking_param.py +17 -0
  205. arkruntime/types/chat/tool_choice_mode.py +15 -0
  206. arkruntime/types/chat/tool_type.py +13 -0
  207. arkruntime/types/chat/tool_type_param.py +11 -0
  208. arkruntime/types/chat/video_image_pixel_limit.py +16 -0
  209. arkruntime/types/chat/video_image_pixel_limit_param.py +17 -0
  210. arkruntime/types/completion_usage.py +43 -0
  211. arkruntime/types/content_generation/__init__.py +66 -0
  212. arkruntime/types/content_generation/_init_extras_shim.py +12 -0
  213. arkruntime/types/content_generation/audio_role.py +16 -0
  214. arkruntime/types/content_generation/audio_url.py +16 -0
  215. arkruntime/types/content_generation/audio_url_param.py +14 -0
  216. arkruntime/types/content_generation/content_generation_task.py +125 -0
  217. arkruntime/types/content_generation/content_item.py +54 -0
  218. arkruntime/types/content_generation/content_item_param.py +46 -0
  219. arkruntime/types/content_generation/content_type.py +21 -0
  220. arkruntime/types/content_generation/create_content_generation_task_request.py +106 -0
  221. arkruntime/types/content_generation/create_content_generation_task_request_param.py +83 -0
  222. arkruntime/types/content_generation/create_content_generation_task_response.py +16 -0
  223. arkruntime/types/content_generation/draft_task.py +16 -0
  224. arkruntime/types/content_generation/draft_task_param.py +14 -0
  225. arkruntime/types/content_generation/image_role.py +20 -0
  226. arkruntime/types/content_generation/image_url.py +16 -0
  227. arkruntime/types/content_generation/image_url_param.py +14 -0
  228. arkruntime/types/content_generation/list_content_generation_tasks_response.py +24 -0
  229. arkruntime/types/content_generation/reasoning_effort.py +16 -0
  230. arkruntime/types/content_generation/task_content.py +30 -0
  231. arkruntime/types/content_generation/task_error.py +20 -0
  232. arkruntime/types/content_generation/task_status.py +21 -0
  233. arkruntime/types/content_generation/task_usage.py +28 -0
  234. arkruntime/types/content_generation/tool.py +18 -0
  235. arkruntime/types/content_generation/tool_param.py +17 -0
  236. arkruntime/types/content_generation/tool_type.py +13 -0
  237. arkruntime/types/content_generation/tool_type_param.py +11 -0
  238. arkruntime/types/content_generation/tool_usage.py +18 -0
  239. arkruntime/types/content_generation/video_role.py +16 -0
  240. arkruntime/types/content_generation/video_url.py +16 -0
  241. arkruntime/types/content_generation/video_url_param.py +14 -0
  242. arkruntime/types/embedding/__init__.py +30 -0
  243. arkruntime/types/embedding/_init_extras_shim.py +12 -0
  244. arkruntime/types/embedding/embedding.py +18 -0
  245. arkruntime/types/embedding/embedding_input.py +18 -0
  246. arkruntime/types/embedding/embedding_input_param.py +16 -0
  247. arkruntime/types/embedding/embedding_item.py +32 -0
  248. arkruntime/types/embedding/embedding_request.py +39 -0
  249. arkruntime/types/embedding/embedding_request_param.py +37 -0
  250. arkruntime/types/embedding/embedding_response.py +41 -0
  251. arkruntime/types/embedding/embedding_usage.py +24 -0
  252. arkruntime/types/embedding/encoding_format.py +14 -0
  253. arkruntime/types/environment/__init__.py +36 -0
  254. arkruntime/types/environment/_init_extras_shim.py +12 -0
  255. arkruntime/types/environment/create_environment_request.py +41 -0
  256. arkruntime/types/environment/delete_environment_response.py +24 -0
  257. arkruntime/types/environment/env_config.py +38 -0
  258. arkruntime/types/environment/env_config_type.py +18 -0
  259. arkruntime/types/environment/environment.py +57 -0
  260. arkruntime/types/environment/environment_scope.py +18 -0
  261. arkruntime/types/environment/list_environments_response.py +30 -0
  262. arkruntime/types/environment/networking_config.py +37 -0
  263. arkruntime/types/environment/networking_type.py +18 -0
  264. arkruntime/types/environment/packages_config.py +47 -0
  265. arkruntime/types/environment/update_environment_request.py +45 -0
  266. arkruntime/types/file/__init__.py +40 -0
  267. arkruntime/types/file/_init_extras_shim.py +12 -0
  268. arkruntime/types/file/file_create_request.py +41 -0
  269. arkruntime/types/file/file_create_request_param.py +41 -0
  270. arkruntime/types/file/file_deleted.py +30 -0
  271. arkruntime/types/file/file_error.py +32 -0
  272. arkruntime/types/file/file_list_response.py +42 -0
  273. arkruntime/types/file/file_object.py +71 -0
  274. arkruntime/types/file/order.py +18 -0
  275. arkruntime/types/file/preprocess_configs.py +24 -0
  276. arkruntime/types/file/preprocess_configs_param.py +22 -0
  277. arkruntime/types/file/purpose.py +18 -0
  278. arkruntime/types/file/status.py +19 -0
  279. arkruntime/types/file/tos_storage.py +28 -0
  280. arkruntime/types/file/tos_storage_param.py +25 -0
  281. arkruntime/types/file/video.py +26 -0
  282. arkruntime/types/file/video_param.py +23 -0
  283. arkruntime/types/images/__init__.py +55 -0
  284. arkruntime/types/images/_init_extras_shim.py +12 -0
  285. arkruntime/types/images/bounding_box.py +27 -0
  286. arkruntime/types/images/create_image_generation_request.py +88 -0
  287. arkruntime/types/images/create_image_generation_request_param.py +73 -0
  288. arkruntime/types/images/image_data_item.py +58 -0
  289. arkruntime/types/images/image_error.py +20 -0
  290. arkruntime/types/images/image_generation_response.py +43 -0
  291. arkruntime/types/images/image_generation_stream_event.py +74 -0
  292. arkruntime/types/images/image_generation_stream_event_type.py +19 -0
  293. arkruntime/types/images/optimize_prompt_mode.py +18 -0
  294. arkruntime/types/images/optimize_prompt_options.py +20 -0
  295. arkruntime/types/images/optimize_prompt_options_param.py +18 -0
  296. arkruntime/types/images/output_format.py +18 -0
  297. arkruntime/types/images/response_format.py +18 -0
  298. arkruntime/types/images/sequential_image_generation_mode.py +18 -0
  299. arkruntime/types/images/sequential_image_generation_options.py +18 -0
  300. arkruntime/types/images/sequential_image_generation_options_param.py +16 -0
  301. arkruntime/types/images/tool.py +18 -0
  302. arkruntime/types/images/tool_param.py +17 -0
  303. arkruntime/types/images/tool_type.py +13 -0
  304. arkruntime/types/images/tool_type_param.py +11 -0
  305. arkruntime/types/images/tool_usage.py +18 -0
  306. arkruntime/types/images/usage.py +36 -0
  307. arkruntime/types/memory/__init__.py +44 -0
  308. arkruntime/types/memory/_init_extras_shim.py +12 -0
  309. arkruntime/types/memory/actor.py +26 -0
  310. arkruntime/types/memory/actor_type.py +16 -0
  311. arkruntime/types/memory/create_memory_request.py +24 -0
  312. arkruntime/types/memory/create_memory_store_request.py +30 -0
  313. arkruntime/types/memory/delete_memory_response.py +26 -0
  314. arkruntime/types/memory/delete_memory_store_response.py +26 -0
  315. arkruntime/types/memory/list_memories_order_by.py +18 -0
  316. arkruntime/types/memory/list_memories_response.py +32 -0
  317. arkruntime/types/memory/list_memory_stores_response.py +28 -0
  318. arkruntime/types/memory/memory.py +64 -0
  319. arkruntime/types/memory/memory_list_item.py +58 -0
  320. arkruntime/types/memory/memory_list_item_type.py +20 -0
  321. arkruntime/types/memory/memory_store.py +64 -0
  322. arkruntime/types/memory/update_memory_request.py +27 -0
  323. arkruntime/types/memory/update_memory_store_request.py +31 -0
  324. arkruntime/types/multimodal_embedding/__init__.py +54 -0
  325. arkruntime/types/multimodal_embedding/_init_extras_shim.py +12 -0
  326. arkruntime/types/multimodal_embedding/embedding.py +13 -0
  327. arkruntime/types/multimodal_embedding/embedding_data_item.py +33 -0
  328. arkruntime/types/multimodal_embedding/embedding_input.py +34 -0
  329. arkruntime/types/multimodal_embedding/embedding_input_param.py +29 -0
  330. arkruntime/types/multimodal_embedding/embedding_input_type.py +15 -0
  331. arkruntime/types/multimodal_embedding/embedding_object.py +14 -0
  332. arkruntime/types/multimodal_embedding/embedding_usage.py +26 -0
  333. arkruntime/types/multimodal_embedding/encoding_format.py +14 -0
  334. arkruntime/types/multimodal_embedding/image_url.py +16 -0
  335. arkruntime/types/multimodal_embedding/image_url_param.py +14 -0
  336. arkruntime/types/multimodal_embedding/multi_embedding_config.py +18 -0
  337. arkruntime/types/multimodal_embedding/multi_embedding_config_param.py +17 -0
  338. arkruntime/types/multimodal_embedding/multi_embedding_mode.py +14 -0
  339. arkruntime/types/multimodal_embedding/multi_modal_embedding_request.py +47 -0
  340. arkruntime/types/multimodal_embedding/multi_modal_embedding_request_param.py +39 -0
  341. arkruntime/types/multimodal_embedding/multi_modal_embedding_response.py +41 -0
  342. arkruntime/types/multimodal_embedding/prompt_tokens_details.py +20 -0
  343. arkruntime/types/multimodal_embedding/sparse_embedding_config.py +20 -0
  344. arkruntime/types/multimodal_embedding/sparse_embedding_config_param.py +18 -0
  345. arkruntime/types/multimodal_embedding/sparse_embedding_mode.py +14 -0
  346. arkruntime/types/multimodal_embedding/sparse_embedding_value.py +20 -0
  347. arkruntime/types/multimodal_embedding/video_url.py +22 -0
  348. arkruntime/types/multimodal_embedding/video_url_param.py +19 -0
  349. arkruntime/types/responses/__init__.py +528 -0
  350. arkruntime/types/responses/_init_extras_shim.py +47 -0
  351. arkruntime/types/responses/annotation.py +20 -0
  352. arkruntime/types/responses/annotation_param.py +14 -0
  353. arkruntime/types/responses/applied_edit.py +22 -0
  354. arkruntime/types/responses/audio_chunk.py +15 -0
  355. arkruntime/types/responses/audio_chunking_strategy.py +18 -0
  356. arkruntime/types/responses/audio_chunking_strategy_param.py +21 -0
  357. arkruntime/types/responses/cache_mode.py +14 -0
  358. arkruntime/types/responses/clear_thinking.py +18 -0
  359. arkruntime/types/responses/clear_thinking_keep.py +18 -0
  360. arkruntime/types/responses/clear_thinking_keep_param.py +19 -0
  361. arkruntime/types/responses/clear_thinking_param.py +19 -0
  362. arkruntime/types/responses/clear_thinking_response.py +16 -0
  363. arkruntime/types/responses/clear_tool_uses.py +23 -0
  364. arkruntime/types/responses/clear_tool_uses_inputs.py +18 -0
  365. arkruntime/types/responses/clear_tool_uses_inputs_param.py +19 -0
  366. arkruntime/types/responses/clear_tool_uses_param.py +27 -0
  367. arkruntime/types/responses/clear_tool_uses_response.py +16 -0
  368. arkruntime/types/responses/content_filter.py +14 -0
  369. arkruntime/types/responses/content_item.py +36 -0
  370. arkruntime/types/responses/content_item_audio.py +20 -0
  371. arkruntime/types/responses/content_item_audio_param.py +23 -0
  372. arkruntime/types/responses/content_item_file.py +19 -0
  373. arkruntime/types/responses/content_item_file_param.py +23 -0
  374. arkruntime/types/responses/content_item_image.py +22 -0
  375. arkruntime/types/responses/content_item_image_param.py +26 -0
  376. arkruntime/types/responses/content_item_param.py +29 -0
  377. arkruntime/types/responses/content_item_text.py +22 -0
  378. arkruntime/types/responses/content_item_text_param.py +19 -0
  379. arkruntime/types/responses/content_item_video.py +27 -0
  380. arkruntime/types/responses/content_item_video_param.py +24 -0
  381. arkruntime/types/responses/context_management.py +17 -0
  382. arkruntime/types/responses/context_management_param.py +17 -0
  383. arkruntime/types/responses/context_management_response.py +17 -0
  384. arkruntime/types/responses/cover_image.py +26 -0
  385. arkruntime/types/responses/cover_image_param.py +22 -0
  386. arkruntime/types/responses/delete_response_response.py +17 -0
  387. arkruntime/types/responses/doc_citation.py +19 -0
  388. arkruntime/types/responses/doc_citation_param.py +23 -0
  389. arkruntime/types/responses/doubao_app_call_block.py +30 -0
  390. arkruntime/types/responses/doubao_app_call_block_output_text.py +21 -0
  391. arkruntime/types/responses/doubao_app_call_block_reasoning_search.py +24 -0
  392. arkruntime/types/responses/doubao_app_call_block_reasoning_text.py +21 -0
  393. arkruntime/types/responses/doubao_app_call_block_search.py +24 -0
  394. arkruntime/types/responses/doubao_app_feature.py +20 -0
  395. arkruntime/types/responses/doubao_app_feature_item.py +18 -0
  396. arkruntime/types/responses/doubao_app_feature_item_param.py +19 -0
  397. arkruntime/types/responses/doubao_app_feature_mode.py +14 -0
  398. arkruntime/types/responses/doubao_app_feature_param.py +23 -0
  399. arkruntime/types/responses/doubao_app_search_result.py +15 -0
  400. arkruntime/types/responses/doubao_app_search_text_item.py +15 -0
  401. arkruntime/types/responses/doubao_app_tool.py +20 -0
  402. arkruntime/types/responses/doubao_app_tool_param.py +22 -0
  403. arkruntime/types/responses/edit.py +19 -0
  404. arkruntime/types/responses/edit_param.py +14 -0
  405. arkruntime/types/responses/function_tool.py +32 -0
  406. arkruntime/types/responses/function_tool_param.py +29 -0
  407. arkruntime/types/responses/image_detail.py +16 -0
  408. arkruntime/types/responses/image_pixel_limit.py +16 -0
  409. arkruntime/types/responses/image_pixel_limit_param.py +17 -0
  410. arkruntime/types/responses/image_process_options.py +15 -0
  411. arkruntime/types/responses/image_process_options_param.py +15 -0
  412. arkruntime/types/responses/image_process_tool.py +21 -0
  413. arkruntime/types/responses/image_process_tool_param.py +25 -0
  414. arkruntime/types/responses/incomplete_details.py +24 -0
  415. arkruntime/types/responses/input_item.py +38 -0
  416. arkruntime/types/responses/input_item_list_params_shim.py +39 -0
  417. arkruntime/types/responses/input_item_param.py +33 -0
  418. arkruntime/types/responses/input_tokens_details.py +17 -0
  419. arkruntime/types/responses/item_agent_tool_call.py +20 -0
  420. arkruntime/types/responses/item_doubao_app_call.py +22 -0
  421. arkruntime/types/responses/item_easy_message.py +22 -0
  422. arkruntime/types/responses/item_easy_message_param.py +26 -0
  423. arkruntime/types/responses/item_function_image_process.py +24 -0
  424. arkruntime/types/responses/item_function_knowledge_search.py +21 -0
  425. arkruntime/types/responses/item_function_mcp_approval_request.py +34 -0
  426. arkruntime/types/responses/item_function_mcp_approval_request_param.py +28 -0
  427. arkruntime/types/responses/item_function_mcp_approval_response.py +34 -0
  428. arkruntime/types/responses/item_function_mcp_approval_response_param.py +28 -0
  429. arkruntime/types/responses/item_function_mcp_call.py +44 -0
  430. arkruntime/types/responses/item_function_mcp_call_param.py +38 -0
  431. arkruntime/types/responses/item_function_mcp_list_tools.py +36 -0
  432. arkruntime/types/responses/item_function_mcp_list_tools_param.py +30 -0
  433. arkruntime/types/responses/item_function_tool_call.py +37 -0
  434. arkruntime/types/responses/item_function_tool_call_output.py +22 -0
  435. arkruntime/types/responses/item_function_tool_call_output_param.py +26 -0
  436. arkruntime/types/responses/item_function_tool_call_param.py +32 -0
  437. arkruntime/types/responses/item_function_web_search.py +21 -0
  438. arkruntime/types/responses/item_input_message.py +24 -0
  439. arkruntime/types/responses/item_output_message.py +23 -0
  440. arkruntime/types/responses/item_reasoning.py +24 -0
  441. arkruntime/types/responses/item_reasoning_param.py +29 -0
  442. arkruntime/types/responses/item_reference.py +16 -0
  443. arkruntime/types/responses/item_status.py +17 -0
  444. arkruntime/types/responses/item_transcription.py +21 -0
  445. arkruntime/types/responses/knowledge_search_tool.py +46 -0
  446. arkruntime/types/responses/knowledge_search_tool_param.py +37 -0
  447. arkruntime/types/responses/list_input_items_response.py +21 -0
  448. arkruntime/types/responses/mcp_allowed_tools.py +17 -0
  449. arkruntime/types/responses/mcp_allowed_tools_filter.py +15 -0
  450. arkruntime/types/responses/mcp_allowed_tools_filter_param.py +15 -0
  451. arkruntime/types/responses/mcp_allowed_tools_param.py +13 -0
  452. arkruntime/types/responses/mcp_approval_mode.py +14 -0
  453. arkruntime/types/responses/mcp_list_tools_tool.py +30 -0
  454. arkruntime/types/responses/mcp_list_tools_tool_param.py +25 -0
  455. arkruntime/types/responses/mcp_require_approval.py +18 -0
  456. arkruntime/types/responses/mcp_require_approval_param.py +14 -0
  457. arkruntime/types/responses/mcp_tool.py +24 -0
  458. arkruntime/types/responses/mcp_tool_approval_filter.py +19 -0
  459. arkruntime/types/responses/mcp_tool_approval_filter_always.py +15 -0
  460. arkruntime/types/responses/mcp_tool_approval_filter_always_param.py +15 -0
  461. arkruntime/types/responses/mcp_tool_approval_filter_never.py +15 -0
  462. arkruntime/types/responses/mcp_tool_approval_filter_never_param.py +15 -0
  463. arkruntime/types/responses/mcp_tool_approval_filter_param.py +20 -0
  464. arkruntime/types/responses/mcp_tool_param.py +30 -0
  465. arkruntime/types/responses/message_content.py +15 -0
  466. arkruntime/types/responses/message_content_param.py +13 -0
  467. arkruntime/types/responses/message_role.py +16 -0
  468. arkruntime/types/responses/order.py +18 -0
  469. arkruntime/types/responses/output_content_item.py +23 -0
  470. arkruntime/types/responses/output_content_item_param.py +18 -0
  471. arkruntime/types/responses/output_content_item_reasoning_text.py +19 -0
  472. arkruntime/types/responses/output_content_item_reasoning_text_param.py +21 -0
  473. arkruntime/types/responses/output_content_item_text.py +19 -0
  474. arkruntime/types/responses/output_content_item_text_param.py +21 -0
  475. arkruntime/types/responses/output_item.py +46 -0
  476. arkruntime/types/responses/output_tokens_details.py +13 -0
  477. arkruntime/types/responses/parsed_response_shim.py +106 -0
  478. arkruntime/types/responses/reasoning.py +17 -0
  479. arkruntime/types/responses/reasoning_effort.py +19 -0
  480. arkruntime/types/responses/reasoning_param.py +17 -0
  481. arkruntime/types/responses/reasoning_summary_part.py +16 -0
  482. arkruntime/types/responses/reasoning_summary_part_param.py +17 -0
  483. arkruntime/types/responses/response.py +58 -0
  484. arkruntime/types/responses/response_agent_tool_call_completed_event.py +19 -0
  485. arkruntime/types/responses/response_agent_tool_call_in_progress_event.py +19 -0
  486. arkruntime/types/responses/response_caching.py +18 -0
  487. arkruntime/types/responses/response_caching_param.py +19 -0
  488. arkruntime/types/responses/response_completed_event.py +28 -0
  489. arkruntime/types/responses/response_content_part_added_event.py +22 -0
  490. arkruntime/types/responses/response_content_part_done_event.py +22 -0
  491. arkruntime/types/responses/response_created_event.py +28 -0
  492. arkruntime/types/responses/response_doubao_app_call_block_added_event.py +21 -0
  493. arkruntime/types/responses/response_doubao_app_call_block_done_event.py +21 -0
  494. arkruntime/types/responses/response_doubao_app_call_completed_event.py +22 -0
  495. arkruntime/types/responses/response_doubao_app_call_failed_event.py +19 -0
  496. arkruntime/types/responses/response_doubao_app_call_in_progress_event.py +19 -0
  497. arkruntime/types/responses/response_doubao_app_call_output_text_delta_event.py +20 -0
  498. arkruntime/types/responses/response_doubao_app_call_output_text_done_event.py +20 -0
  499. arkruntime/types/responses/response_doubao_app_call_reasoning_search_completed_event.py +24 -0
  500. arkruntime/types/responses/response_doubao_app_call_reasoning_search_in_progress_event.py +19 -0
  501. arkruntime/types/responses/response_doubao_app_call_reasoning_search_searching_event.py +20 -0
  502. arkruntime/types/responses/response_doubao_app_call_reasoning_text_delta_event.py +20 -0
  503. arkruntime/types/responses/response_doubao_app_call_reasoning_text_done_event.py +20 -0
  504. arkruntime/types/responses/response_doubao_app_call_search_completed_event.py +24 -0
  505. arkruntime/types/responses/response_doubao_app_call_search_in_progress_event.py +19 -0
  506. arkruntime/types/responses/response_doubao_app_call_search_searching_event.py +20 -0
  507. arkruntime/types/responses/response_error.py +20 -0
  508. arkruntime/types/responses/response_error_event.py +34 -0
  509. arkruntime/types/responses/response_failed_event.py +28 -0
  510. arkruntime/types/responses/response_function_call_arguments_delta_event.py +34 -0
  511. arkruntime/types/responses/response_function_call_arguments_done_event.py +31 -0
  512. arkruntime/types/responses/response_image_process_action.py +16 -0
  513. arkruntime/types/responses/response_image_process_call_completed_event.py +22 -0
  514. arkruntime/types/responses/response_image_process_call_in_progress_event.py +21 -0
  515. arkruntime/types/responses/response_image_process_call_processing_event.py +22 -0
  516. arkruntime/types/responses/response_image_process_error.py +13 -0
  517. arkruntime/types/responses/response_in_progress_event.py +28 -0
  518. arkruntime/types/responses/response_includable.py +15 -0
  519. arkruntime/types/responses/response_incomplete_event.py +28 -0
  520. arkruntime/types/responses/response_knowledge_search_call_completed_event.py +21 -0
  521. arkruntime/types/responses/response_knowledge_search_call_failed_event.py +21 -0
  522. arkruntime/types/responses/response_knowledge_search_call_in_progress_event.py +21 -0
  523. arkruntime/types/responses/response_knowledge_search_call_searching_event.py +21 -0
  524. arkruntime/types/responses/response_mcp_approval_request_event.py +20 -0
  525. arkruntime/types/responses/response_mcp_call_arguments_delta_event.py +35 -0
  526. arkruntime/types/responses/response_mcp_call_arguments_done_event.py +34 -0
  527. arkruntime/types/responses/response_mcp_call_completed_event.py +30 -0
  528. arkruntime/types/responses/response_mcp_call_failed_event.py +30 -0
  529. arkruntime/types/responses/response_mcp_call_in_progress_event.py +30 -0
  530. arkruntime/types/responses/response_mcp_list_tools_completed_event.py +30 -0
  531. arkruntime/types/responses/response_mcp_list_tools_failed_event.py +30 -0
  532. arkruntime/types/responses/response_mcp_list_tools_in_progress_event.py +30 -0
  533. arkruntime/types/responses/response_output_item_added_event.py +20 -0
  534. arkruntime/types/responses/response_output_item_done_event.py +20 -0
  535. arkruntime/types/responses/response_output_text_annotation_added_event.py +46 -0
  536. arkruntime/types/responses/response_reasoning_raw_text_delta_event.py +38 -0
  537. arkruntime/types/responses/response_reasoning_raw_text_done_event.py +38 -0
  538. arkruntime/types/responses/response_reasoning_summary_part_added_event.py +22 -0
  539. arkruntime/types/responses/response_reasoning_summary_part_done_event.py +22 -0
  540. arkruntime/types/responses/response_reasoning_summary_text_delta_event.py +38 -0
  541. arkruntime/types/responses/response_reasoning_summary_text_done_event.py +38 -0
  542. arkruntime/types/responses/response_reasoning_text_delta_event.py +38 -0
  543. arkruntime/types/responses/response_reasoning_text_done_event.py +38 -0
  544. arkruntime/types/responses/response_status.py +16 -0
  545. arkruntime/types/responses/response_stream_event.py +216 -0
  546. arkruntime/types/responses/response_text_config.py +15 -0
  547. arkruntime/types/responses/response_text_config_param.py +16 -0
  548. arkruntime/types/responses/response_text_delta_event.py +38 -0
  549. arkruntime/types/responses/response_text_done_event.py +38 -0
  550. arkruntime/types/responses/response_transcription_part_added_event.py +22 -0
  551. arkruntime/types/responses/response_transcription_part_done_event.py +22 -0
  552. arkruntime/types/responses/response_transcription_text_delta_event.py +46 -0
  553. arkruntime/types/responses/response_transcription_text_done_event.py +52 -0
  554. arkruntime/types/responses/response_usage.py +47 -0
  555. arkruntime/types/responses/response_web_search_call_completed_event.py +30 -0
  556. arkruntime/types/responses/response_web_search_call_in_progress_event.py +30 -0
  557. arkruntime/types/responses/response_web_search_call_searching_event.py +30 -0
  558. arkruntime/types/responses/responses_input.py +15 -0
  559. arkruntime/types/responses/responses_input_param.py +13 -0
  560. arkruntime/types/responses/responses_request.py +50 -0
  561. arkruntime/types/responses/responses_request_param.py +73 -0
  562. arkruntime/types/responses/service_tier.py +14 -0
  563. arkruntime/types/responses/session.py +13 -0
  564. arkruntime/types/responses/session_param.py +13 -0
  565. arkruntime/types/responses/text_format.py +22 -0
  566. arkruntime/types/responses/text_format_param.py +25 -0
  567. arkruntime/types/responses/text_format_type.py +15 -0
  568. arkruntime/types/responses/text_translation_options.py +14 -0
  569. arkruntime/types/responses/thinking.py +17 -0
  570. arkruntime/types/responses/thinking_mode.py +15 -0
  571. arkruntime/types/responses/thinking_param.py +17 -0
  572. arkruntime/types/responses/thinking_turns_param.py +16 -0
  573. arkruntime/types/responses/thinking_turns_param_param.py +17 -0
  574. arkruntime/types/responses/tool.py +34 -0
  575. arkruntime/types/responses/tool_choice.py +16 -0
  576. arkruntime/types/responses/tool_choice_function.py +22 -0
  577. arkruntime/types/responses/tool_choice_function_param.py +19 -0
  578. arkruntime/types/responses/tool_choice_knowledge_search.py +15 -0
  579. arkruntime/types/responses/tool_choice_knowledge_search_param.py +15 -0
  580. arkruntime/types/responses/tool_choice_mcp.py +26 -0
  581. arkruntime/types/responses/tool_choice_mcp_param.py +22 -0
  582. arkruntime/types/responses/tool_choice_options.py +15 -0
  583. arkruntime/types/responses/tool_choice_param.py +14 -0
  584. arkruntime/types/responses/tool_choice_web_search.py +15 -0
  585. arkruntime/types/responses/tool_choice_web_search_param.py +15 -0
  586. arkruntime/types/responses/tool_name_list.py +15 -0
  587. arkruntime/types/responses/tool_name_list_param.py +15 -0
  588. arkruntime/types/responses/tool_param.py +25 -0
  589. arkruntime/types/responses/tool_usage.py +27 -0
  590. arkruntime/types/responses/tool_usage_details.py +30 -0
  591. arkruntime/types/responses/tool_uses_keep.py +16 -0
  592. arkruntime/types/responses/tool_uses_keep_param.py +17 -0
  593. arkruntime/types/responses/tool_uses_trigger.py +16 -0
  594. arkruntime/types/responses/tool_uses_trigger_param.py +17 -0
  595. arkruntime/types/responses/transcription_part.py +19 -0
  596. arkruntime/types/responses/truncation_mode.py +14 -0
  597. arkruntime/types/responses/typed_tool_choice.py +30 -0
  598. arkruntime/types/responses/typed_tool_choice_param.py +21 -0
  599. arkruntime/types/responses/url_citation.py +26 -0
  600. arkruntime/types/responses/url_citation_param.py +35 -0
  601. arkruntime/types/responses/user_location.py +34 -0
  602. arkruntime/types/responses/user_location_param.py +28 -0
  603. arkruntime/types/responses/web_search_action.py +16 -0
  604. arkruntime/types/responses/web_search_source.py +16 -0
  605. arkruntime/types/responses/web_search_tool.py +22 -0
  606. arkruntime/types/responses/web_search_tool_param.py +26 -0
  607. arkruntime/types/session/__init__.py +154 -0
  608. arkruntime/types/session/_init_extras_shim.py +88 -0
  609. arkruntime/types/session/agent_identifier.py +19 -0
  610. arkruntime/types/session/agent_ref.py +31 -0
  611. arkruntime/types/session/base64_document_source.py +27 -0
  612. arkruntime/types/session/base64_image_source.py +27 -0
  613. arkruntime/types/session/cache_creation.py +26 -0
  614. arkruntime/types/session/create_session_request.py +50 -0
  615. arkruntime/types/session/create_session_resource_request.py +29 -0
  616. arkruntime/types/session/delete_session_response.py +24 -0
  617. arkruntime/types/session/document_source.py +34 -0
  618. arkruntime/types/session/file_document_source.py +23 -0
  619. arkruntime/types/session/file_image_source.py +23 -0
  620. arkruntime/types/session/image_source.py +28 -0
  621. arkruntime/types/session/list_session_events_response_wire.py +31 -0
  622. arkruntime/types/session/list_session_resources_response.py +24 -0
  623. arkruntime/types/session/list_session_threads_response.py +28 -0
  624. arkruntime/types/session/list_sessions_order.py +18 -0
  625. arkruntime/types/session/list_sessions_response.py +28 -0
  626. arkruntime/types/session/managed_agents_agent_message_preview.py +27 -0
  627. arkruntime/types/session/managed_agents_agent_thinking_preview.py +27 -0
  628. arkruntime/types/session/managed_agents_delta_content.py +34 -0
  629. arkruntime/types/session/managed_agents_delta_event.py +34 -0
  630. arkruntime/types/session/managed_agents_delta_text_block.py +27 -0
  631. arkruntime/types/session/managed_agents_document_block.py +33 -0
  632. arkruntime/types/session/managed_agents_event_params.py +57 -0
  633. arkruntime/types/session/managed_agents_file_rubric_params.py +23 -0
  634. arkruntime/types/session/managed_agents_image_block.py +25 -0
  635. arkruntime/types/session/managed_agents_message_content_block.py +30 -0
  636. arkruntime/types/session/managed_agents_rubric.py +26 -0
  637. arkruntime/types/session/managed_agents_search_result_block.py +38 -0
  638. arkruntime/types/session/managed_agents_session_event.py +34 -0
  639. arkruntime/types/session/managed_agents_start_event.py +31 -0
  640. arkruntime/types/session/managed_agents_start_event_preview.py +27 -0
  641. arkruntime/types/session/managed_agents_stream_preview_event.py +26 -0
  642. arkruntime/types/session/managed_agents_system_content_block.py +23 -0
  643. arkruntime/types/session/managed_agents_system_message_event_params.py +34 -0
  644. arkruntime/types/session/managed_agents_text_block.py +23 -0
  645. arkruntime/types/session/managed_agents_text_rubric_params.py +23 -0
  646. arkruntime/types/session/managed_agents_tool_result_content_block.py +34 -0
  647. arkruntime/types/session/managed_agents_user_custom_tool_result_event_params.py +44 -0
  648. arkruntime/types/session/managed_agents_user_define_outcome_event_params.py +45 -0
  649. arkruntime/types/session/managed_agents_user_interrupt_event_params.py +31 -0
  650. arkruntime/types/session/managed_agents_user_message_event_params.py +34 -0
  651. arkruntime/types/session/managed_agents_user_tool_confirmation_event_params.py +46 -0
  652. arkruntime/types/session/managed_agents_user_tool_result_event_params.py +44 -0
  653. arkruntime/types/session/plain_text_document_source.py +27 -0
  654. arkruntime/types/session/search_result_citations.py +20 -0
  655. arkruntime/types/session/search_result_content.py +20 -0
  656. arkruntime/types/session/send_session_events_request.py +24 -0
  657. arkruntime/types/session/send_session_events_response.py +22 -0
  658. arkruntime/types/session/session.py +80 -0
  659. arkruntime/types/session/session_resource.py +70 -0
  660. arkruntime/types/session/session_resource_access.py +18 -0
  661. arkruntime/types/session/session_resource_type.py +19 -0
  662. arkruntime/types/session/session_status.py +20 -0
  663. arkruntime/types/session/session_stream_shim.py +540 -0
  664. arkruntime/types/session/session_thread.py +56 -0
  665. arkruntime/types/session/session_thread_status.py +20 -0
  666. arkruntime/types/session/session_usage.py +36 -0
  667. arkruntime/types/session/tag.py +26 -0
  668. arkruntime/types/session/tool_confirmation_result.py +18 -0
  669. arkruntime/types/session/update_session_request.py +28 -0
  670. arkruntime/types/session/url_document_source.py +23 -0
  671. arkruntime/types/session/url_image_source.py +23 -0
  672. arkruntime/types/skill/__init__.py +18 -0
  673. arkruntime/types/skill/_init_extras_shim.py +12 -0
  674. arkruntime/types/skill/create_skill_request.py +18 -0
  675. arkruntime/types/skill/skill.py +46 -0
  676. arkruntime/types/tokenization/__init__.py +24 -0
  677. arkruntime/types/tokenization/_init_extras_shim.py +12 -0
  678. arkruntime/types/tokenization/tokenization_input.py +17 -0
  679. arkruntime/types/tokenization/tokenization_input_param.py +15 -0
  680. arkruntime/types/tokenization/tokenization_item.py +39 -0
  681. arkruntime/types/tokenization/tokenization_request.py +30 -0
  682. arkruntime/types/tokenization/tokenization_request_param.py +30 -0
  683. arkruntime/types/tokenization/tokenization_response.py +36 -0
  684. arkruntime/types/vault/__init__.py +62 -0
  685. arkruntime/types/vault/_init_extras_shim.py +12 -0
  686. arkruntime/types/vault/create_credential_request.py +32 -0
  687. arkruntime/types/vault/create_vault_request.py +26 -0
  688. arkruntime/types/vault/credential.py +52 -0
  689. arkruntime/types/vault/credential_auth.py +64 -0
  690. arkruntime/types/vault/credential_auth_type.py +22 -0
  691. arkruntime/types/vault/credential_networking.py +29 -0
  692. arkruntime/types/vault/credential_networking_type.py +18 -0
  693. arkruntime/types/vault/credential_validation.py +54 -0
  694. arkruntime/types/vault/delete_credential_response.py +26 -0
  695. arkruntime/types/vault/delete_vault_response.py +26 -0
  696. arkruntime/types/vault/limited_credential_networking.py +22 -0
  697. arkruntime/types/vault/list_credentials_response.py +35 -0
  698. arkruntime/types/vault/list_vaults_response.py +32 -0
  699. arkruntime/types/vault/mcp_probe.py +26 -0
  700. arkruntime/types/vault/mcpo_auth_refresh.py +45 -0
  701. arkruntime/types/vault/refresh_http_response.py +32 -0
  702. arkruntime/types/vault/refresh_object.py +27 -0
  703. arkruntime/types/vault/refresh_status.py +20 -0
  704. arkruntime/types/vault/token_endpoint_auth.py +29 -0
  705. arkruntime/types/vault/token_endpoint_auth_type.py +19 -0
  706. arkruntime/types/vault/update_credential_request.py +35 -0
  707. arkruntime/types/vault/update_vault_request.py +27 -0
  708. arkruntime/types/vault/validation_status.py +19 -0
  709. arkruntime/types/vault/vault.py +42 -0
  710. arkruntime-0.1.0.dist-info/METADATA +347 -0
  711. arkruntime-0.1.0.dist-info/RECORD +714 -0
  712. arkruntime-0.1.0.dist-info/WHEEL +5 -0
  713. arkruntime-0.1.0.dist-info/licenses/LICENSE +201 -0
  714. arkruntime-0.1.0.dist-info/top_level.txt +1 -0
arkruntime/_models.py ADDED
@@ -0,0 +1,733 @@
1
+ # Copyright (c) 2025 ByteDance Ltd. and/or its affiliates.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ # License text: https://github.com/volcengine/ark-runtime-python/blob/main/LICENSE
4
+
5
+ from __future__ import annotations
6
+
7
+ import inspect
8
+ import os
9
+ from datetime import date, datetime
10
+ from enum import Enum
11
+ from typing import (
12
+ TYPE_CHECKING,
13
+ Any,
14
+ Callable,
15
+ Generic,
16
+ Type,
17
+ TypeVar,
18
+ cast,
19
+ )
20
+
21
+ import pydantic
22
+ from pydantic.fields import FieldInfo
23
+ from typing_extensions import (
24
+ ClassVar,
25
+ Literal,
26
+ ParamSpec,
27
+ Protocol,
28
+ TypeAliasType,
29
+ TypeGuard,
30
+ override,
31
+ runtime_checkable,
32
+ )
33
+
34
+ from ._compat import (
35
+ PYDANTIC_V2,
36
+ ConfigDict,
37
+ field_get_default,
38
+ get_args,
39
+ get_model_config,
40
+ get_model_fields,
41
+ get_origin,
42
+ is_literal_type,
43
+ is_union,
44
+ parse_obj,
45
+ )
46
+ from ._compat import (
47
+ GenericModel as BaseGenericModel,
48
+ )
49
+ from ._types import ModelT
50
+ from ._utils import (
51
+ PropertyInfo,
52
+ coerce_boolean,
53
+ extract_type_arg,
54
+ is_annotated_type,
55
+ is_list,
56
+ is_mapping,
57
+ lru_cache,
58
+ parse_date,
59
+ parse_datetime,
60
+ strip_annotated_type,
61
+ )
62
+
63
+ if TYPE_CHECKING:
64
+ from pydantic_core.core_schema import (
65
+ ModelField,
66
+ ModelFieldsSchema,
67
+ )
68
+
69
+ __all__ = ["BaseModel", "GenericModel"]
70
+
71
+ _T = TypeVar("_T")
72
+ _BaseModelT = TypeVar("_BaseModelT", bound="BaseModel")
73
+
74
+ P = ParamSpec("P")
75
+
76
+
77
+ @runtime_checkable
78
+ class _ConfigProtocol(Protocol):
79
+ allow_population_by_field_name: bool
80
+
81
+
82
+ class BaseModel(pydantic.BaseModel):
83
+ if PYDANTIC_V2:
84
+ model_config: ClassVar[ConfigDict] = ConfigDict(
85
+ extra="allow",
86
+ defer_build=coerce_boolean(os.environ.get("DEFER_PYDANTIC_BUILD", "true")),
87
+ protected_namespaces=(),
88
+ )
89
+ else:
90
+
91
+ @property
92
+ @override
93
+ def model_fields_set(self) -> set[str]:
94
+ # a forwards-compat shim for pydantic v2
95
+ return self.__fields_set__ # type: ignore
96
+
97
+ class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated]
98
+ extra: Any = pydantic.Extra.allow # type: ignore
99
+
100
+ def to_dict(
101
+ self,
102
+ *,
103
+ mode: Literal["json", "python"] = "python",
104
+ use_api_names: bool = True,
105
+ exclude_unset: bool = True,
106
+ exclude_defaults: bool = False,
107
+ exclude_none: bool = False,
108
+ warnings: bool = True,
109
+ ) -> dict[str, object]:
110
+ """Recursively generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
111
+
112
+ By default, fields that were not set by the API will not be included,
113
+ and keys will match the API response, *not* the property names from the model.
114
+
115
+ For example, if the API responds with `"fooBar": true` but we've defined a `foo_bar: bool` property,
116
+ the output will use the `"fooBar"` key (unless `use_api_names=False` is passed).
117
+
118
+ Args:
119
+ mode:
120
+ If mode is 'json', the dictionary will only contain JSON serializable types. e.g. `datetime` will be turned into a string, `"2024-3-22T18:11:19.117000Z"`.
121
+ If mode is 'python', the dictionary may contain any Python objects. e.g. `datetime(2024, 3, 22)`
122
+
123
+ use_api_names: Whether to use the key that the API responded with or the property name. Defaults to `True`.
124
+ exclude_unset: Whether to exclude fields that have not been explicitly set.
125
+ exclude_defaults: Whether to exclude fields that are set to their default value from the output.
126
+ exclude_none: Whether to exclude fields that have a value of `None` from the output.
127
+ warnings: Whether to log warnings when invalid fields are encountered. This is only supported in Pydantic v2.
128
+ """
129
+ return self.model_dump(
130
+ mode=mode,
131
+ by_alias=use_api_names,
132
+ exclude_unset=exclude_unset,
133
+ exclude_defaults=exclude_defaults,
134
+ exclude_none=exclude_none,
135
+ warnings=warnings,
136
+ )
137
+
138
+ def to_json(
139
+ self,
140
+ *,
141
+ indent: int | None = 2,
142
+ use_api_names: bool = True,
143
+ exclude_unset: bool = True,
144
+ exclude_defaults: bool = False,
145
+ exclude_none: bool = False,
146
+ warnings: bool = True,
147
+ ) -> str:
148
+ """Generates a JSON string representing this model as it would be received from or sent to the API (but with indentation).
149
+
150
+ By default, fields that were not set by the API will not be included,
151
+ and keys will match the API response, *not* the property names from the model.
152
+
153
+ For example, if the API responds with `"fooBar": true` but we've defined a `foo_bar: bool` property,
154
+ the output will use the `"fooBar"` key (unless `use_api_names=False` is passed).
155
+
156
+ Args:
157
+ indent: Indentation to use in the JSON output. If `None` is passed, the output will be compact. Defaults to `2`
158
+ use_api_names: Whether to use the key that the API responded with or the property name. Defaults to `True`.
159
+ exclude_unset: Whether to exclude fields that have not been explicitly set.
160
+ exclude_defaults: Whether to exclude fields that have the default value.
161
+ exclude_none: Whether to exclude fields that have a value of `None`.
162
+ warnings: Whether to show any warnings that occurred during serialization. This is only supported in Pydantic v2.
163
+ """
164
+ return self.model_dump_json(
165
+ indent=indent,
166
+ by_alias=use_api_names,
167
+ exclude_unset=exclude_unset,
168
+ exclude_defaults=exclude_defaults,
169
+ exclude_none=exclude_none,
170
+ warnings=warnings,
171
+ )
172
+
173
+ @override
174
+ def __str__(self) -> str:
175
+ # mypy complains about an invalid self arg
176
+ return f"{self.__repr_name__()}({self.__repr_str__(', ')})" # type: ignore[misc]
177
+
178
+ # Override the 'construct' method in a way that supports recursive parsing without validation.
179
+ # Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
180
+ @classmethod
181
+ @override
182
+ def construct(
183
+ cls: Type[ModelT],
184
+ _fields_set: set[str] | None = None,
185
+ **values: object,
186
+ ) -> ModelT:
187
+ m = cls.__new__(cls)
188
+ fields_values: dict[str, object] = {}
189
+
190
+ config = get_model_config(cls)
191
+ populate_by_name = (
192
+ config.allow_population_by_field_name
193
+ if isinstance(config, _ConfigProtocol)
194
+ else config.get("populate_by_name")
195
+ )
196
+
197
+ if _fields_set is None:
198
+ _fields_set = set()
199
+
200
+ model_fields = get_model_fields(cls)
201
+ for name, field in model_fields.items():
202
+ key = field.alias
203
+ if key is None or (key not in values and populate_by_name):
204
+ key = name
205
+
206
+ if key in values:
207
+ fields_values[name] = _construct_field(value=values[key], field=field, key=key)
208
+ _fields_set.add(name)
209
+ else:
210
+ fields_values[name] = field_get_default(field)
211
+
212
+ _extra = {}
213
+ for key, value in values.items():
214
+ if key not in model_fields:
215
+ if PYDANTIC_V2:
216
+ _extra[key] = value
217
+ else:
218
+ _fields_set.add(key)
219
+ fields_values[key] = value
220
+
221
+ object.__setattr__(m, "__dict__", fields_values)
222
+
223
+ if PYDANTIC_V2:
224
+ # these properties are copied from Pydantic's `model_construct()` method
225
+ object.__setattr__(m, "__pydantic_private__", None)
226
+ object.__setattr__(m, "__pydantic_extra__", _extra)
227
+ object.__setattr__(m, "__pydantic_fields_set__", _fields_set)
228
+ else:
229
+ # init_private_attributes() does not exist in v2
230
+ m._init_private_attributes() # type: ignore
231
+
232
+ # copied from Pydantic v1's `construct()` method
233
+ object.__setattr__(m, "__fields_set__", _fields_set)
234
+
235
+ return m
236
+
237
+ if not TYPE_CHECKING:
238
+ # type checkers incorrectly complain about this assignment
239
+ # because the type signatures are technically different
240
+ # although not in practice
241
+ model_construct = construct
242
+
243
+ if not PYDANTIC_V2:
244
+ # we define aliases for some of the new pydantic v2 methods so
245
+ # that we can just document these methods without having to specify
246
+ # a specific pydantic version as some users may not know which
247
+ # pydantic version they are currently using
248
+
249
+ @override
250
+ def model_dump(
251
+ self,
252
+ *,
253
+ mode: Literal["json", "python"] | str = "python",
254
+ include: (set[int] | set[str] | dict[int, Any] | dict[str, Any] | None) = None,
255
+ exclude: (set[int] | set[str] | dict[int, Any] | dict[str, Any] | None) = None,
256
+ by_alias: bool = False,
257
+ exclude_unset: bool = False,
258
+ exclude_defaults: bool = False,
259
+ exclude_none: bool = False,
260
+ round_trip: bool = False,
261
+ warnings: bool = True,
262
+ ) -> dict[str, Any]:
263
+ """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump
264
+
265
+ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
266
+
267
+ Args:
268
+ mode: The mode in which `to_python` should run.
269
+ If mode is 'json', the dictionary will only contain JSON serializable types.
270
+ If mode is 'python', the dictionary may contain any Python objects.
271
+ include: A list of fields to include in the output.
272
+ exclude: A list of fields to exclude from the output.
273
+ by_alias: Whether to use the field's alias in the dictionary key if defined.
274
+ exclude_unset: Whether to exclude fields that are unset or None from the output.
275
+ exclude_defaults: Whether to exclude fields that are set to their default value from the output.
276
+ exclude_none: Whether to exclude fields that have a value of `None` from the output.
277
+ round_trip: Whether to enable serialization and deserialization round-trip support.
278
+ warnings: Whether to log warnings when invalid fields are encountered.
279
+
280
+ Returns:
281
+ A dictionary representation of the model.
282
+ """
283
+ if mode != "python":
284
+ raise ValueError("mode is only supported in Pydantic v2")
285
+ if round_trip != False:
286
+ raise ValueError("round_trip is only supported in Pydantic v2")
287
+ if warnings != True:
288
+ raise ValueError("warnings is only supported in Pydantic v2")
289
+ return super().dict( # pyright: ignore[reportDeprecated]
290
+ include=include,
291
+ exclude=exclude,
292
+ by_alias=by_alias,
293
+ exclude_unset=exclude_unset,
294
+ exclude_defaults=exclude_defaults,
295
+ exclude_none=exclude_none,
296
+ )
297
+
298
+ @override
299
+ def model_dump_json(
300
+ self,
301
+ *,
302
+ indent: int | None = None,
303
+ include: (set[int] | set[str] | dict[int, Any] | dict[str, Any] | None) = None,
304
+ exclude: (set[int] | set[str] | dict[int, Any] | dict[str, Any] | None) = None,
305
+ by_alias: bool = False,
306
+ exclude_unset: bool = False,
307
+ exclude_defaults: bool = False,
308
+ exclude_none: bool = False,
309
+ round_trip: bool = False,
310
+ warnings: bool = True,
311
+ ) -> str:
312
+ """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json
313
+
314
+ Generates a JSON representation of the model using Pydantic's `to_json` method.
315
+
316
+ Args:
317
+ indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
318
+ include: Field(s) to include in the JSON output. Can take either a string or set of strings.
319
+ exclude: Field(s) to exclude from the JSON output. Can take either a string or set of strings.
320
+ by_alias: Whether to serialize using field aliases.
321
+ exclude_unset: Whether to exclude fields that have not been explicitly set.
322
+ exclude_defaults: Whether to exclude fields that have the default value.
323
+ exclude_none: Whether to exclude fields that have a value of `None`.
324
+ round_trip: Whether to use serialization/deserialization between JSON and class instance.
325
+ warnings: Whether to show any warnings that occurred during serialization.
326
+
327
+ Returns:
328
+ A JSON string representation of the model.
329
+ """
330
+ if round_trip != False:
331
+ raise ValueError("round_trip is only supported in Pydantic v2")
332
+ if warnings != True:
333
+ raise ValueError("warnings is only supported in Pydantic v2")
334
+ return super().json( # type: ignore[reportDeprecated]
335
+ indent=indent,
336
+ include=include,
337
+ exclude=exclude,
338
+ by_alias=by_alias,
339
+ exclude_unset=exclude_unset,
340
+ exclude_defaults=exclude_defaults,
341
+ exclude_none=exclude_none,
342
+ )
343
+
344
+
345
+ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
346
+ if value is None:
347
+ return field_get_default(field)
348
+
349
+ if PYDANTIC_V2:
350
+ type_ = field.annotation
351
+ else:
352
+ type_ = cast(type, field.outer_type_) # type: ignore
353
+
354
+ if type_ is None:
355
+ raise RuntimeError(f"Unexpected field type is None for {key}")
356
+
357
+ return construct_type(value=value, type_=type_)
358
+
359
+
360
+ def is_basemodel(type_: type) -> bool:
361
+ """Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`"""
362
+ if is_union(type_):
363
+ for variant in get_args(type_):
364
+ if is_basemodel(variant):
365
+ return True
366
+
367
+ return False
368
+
369
+ return is_basemodel_type(type_)
370
+
371
+
372
+ def is_basemodel_type(type_: type) -> TypeGuard[type[BaseModel] | type[GenericModel]]:
373
+ origin = get_origin(type_) or type_
374
+ return issubclass(origin, BaseModel) or issubclass(origin, GenericModel)
375
+
376
+
377
+ def build(
378
+ base_model_cls: Callable[P, _BaseModelT],
379
+ *args: P.args,
380
+ **kwargs: P.kwargs,
381
+ ) -> _BaseModelT:
382
+ """Construct a BaseModel class without validation.
383
+
384
+ This is useful for cases where you need to instantiate a `BaseModel`
385
+ from an API response as this provides type-safe params which isn't supported
386
+ by helpers like `construct_type()`.
387
+
388
+ ```py
389
+ build(MyModel, my_field_a="foo", my_field_b=123)
390
+ ```
391
+ """
392
+ if args:
393
+ raise TypeError(
394
+ "Received positional arguments which are not supported; Keyword arguments must be used instead",
395
+ )
396
+
397
+ return cast(_BaseModelT, construct_type(type_=base_model_cls, value=kwargs))
398
+
399
+
400
+ def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T:
401
+ """Loose coercion to the expected type with construction of nested values.
402
+
403
+ Note: the returned value from this function is not guaranteed to match the
404
+ given type.
405
+ """
406
+ return cast(_T, construct_type(value=value, type_=type_))
407
+
408
+
409
+ def construct_type(*, value: object, type_: object) -> object:
410
+ """Loose coercion to the expected type with construction of nested values.
411
+
412
+ If the given value does not match the expected type then it is returned as-is.
413
+ """
414
+ # we allow `object` as the input type because otherwise, passing things like
415
+ # `Literal['value']` will be reported as a type error by type checkers
416
+ type_ = cast("type[object]", type_)
417
+
418
+ # unwrap `TypeAliasType` (PEP 695-style aliases emitted by codegen for
419
+ # union root models) -> the aliased type
420
+ if type(type_) is TypeAliasType:
421
+ type_ = cast("type[object]", type_.__value__)
422
+
423
+ # unwrap `Annotated[T, ...]` -> `T`
424
+ if is_annotated_type(type_):
425
+ meta: tuple[Any, ...] = get_args(type_)[1:]
426
+ type_ = extract_type_arg(type_, 0)
427
+ else:
428
+ meta = tuple()
429
+
430
+ # we need to use the origin class for any types that are subscripted generics
431
+ # e.g. Dict[str, object]
432
+ origin = get_origin(type_) or type_
433
+ args = get_args(type_)
434
+
435
+ if is_union(origin):
436
+ try:
437
+ return validate_type(type_=cast("type[object]", type_), value=value)
438
+ except Exception:
439
+ pass
440
+
441
+ # if the type is a discriminated union then we want to construct the right variant
442
+ # in the union, even if the data doesn't match exactly, otherwise we'd break code
443
+ # that relies on the constructed class types, e.g.
444
+ #
445
+ # class FooType:
446
+ # kind: Literal['foo']
447
+ # value: str
448
+ #
449
+ # class BarType:
450
+ # kind: Literal['bar']
451
+ # value: int
452
+ #
453
+ # without this block, if the data we get is something like `{'kind': 'bar', 'value': 'foo'}` then
454
+ # we'd end up constructing `FooType` when it should be `BarType`.
455
+ discriminator = _build_discriminated_union_meta(union=type_, meta_annotations=meta)
456
+ if discriminator and is_mapping(value):
457
+ variant_value = value.get(discriminator.field_alias_from or discriminator.field_name)
458
+ if variant_value and isinstance(variant_value, str):
459
+ variant_type = discriminator.mapping.get(variant_value)
460
+ if variant_type:
461
+ return construct_type(type_=variant_type, value=value)
462
+
463
+ # if the data is not valid, use the first variant that doesn't fail while deserializing
464
+ for variant in args:
465
+ try:
466
+ return construct_type(value=value, type_=variant)
467
+ except Exception:
468
+ continue
469
+
470
+ raise RuntimeError(f"Could not convert data into a valid instance of {type_}")
471
+
472
+ if origin == dict:
473
+ if not is_mapping(value):
474
+ return value
475
+
476
+ _, items_type = get_args(type_) # Dict[_, items_type]
477
+ return {key: construct_type(value=item, type_=items_type) for key, item in value.items()}
478
+
479
+ if not is_literal_type(type_) and (issubclass(origin, BaseModel) or issubclass(origin, GenericModel)):
480
+ if is_list(value):
481
+ return [cast(Any, type_).construct(**entry) if is_mapping(entry) else entry for entry in value]
482
+
483
+ if is_mapping(value):
484
+ if issubclass(type_, BaseModel):
485
+ return type_.construct(**value) # type: ignore[arg-type]
486
+
487
+ return cast(Any, type_).construct(**value)
488
+
489
+ if origin == list:
490
+ if not is_list(value):
491
+ return value
492
+
493
+ inner_type = args[0] # List[inner_type]
494
+ return [construct_type(value=entry, type_=inner_type) for entry in value]
495
+
496
+ if origin == float:
497
+ if isinstance(value, int):
498
+ coerced = float(value)
499
+ if coerced != value:
500
+ return value
501
+ return coerced
502
+
503
+ return value
504
+
505
+ if type_ == datetime:
506
+ try:
507
+ return parse_datetime(value) # type: ignore
508
+ except Exception:
509
+ return value
510
+
511
+ if type_ == date:
512
+ try:
513
+ return parse_date(value) # type: ignore
514
+ except Exception:
515
+ return value
516
+
517
+ # Coerce a raw wire scalar into the declared Enum. Codegen emits fields
518
+ # like ``Session.status: SessionStatus`` (direct Enum type — no
519
+ # ``Optional[...]`` / ``Union[...]`` wrapper), and the union branch above
520
+ # never fires for those. Without this fallback, ``.status`` comes back as
521
+ # the raw ``str`` from the wire, so ``session.status == SessionStatus.idle``
522
+ # is silently False. ``inspect.isclass`` gate avoids ``issubclass`` on
523
+ # non-class objects (Annotated, Literal, TypeAliasType — already unwrapped
524
+ # above, but be defensive).
525
+ if inspect.isclass(origin) and issubclass(origin, Enum):
526
+ try:
527
+ return origin(value)
528
+ except (ValueError, KeyError):
529
+ return value
530
+
531
+ return value
532
+
533
+
534
+ @runtime_checkable
535
+ class CachedDiscriminatorType(Protocol):
536
+ __discriminator__: DiscriminatorDetails
537
+
538
+
539
+ class DiscriminatorDetails:
540
+ field_name: str
541
+ """The name of the discriminator field in the variant class, e.g.
542
+
543
+ ```py
544
+ class Foo(BaseModel):
545
+ type: Literal['foo']
546
+ ```
547
+
548
+ Will result in field_name='type'
549
+ """
550
+
551
+ field_alias_from: str | None
552
+ """The name of the discriminator field in the API response, e.g.
553
+
554
+ ```py
555
+ class Foo(BaseModel):
556
+ type: Literal['foo'] = Field(alias='type_from_api')
557
+ ```
558
+
559
+ Will result in field_alias_from='type_from_api'
560
+ """
561
+
562
+ mapping: dict[str, type]
563
+ """Mapping of discriminator value to variant type, e.g.
564
+
565
+ {'foo': FooVariant, 'bar': BarVariant}
566
+ """
567
+
568
+ def __init__(
569
+ self,
570
+ *,
571
+ mapping: dict[str, type],
572
+ discriminator_field: str,
573
+ discriminator_alias: str | None,
574
+ ) -> None:
575
+ self.mapping = mapping
576
+ self.field_name = discriminator_field
577
+ self.field_alias_from = discriminator_alias
578
+
579
+
580
+ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, ...]) -> DiscriminatorDetails | None:
581
+ if isinstance(union, CachedDiscriminatorType):
582
+ return union.__discriminator__
583
+
584
+ discriminator_field_name: str | None = None
585
+
586
+ for annotation in meta_annotations:
587
+ if isinstance(annotation, PropertyInfo) and annotation.discriminator is not None:
588
+ discriminator_field_name = annotation.discriminator
589
+ break
590
+ # codegen emits pydantic-native `Field(discriminator=...)` annotations
591
+ if isinstance(annotation, FieldInfo) and annotation.discriminator is not None:
592
+ discriminator_field_name = annotation.discriminator
593
+ break
594
+
595
+ if not discriminator_field_name:
596
+ return None
597
+
598
+ mapping: dict[str, type] = {}
599
+ discriminator_alias: str | None = None
600
+
601
+ for variant in get_args(union):
602
+ variant = strip_annotated_type(variant)
603
+ if is_basemodel_type(variant):
604
+ if PYDANTIC_V2:
605
+ field = _extract_field_schema_pv2(variant, discriminator_field_name)
606
+ if not field:
607
+ continue
608
+
609
+ # Note: if one variant defines an alias then they all should
610
+ discriminator_alias = field.get("serialization_alias")
611
+
612
+ field_schema = field["schema"]
613
+
614
+ if field_schema["type"] == "literal":
615
+ for entry in field_schema["expected"]:
616
+ if isinstance(entry, str):
617
+ mapping[entry] = variant
618
+ else:
619
+ field_info = cast("dict[str, FieldInfo]", variant.__fields__).get(discriminator_field_name) # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
620
+ if not field_info:
621
+ continue
622
+
623
+ # Note: if one variant defines an alias then they all should
624
+ discriminator_alias = field_info.alias
625
+
626
+ if field_info.annotation and is_literal_type(field_info.annotation):
627
+ for entry in get_args(field_info.annotation):
628
+ if isinstance(entry, str):
629
+ mapping[entry] = variant
630
+
631
+ if not mapping:
632
+ return None
633
+
634
+ details = DiscriminatorDetails(
635
+ mapping=mapping,
636
+ discriminator_field=discriminator_field_name,
637
+ discriminator_alias=discriminator_alias,
638
+ )
639
+ cast(CachedDiscriminatorType, union).__discriminator__ = details
640
+ return details
641
+
642
+
643
+ def _extract_field_schema_pv2(model: type[BaseModel], field_name: str) -> ModelField | None:
644
+ schema = model.__pydantic_core_schema__
645
+ if schema["type"] == "definitions":
646
+ schema = schema["schema"]
647
+ if schema["type"] != "model":
648
+ return None
649
+
650
+ fields_schema = schema["schema"]
651
+ if fields_schema["type"] != "model-fields":
652
+ return None
653
+
654
+ fields_schema = cast("ModelFieldsSchema", fields_schema)
655
+
656
+ field = fields_schema["fields"].get(field_name)
657
+ if not field:
658
+ return None
659
+
660
+ return cast("ModelField", field) # pyright: ignore[reportUnnecessaryCast]
661
+
662
+
663
+ def validate_type(*, type_: type[_T], value: object) -> _T:
664
+ """Strict validation that the given value matches the expected type"""
665
+ if inspect.isclass(type_) and issubclass(type_, pydantic.BaseModel):
666
+ return cast(_T, parse_obj(type_, value))
667
+
668
+ return cast(_T, _validate_non_model_type(type_=type_, value=value))
669
+
670
+
671
+ def add_request_id(obj: BaseModel, request_id: str | None) -> None:
672
+ obj._request_id = request_id
673
+
674
+ # in Pydantic v1, using setattr like we do above causes the attribute
675
+ # to be included when serializing the model which we don't want in this
676
+ # case so we need to explicitly exclude it
677
+ if not PYDANTIC_V2:
678
+ try:
679
+ exclude_fields = obj.__exclude_fields__ # type: ignore
680
+ except AttributeError:
681
+ cast(Any, obj).__exclude_fields__ = {"_request_id", "__exclude_fields__"}
682
+ else:
683
+ cast(Any, obj).__exclude_fields__ = {
684
+ *(exclude_fields or {}),
685
+ "_request_id",
686
+ "__exclude_fields__",
687
+ }
688
+
689
+
690
+ # our use of subclasssing here causes weirdness for type checkers,
691
+ # so we just pretend that we don't subclass
692
+ if TYPE_CHECKING:
693
+ GenericModel = BaseModel
694
+ else:
695
+
696
+ class GenericModel(BaseGenericModel, BaseModel):
697
+ pass
698
+
699
+
700
+ if PYDANTIC_V2:
701
+ from pydantic import TypeAdapter as _TypeAdapter
702
+
703
+ _CachedTypeAdapter = cast("TypeAdapter[object]", lru_cache(maxsize=None)(_TypeAdapter))
704
+
705
+ if TYPE_CHECKING:
706
+ from pydantic import TypeAdapter
707
+ else:
708
+ TypeAdapter = _CachedTypeAdapter
709
+
710
+ def _validate_non_model_type(*, type_: type[_T], value: object) -> _T:
711
+ return TypeAdapter(type_).validate_python(value)
712
+
713
+ elif not TYPE_CHECKING: # TODO: condition is weird
714
+
715
+ class RootModel(GenericModel, Generic[_T]):
716
+ """Used as a placeholder to easily convert runtime types to a Pydantic format
717
+ to provide validation.
718
+
719
+ For example:
720
+ ```py
721
+ validated = RootModel[int](__root__="5").__root__
722
+ # validated: 5
723
+ ```
724
+ """
725
+
726
+ __root__: _T
727
+
728
+ def _validate_non_model_type(*, type_: type[_T], value: object) -> _T:
729
+ model = _create_pydantic_model(type_).validate(value)
730
+ return cast(_T, model.__root__)
731
+
732
+ def _create_pydantic_model(type_: _T) -> Type[RootModel[_T]]:
733
+ return RootModel[type_] # type: ignore