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.
- arkruntime/__init__.py +11 -0
- arkruntime/_base_client.py +1373 -0
- arkruntime/_client.py +585 -0
- arkruntime/_compat.py +265 -0
- arkruntime/_constants.py +55 -0
- arkruntime/_exceptions.py +188 -0
- arkruntime/_files.py +122 -0
- arkruntime/_legacy_response.py +438 -0
- arkruntime/_managed_agents_serialize.py +55 -0
- arkruntime/_models.py +733 -0
- arkruntime/_qs.py +164 -0
- arkruntime/_request_options.py +118 -0
- arkruntime/_resource.py +41 -0
- arkruntime/_response.py +599 -0
- arkruntime/_streaming.py +460 -0
- arkruntime/_types.py +207 -0
- arkruntime/_utils/__init__.py +144 -0
- arkruntime/_utils/_key_agreement.py +217 -0
- arkruntime/_utils/_logs.py +28 -0
- arkruntime/_utils/_model_breaker.py +87 -0
- arkruntime/_utils/_streams.py +17 -0
- arkruntime/_utils/_transform.py +463 -0
- arkruntime/_utils/_typing.py +157 -0
- arkruntime/_utils/_utils.py +473 -0
- arkruntime/common/__init__.py +6 -0
- arkruntime/common/_parsing/__init__.py +31 -0
- arkruntime/common/_parsing/_completions.py +272 -0
- arkruntime/common/_parsing/_responses.py +174 -0
- arkruntime/common/_pydantic.py +166 -0
- arkruntime/common/_tools.py +85 -0
- arkruntime/common/streaming/__init__.py +4 -0
- arkruntime/common/streaming/_deltas.py +68 -0
- arkruntime/common/streaming/chat/__init__.py +49 -0
- arkruntime/common/streaming/chat/_completions.py +732 -0
- arkruntime/common/streaming/chat/_events.py +96 -0
- arkruntime/common/streaming/chat/_types.py +28 -0
- arkruntime/pagination.py +128 -0
- arkruntime/resources/__init__.py +75 -0
- arkruntime/resources/agents/__init__.py +3 -0
- arkruntime/resources/agents/agents.py +372 -0
- arkruntime/resources/batch/__init__.py +6 -0
- arkruntime/resources/batch/_utils.py +156 -0
- arkruntime/resources/batch/batch.py +40 -0
- arkruntime/resources/batch/chat/__init__.py +6 -0
- arkruntime/resources/batch/chat/chat.py +22 -0
- arkruntime/resources/batch/chat/completions.py +217 -0
- arkruntime/resources/batch/embeddings.py +150 -0
- arkruntime/resources/batch/multimodal_embeddings.py +160 -0
- arkruntime/resources/beta/__init__.py +4 -0
- arkruntime/resources/beta/beta.py +73 -0
- arkruntime/resources/beta/chat/__init__.py +13 -0
- arkruntime/resources/beta/chat/chat.py +23 -0
- arkruntime/resources/beta/chat/completions.py +356 -0
- arkruntime/resources/chat/__init__.py +7 -0
- arkruntime/resources/chat/chat.py +23 -0
- arkruntime/resources/chat/completions.py +242 -0
- arkruntime/resources/content_generation/__init__.py +7 -0
- arkruntime/resources/content_generation/content_generation.py +21 -0
- arkruntime/resources/content_generation/tasks.py +331 -0
- arkruntime/resources/embeddings/__init__.py +6 -0
- arkruntime/resources/embeddings/embeddings.py +140 -0
- arkruntime/resources/encryption.py +187 -0
- arkruntime/resources/environments/__init__.py +3 -0
- arkruntime/resources/environments/environments.py +216 -0
- arkruntime/resources/files/__init__.py +6 -0
- arkruntime/resources/files/files.py +401 -0
- arkruntime/resources/images/__init__.py +10 -0
- arkruntime/resources/images/images.py +152 -0
- arkruntime/resources/memory_stores/__init__.py +7 -0
- arkruntime/resources/memory_stores/memories.py +262 -0
- arkruntime/resources/memory_stores/memory_stores.py +223 -0
- arkruntime/resources/multimodal_embeddings/__init__.py +9 -0
- arkruntime/resources/multimodal_embeddings/multimodal_embeddings.py +150 -0
- arkruntime/resources/responses/__init__.py +8 -0
- arkruntime/resources/responses/input_items.py +241 -0
- arkruntime/resources/responses/responses.py +467 -0
- arkruntime/resources/sessions/__init__.py +24 -0
- arkruntime/resources/sessions/session_events.py +336 -0
- arkruntime/resources/sessions/session_resources.py +89 -0
- arkruntime/resources/sessions/session_threads.py +275 -0
- arkruntime/resources/sessions/sessions.py +331 -0
- arkruntime/resources/skills/__init__.py +3 -0
- arkruntime/resources/skills/skills.py +112 -0
- arkruntime/resources/tokenization/__init__.py +9 -0
- arkruntime/resources/tokenization/tokenization.py +131 -0
- arkruntime/resources/vaults/__init__.py +4 -0
- arkruntime/resources/vaults/credentials.py +253 -0
- arkruntime/resources/vaults/vaults.py +197 -0
- arkruntime/types/__init__.py +7 -0
- arkruntime/types/agent/__init__.py +56 -0
- arkruntime/types/agent/_init_extras_shim.py +12 -0
- arkruntime/types/agent/agent.py +86 -0
- arkruntime/types/agent/agent_ref.py +32 -0
- arkruntime/types/agent/agent_ref_type.py +18 -0
- arkruntime/types/agent/agent_skill_ref.py +32 -0
- arkruntime/types/agent/create_agent_request.py +65 -0
- arkruntime/types/agent/delete_agent_response.py +20 -0
- arkruntime/types/agent/list_agents_response.py +32 -0
- arkruntime/types/agent/mcp_server.py +30 -0
- arkruntime/types/agent/mcp_server_type.py +16 -0
- arkruntime/types/agent/model_config.py +28 -0
- arkruntime/types/agent/model_speed.py +18 -0
- arkruntime/types/agent/multiagent_config.py +29 -0
- arkruntime/types/agent/multiagent_type.py +16 -0
- arkruntime/types/agent/permission_policy.py +22 -0
- arkruntime/types/agent/permission_policy_type.py +18 -0
- arkruntime/types/agent/skill_ref_type.py +19 -0
- arkruntime/types/agent/tag.py +26 -0
- arkruntime/types/agent/tool_config.py +32 -0
- arkruntime/types/agent/tool_default_config.py +28 -0
- arkruntime/types/agent/tool_item.py +57 -0
- arkruntime/types/agent/update_agent_request.py +70 -0
- arkruntime/types/chat/__init__.py +212 -0
- arkruntime/types/chat/_init_extras_shim.py +73 -0
- arkruntime/types/chat/chat_completion_choice_logprobs.py +20 -0
- arkruntime/types/chat/chat_completion_content_part.py +32 -0
- arkruntime/types/chat/chat_completion_content_part_audio.py +23 -0
- arkruntime/types/chat/chat_completion_content_part_audio_input_audio.py +30 -0
- arkruntime/types/chat/chat_completion_content_part_audio_input_audio_param.py +25 -0
- arkruntime/types/chat/chat_completion_content_part_audio_param.py +22 -0
- arkruntime/types/chat/chat_completion_content_part_file.py +21 -0
- arkruntime/types/chat/chat_completion_content_part_file_file.py +30 -0
- arkruntime/types/chat/chat_completion_content_part_file_file_param.py +25 -0
- arkruntime/types/chat/chat_completion_content_part_file_param.py +22 -0
- arkruntime/types/chat/chat_completion_content_part_image.py +23 -0
- arkruntime/types/chat/chat_completion_content_part_image_image_url.py +33 -0
- arkruntime/types/chat/chat_completion_content_part_image_image_url_param.py +28 -0
- arkruntime/types/chat/chat_completion_content_part_image_param.py +22 -0
- arkruntime/types/chat/chat_completion_content_part_param.py +29 -0
- arkruntime/types/chat/chat_completion_content_part_text.py +22 -0
- arkruntime/types/chat/chat_completion_content_part_text_param.py +19 -0
- arkruntime/types/chat/chat_completion_content_part_video.py +23 -0
- arkruntime/types/chat/chat_completion_content_part_video_param.py +22 -0
- arkruntime/types/chat/chat_completion_content_part_video_video_url.py +36 -0
- arkruntime/types/chat/chat_completion_content_part_video_video_url_param.py +30 -0
- arkruntime/types/chat/chat_completion_message_content.py +17 -0
- arkruntime/types/chat/chat_completion_message_content_param.py +15 -0
- arkruntime/types/chat/chat_completion_message_tool_call.py +29 -0
- arkruntime/types/chat/chat_completion_message_tool_call_chunk.py +31 -0
- arkruntime/types/chat/chat_completion_message_tool_call_chunk_function.py +16 -0
- arkruntime/types/chat/chat_completion_message_tool_call_function.py +23 -0
- arkruntime/types/chat/chat_completion_message_tool_call_function_param.py +22 -0
- arkruntime/types/chat/chat_completion_message_tool_call_param.py +26 -0
- arkruntime/types/chat/chat_completion_named_tool_choice.py +21 -0
- arkruntime/types/chat/chat_completion_named_tool_choice_param.py +22 -0
- arkruntime/types/chat/chat_completion_request.py +129 -0
- arkruntime/types/chat/chat_completion_request_assistant_message.py +39 -0
- arkruntime/types/chat/chat_completion_request_assistant_message_param.py +36 -0
- arkruntime/types/chat/chat_completion_request_message.py +32 -0
- arkruntime/types/chat/chat_completion_request_message_param.py +29 -0
- arkruntime/types/chat/chat_completion_request_param.py +122 -0
- arkruntime/types/chat/chat_completion_request_system_message.py +25 -0
- arkruntime/types/chat/chat_completion_request_system_message_param.py +23 -0
- arkruntime/types/chat/chat_completion_request_tool_message.py +29 -0
- arkruntime/types/chat/chat_completion_request_tool_message_param.py +26 -0
- arkruntime/types/chat/chat_completion_request_user_message.py +29 -0
- arkruntime/types/chat/chat_completion_request_user_message_param.py +27 -0
- arkruntime/types/chat/chat_completion_response.py +52 -0
- arkruntime/types/chat/chat_completion_response_choice.py +36 -0
- arkruntime/types/chat/chat_completion_response_format.py +28 -0
- arkruntime/types/chat/chat_completion_response_format_json_schema.py +33 -0
- arkruntime/types/chat/chat_completion_response_format_json_schema_param.py +31 -0
- arkruntime/types/chat/chat_completion_response_format_param.py +27 -0
- arkruntime/types/chat/chat_completion_response_message.py +37 -0
- arkruntime/types/chat/chat_completion_role.py +16 -0
- arkruntime/types/chat/chat_completion_service_status.py +17 -0
- arkruntime/types/chat/chat_completion_stop.py +13 -0
- arkruntime/types/chat/chat_completion_stop_param.py +11 -0
- arkruntime/types/chat/chat_completion_stream_choice_logprobs.py +17 -0
- arkruntime/types/chat/chat_completion_stream_options.py +22 -0
- arkruntime/types/chat/chat_completion_stream_options_param.py +19 -0
- arkruntime/types/chat/chat_completion_stream_response.py +34 -0
- arkruntime/types/chat/chat_completion_stream_response_choice.py +27 -0
- arkruntime/types/chat/chat_completion_stream_response_delta.py +36 -0
- arkruntime/types/chat/chat_completion_token_logprob.py +26 -0
- arkruntime/types/chat/chat_completion_token_logprob_top_logprob.py +17 -0
- arkruntime/types/chat/chat_completion_tool.py +20 -0
- arkruntime/types/chat/chat_completion_tool_choice.py +18 -0
- arkruntime/types/chat/chat_completion_tool_choice_function.py +13 -0
- arkruntime/types/chat/chat_completion_tool_choice_function_param.py +13 -0
- arkruntime/types/chat/chat_completion_tool_choice_param.py +16 -0
- arkruntime/types/chat/chat_completion_tool_param.py +20 -0
- arkruntime/types/chat/completion_tokens_details.py +16 -0
- arkruntime/types/chat/completion_usage.py +35 -0
- arkruntime/types/chat/error.py +28 -0
- arkruntime/types/chat/error_response.py +15 -0
- arkruntime/types/chat/finish_reason.py +16 -0
- arkruntime/types/chat/function_object.py +35 -0
- arkruntime/types/chat/function_object_param.py +38 -0
- arkruntime/types/chat/image_detail.py +16 -0
- arkruntime/types/chat/image_pixel_limit.py +16 -0
- arkruntime/types/chat/image_pixel_limit_param.py +17 -0
- arkruntime/types/chat/model_fallback_status.py +20 -0
- arkruntime/types/chat/moderation_hit_type.py +14 -0
- arkruntime/types/chat/parsed_chat_completion_shim.py +52 -0
- arkruntime/types/chat/parsed_function_tool_call_shim.py +29 -0
- arkruntime/types/chat/prompt_tokens_details.py +34 -0
- arkruntime/types/chat/reasoning_effort.py +19 -0
- arkruntime/types/chat/request_service_tier.py +15 -0
- arkruntime/types/chat/response_format_type.py +15 -0
- arkruntime/types/chat/response_service_tier.py +15 -0
- arkruntime/types/chat/thinking.py +17 -0
- arkruntime/types/chat/thinking_mode.py +15 -0
- arkruntime/types/chat/thinking_param.py +17 -0
- arkruntime/types/chat/tool_choice_mode.py +15 -0
- arkruntime/types/chat/tool_type.py +13 -0
- arkruntime/types/chat/tool_type_param.py +11 -0
- arkruntime/types/chat/video_image_pixel_limit.py +16 -0
- arkruntime/types/chat/video_image_pixel_limit_param.py +17 -0
- arkruntime/types/completion_usage.py +43 -0
- arkruntime/types/content_generation/__init__.py +66 -0
- arkruntime/types/content_generation/_init_extras_shim.py +12 -0
- arkruntime/types/content_generation/audio_role.py +16 -0
- arkruntime/types/content_generation/audio_url.py +16 -0
- arkruntime/types/content_generation/audio_url_param.py +14 -0
- arkruntime/types/content_generation/content_generation_task.py +125 -0
- arkruntime/types/content_generation/content_item.py +54 -0
- arkruntime/types/content_generation/content_item_param.py +46 -0
- arkruntime/types/content_generation/content_type.py +21 -0
- arkruntime/types/content_generation/create_content_generation_task_request.py +106 -0
- arkruntime/types/content_generation/create_content_generation_task_request_param.py +83 -0
- arkruntime/types/content_generation/create_content_generation_task_response.py +16 -0
- arkruntime/types/content_generation/draft_task.py +16 -0
- arkruntime/types/content_generation/draft_task_param.py +14 -0
- arkruntime/types/content_generation/image_role.py +20 -0
- arkruntime/types/content_generation/image_url.py +16 -0
- arkruntime/types/content_generation/image_url_param.py +14 -0
- arkruntime/types/content_generation/list_content_generation_tasks_response.py +24 -0
- arkruntime/types/content_generation/reasoning_effort.py +16 -0
- arkruntime/types/content_generation/task_content.py +30 -0
- arkruntime/types/content_generation/task_error.py +20 -0
- arkruntime/types/content_generation/task_status.py +21 -0
- arkruntime/types/content_generation/task_usage.py +28 -0
- arkruntime/types/content_generation/tool.py +18 -0
- arkruntime/types/content_generation/tool_param.py +17 -0
- arkruntime/types/content_generation/tool_type.py +13 -0
- arkruntime/types/content_generation/tool_type_param.py +11 -0
- arkruntime/types/content_generation/tool_usage.py +18 -0
- arkruntime/types/content_generation/video_role.py +16 -0
- arkruntime/types/content_generation/video_url.py +16 -0
- arkruntime/types/content_generation/video_url_param.py +14 -0
- arkruntime/types/embedding/__init__.py +30 -0
- arkruntime/types/embedding/_init_extras_shim.py +12 -0
- arkruntime/types/embedding/embedding.py +18 -0
- arkruntime/types/embedding/embedding_input.py +18 -0
- arkruntime/types/embedding/embedding_input_param.py +16 -0
- arkruntime/types/embedding/embedding_item.py +32 -0
- arkruntime/types/embedding/embedding_request.py +39 -0
- arkruntime/types/embedding/embedding_request_param.py +37 -0
- arkruntime/types/embedding/embedding_response.py +41 -0
- arkruntime/types/embedding/embedding_usage.py +24 -0
- arkruntime/types/embedding/encoding_format.py +14 -0
- arkruntime/types/environment/__init__.py +36 -0
- arkruntime/types/environment/_init_extras_shim.py +12 -0
- arkruntime/types/environment/create_environment_request.py +41 -0
- arkruntime/types/environment/delete_environment_response.py +24 -0
- arkruntime/types/environment/env_config.py +38 -0
- arkruntime/types/environment/env_config_type.py +18 -0
- arkruntime/types/environment/environment.py +57 -0
- arkruntime/types/environment/environment_scope.py +18 -0
- arkruntime/types/environment/list_environments_response.py +30 -0
- arkruntime/types/environment/networking_config.py +37 -0
- arkruntime/types/environment/networking_type.py +18 -0
- arkruntime/types/environment/packages_config.py +47 -0
- arkruntime/types/environment/update_environment_request.py +45 -0
- arkruntime/types/file/__init__.py +40 -0
- arkruntime/types/file/_init_extras_shim.py +12 -0
- arkruntime/types/file/file_create_request.py +41 -0
- arkruntime/types/file/file_create_request_param.py +41 -0
- arkruntime/types/file/file_deleted.py +30 -0
- arkruntime/types/file/file_error.py +32 -0
- arkruntime/types/file/file_list_response.py +42 -0
- arkruntime/types/file/file_object.py +71 -0
- arkruntime/types/file/order.py +18 -0
- arkruntime/types/file/preprocess_configs.py +24 -0
- arkruntime/types/file/preprocess_configs_param.py +22 -0
- arkruntime/types/file/purpose.py +18 -0
- arkruntime/types/file/status.py +19 -0
- arkruntime/types/file/tos_storage.py +28 -0
- arkruntime/types/file/tos_storage_param.py +25 -0
- arkruntime/types/file/video.py +26 -0
- arkruntime/types/file/video_param.py +23 -0
- arkruntime/types/images/__init__.py +55 -0
- arkruntime/types/images/_init_extras_shim.py +12 -0
- arkruntime/types/images/bounding_box.py +27 -0
- arkruntime/types/images/create_image_generation_request.py +88 -0
- arkruntime/types/images/create_image_generation_request_param.py +73 -0
- arkruntime/types/images/image_data_item.py +58 -0
- arkruntime/types/images/image_error.py +20 -0
- arkruntime/types/images/image_generation_response.py +43 -0
- arkruntime/types/images/image_generation_stream_event.py +74 -0
- arkruntime/types/images/image_generation_stream_event_type.py +19 -0
- arkruntime/types/images/optimize_prompt_mode.py +18 -0
- arkruntime/types/images/optimize_prompt_options.py +20 -0
- arkruntime/types/images/optimize_prompt_options_param.py +18 -0
- arkruntime/types/images/output_format.py +18 -0
- arkruntime/types/images/response_format.py +18 -0
- arkruntime/types/images/sequential_image_generation_mode.py +18 -0
- arkruntime/types/images/sequential_image_generation_options.py +18 -0
- arkruntime/types/images/sequential_image_generation_options_param.py +16 -0
- arkruntime/types/images/tool.py +18 -0
- arkruntime/types/images/tool_param.py +17 -0
- arkruntime/types/images/tool_type.py +13 -0
- arkruntime/types/images/tool_type_param.py +11 -0
- arkruntime/types/images/tool_usage.py +18 -0
- arkruntime/types/images/usage.py +36 -0
- arkruntime/types/memory/__init__.py +44 -0
- arkruntime/types/memory/_init_extras_shim.py +12 -0
- arkruntime/types/memory/actor.py +26 -0
- arkruntime/types/memory/actor_type.py +16 -0
- arkruntime/types/memory/create_memory_request.py +24 -0
- arkruntime/types/memory/create_memory_store_request.py +30 -0
- arkruntime/types/memory/delete_memory_response.py +26 -0
- arkruntime/types/memory/delete_memory_store_response.py +26 -0
- arkruntime/types/memory/list_memories_order_by.py +18 -0
- arkruntime/types/memory/list_memories_response.py +32 -0
- arkruntime/types/memory/list_memory_stores_response.py +28 -0
- arkruntime/types/memory/memory.py +64 -0
- arkruntime/types/memory/memory_list_item.py +58 -0
- arkruntime/types/memory/memory_list_item_type.py +20 -0
- arkruntime/types/memory/memory_store.py +64 -0
- arkruntime/types/memory/update_memory_request.py +27 -0
- arkruntime/types/memory/update_memory_store_request.py +31 -0
- arkruntime/types/multimodal_embedding/__init__.py +54 -0
- arkruntime/types/multimodal_embedding/_init_extras_shim.py +12 -0
- arkruntime/types/multimodal_embedding/embedding.py +13 -0
- arkruntime/types/multimodal_embedding/embedding_data_item.py +33 -0
- arkruntime/types/multimodal_embedding/embedding_input.py +34 -0
- arkruntime/types/multimodal_embedding/embedding_input_param.py +29 -0
- arkruntime/types/multimodal_embedding/embedding_input_type.py +15 -0
- arkruntime/types/multimodal_embedding/embedding_object.py +14 -0
- arkruntime/types/multimodal_embedding/embedding_usage.py +26 -0
- arkruntime/types/multimodal_embedding/encoding_format.py +14 -0
- arkruntime/types/multimodal_embedding/image_url.py +16 -0
- arkruntime/types/multimodal_embedding/image_url_param.py +14 -0
- arkruntime/types/multimodal_embedding/multi_embedding_config.py +18 -0
- arkruntime/types/multimodal_embedding/multi_embedding_config_param.py +17 -0
- arkruntime/types/multimodal_embedding/multi_embedding_mode.py +14 -0
- arkruntime/types/multimodal_embedding/multi_modal_embedding_request.py +47 -0
- arkruntime/types/multimodal_embedding/multi_modal_embedding_request_param.py +39 -0
- arkruntime/types/multimodal_embedding/multi_modal_embedding_response.py +41 -0
- arkruntime/types/multimodal_embedding/prompt_tokens_details.py +20 -0
- arkruntime/types/multimodal_embedding/sparse_embedding_config.py +20 -0
- arkruntime/types/multimodal_embedding/sparse_embedding_config_param.py +18 -0
- arkruntime/types/multimodal_embedding/sparse_embedding_mode.py +14 -0
- arkruntime/types/multimodal_embedding/sparse_embedding_value.py +20 -0
- arkruntime/types/multimodal_embedding/video_url.py +22 -0
- arkruntime/types/multimodal_embedding/video_url_param.py +19 -0
- arkruntime/types/responses/__init__.py +528 -0
- arkruntime/types/responses/_init_extras_shim.py +47 -0
- arkruntime/types/responses/annotation.py +20 -0
- arkruntime/types/responses/annotation_param.py +14 -0
- arkruntime/types/responses/applied_edit.py +22 -0
- arkruntime/types/responses/audio_chunk.py +15 -0
- arkruntime/types/responses/audio_chunking_strategy.py +18 -0
- arkruntime/types/responses/audio_chunking_strategy_param.py +21 -0
- arkruntime/types/responses/cache_mode.py +14 -0
- arkruntime/types/responses/clear_thinking.py +18 -0
- arkruntime/types/responses/clear_thinking_keep.py +18 -0
- arkruntime/types/responses/clear_thinking_keep_param.py +19 -0
- arkruntime/types/responses/clear_thinking_param.py +19 -0
- arkruntime/types/responses/clear_thinking_response.py +16 -0
- arkruntime/types/responses/clear_tool_uses.py +23 -0
- arkruntime/types/responses/clear_tool_uses_inputs.py +18 -0
- arkruntime/types/responses/clear_tool_uses_inputs_param.py +19 -0
- arkruntime/types/responses/clear_tool_uses_param.py +27 -0
- arkruntime/types/responses/clear_tool_uses_response.py +16 -0
- arkruntime/types/responses/content_filter.py +14 -0
- arkruntime/types/responses/content_item.py +36 -0
- arkruntime/types/responses/content_item_audio.py +20 -0
- arkruntime/types/responses/content_item_audio_param.py +23 -0
- arkruntime/types/responses/content_item_file.py +19 -0
- arkruntime/types/responses/content_item_file_param.py +23 -0
- arkruntime/types/responses/content_item_image.py +22 -0
- arkruntime/types/responses/content_item_image_param.py +26 -0
- arkruntime/types/responses/content_item_param.py +29 -0
- arkruntime/types/responses/content_item_text.py +22 -0
- arkruntime/types/responses/content_item_text_param.py +19 -0
- arkruntime/types/responses/content_item_video.py +27 -0
- arkruntime/types/responses/content_item_video_param.py +24 -0
- arkruntime/types/responses/context_management.py +17 -0
- arkruntime/types/responses/context_management_param.py +17 -0
- arkruntime/types/responses/context_management_response.py +17 -0
- arkruntime/types/responses/cover_image.py +26 -0
- arkruntime/types/responses/cover_image_param.py +22 -0
- arkruntime/types/responses/delete_response_response.py +17 -0
- arkruntime/types/responses/doc_citation.py +19 -0
- arkruntime/types/responses/doc_citation_param.py +23 -0
- arkruntime/types/responses/doubao_app_call_block.py +30 -0
- arkruntime/types/responses/doubao_app_call_block_output_text.py +21 -0
- arkruntime/types/responses/doubao_app_call_block_reasoning_search.py +24 -0
- arkruntime/types/responses/doubao_app_call_block_reasoning_text.py +21 -0
- arkruntime/types/responses/doubao_app_call_block_search.py +24 -0
- arkruntime/types/responses/doubao_app_feature.py +20 -0
- arkruntime/types/responses/doubao_app_feature_item.py +18 -0
- arkruntime/types/responses/doubao_app_feature_item_param.py +19 -0
- arkruntime/types/responses/doubao_app_feature_mode.py +14 -0
- arkruntime/types/responses/doubao_app_feature_param.py +23 -0
- arkruntime/types/responses/doubao_app_search_result.py +15 -0
- arkruntime/types/responses/doubao_app_search_text_item.py +15 -0
- arkruntime/types/responses/doubao_app_tool.py +20 -0
- arkruntime/types/responses/doubao_app_tool_param.py +22 -0
- arkruntime/types/responses/edit.py +19 -0
- arkruntime/types/responses/edit_param.py +14 -0
- arkruntime/types/responses/function_tool.py +32 -0
- arkruntime/types/responses/function_tool_param.py +29 -0
- arkruntime/types/responses/image_detail.py +16 -0
- arkruntime/types/responses/image_pixel_limit.py +16 -0
- arkruntime/types/responses/image_pixel_limit_param.py +17 -0
- arkruntime/types/responses/image_process_options.py +15 -0
- arkruntime/types/responses/image_process_options_param.py +15 -0
- arkruntime/types/responses/image_process_tool.py +21 -0
- arkruntime/types/responses/image_process_tool_param.py +25 -0
- arkruntime/types/responses/incomplete_details.py +24 -0
- arkruntime/types/responses/input_item.py +38 -0
- arkruntime/types/responses/input_item_list_params_shim.py +39 -0
- arkruntime/types/responses/input_item_param.py +33 -0
- arkruntime/types/responses/input_tokens_details.py +17 -0
- arkruntime/types/responses/item_agent_tool_call.py +20 -0
- arkruntime/types/responses/item_doubao_app_call.py +22 -0
- arkruntime/types/responses/item_easy_message.py +22 -0
- arkruntime/types/responses/item_easy_message_param.py +26 -0
- arkruntime/types/responses/item_function_image_process.py +24 -0
- arkruntime/types/responses/item_function_knowledge_search.py +21 -0
- arkruntime/types/responses/item_function_mcp_approval_request.py +34 -0
- arkruntime/types/responses/item_function_mcp_approval_request_param.py +28 -0
- arkruntime/types/responses/item_function_mcp_approval_response.py +34 -0
- arkruntime/types/responses/item_function_mcp_approval_response_param.py +28 -0
- arkruntime/types/responses/item_function_mcp_call.py +44 -0
- arkruntime/types/responses/item_function_mcp_call_param.py +38 -0
- arkruntime/types/responses/item_function_mcp_list_tools.py +36 -0
- arkruntime/types/responses/item_function_mcp_list_tools_param.py +30 -0
- arkruntime/types/responses/item_function_tool_call.py +37 -0
- arkruntime/types/responses/item_function_tool_call_output.py +22 -0
- arkruntime/types/responses/item_function_tool_call_output_param.py +26 -0
- arkruntime/types/responses/item_function_tool_call_param.py +32 -0
- arkruntime/types/responses/item_function_web_search.py +21 -0
- arkruntime/types/responses/item_input_message.py +24 -0
- arkruntime/types/responses/item_output_message.py +23 -0
- arkruntime/types/responses/item_reasoning.py +24 -0
- arkruntime/types/responses/item_reasoning_param.py +29 -0
- arkruntime/types/responses/item_reference.py +16 -0
- arkruntime/types/responses/item_status.py +17 -0
- arkruntime/types/responses/item_transcription.py +21 -0
- arkruntime/types/responses/knowledge_search_tool.py +46 -0
- arkruntime/types/responses/knowledge_search_tool_param.py +37 -0
- arkruntime/types/responses/list_input_items_response.py +21 -0
- arkruntime/types/responses/mcp_allowed_tools.py +17 -0
- arkruntime/types/responses/mcp_allowed_tools_filter.py +15 -0
- arkruntime/types/responses/mcp_allowed_tools_filter_param.py +15 -0
- arkruntime/types/responses/mcp_allowed_tools_param.py +13 -0
- arkruntime/types/responses/mcp_approval_mode.py +14 -0
- arkruntime/types/responses/mcp_list_tools_tool.py +30 -0
- arkruntime/types/responses/mcp_list_tools_tool_param.py +25 -0
- arkruntime/types/responses/mcp_require_approval.py +18 -0
- arkruntime/types/responses/mcp_require_approval_param.py +14 -0
- arkruntime/types/responses/mcp_tool.py +24 -0
- arkruntime/types/responses/mcp_tool_approval_filter.py +19 -0
- arkruntime/types/responses/mcp_tool_approval_filter_always.py +15 -0
- arkruntime/types/responses/mcp_tool_approval_filter_always_param.py +15 -0
- arkruntime/types/responses/mcp_tool_approval_filter_never.py +15 -0
- arkruntime/types/responses/mcp_tool_approval_filter_never_param.py +15 -0
- arkruntime/types/responses/mcp_tool_approval_filter_param.py +20 -0
- arkruntime/types/responses/mcp_tool_param.py +30 -0
- arkruntime/types/responses/message_content.py +15 -0
- arkruntime/types/responses/message_content_param.py +13 -0
- arkruntime/types/responses/message_role.py +16 -0
- arkruntime/types/responses/order.py +18 -0
- arkruntime/types/responses/output_content_item.py +23 -0
- arkruntime/types/responses/output_content_item_param.py +18 -0
- arkruntime/types/responses/output_content_item_reasoning_text.py +19 -0
- arkruntime/types/responses/output_content_item_reasoning_text_param.py +21 -0
- arkruntime/types/responses/output_content_item_text.py +19 -0
- arkruntime/types/responses/output_content_item_text_param.py +21 -0
- arkruntime/types/responses/output_item.py +46 -0
- arkruntime/types/responses/output_tokens_details.py +13 -0
- arkruntime/types/responses/parsed_response_shim.py +106 -0
- arkruntime/types/responses/reasoning.py +17 -0
- arkruntime/types/responses/reasoning_effort.py +19 -0
- arkruntime/types/responses/reasoning_param.py +17 -0
- arkruntime/types/responses/reasoning_summary_part.py +16 -0
- arkruntime/types/responses/reasoning_summary_part_param.py +17 -0
- arkruntime/types/responses/response.py +58 -0
- arkruntime/types/responses/response_agent_tool_call_completed_event.py +19 -0
- arkruntime/types/responses/response_agent_tool_call_in_progress_event.py +19 -0
- arkruntime/types/responses/response_caching.py +18 -0
- arkruntime/types/responses/response_caching_param.py +19 -0
- arkruntime/types/responses/response_completed_event.py +28 -0
- arkruntime/types/responses/response_content_part_added_event.py +22 -0
- arkruntime/types/responses/response_content_part_done_event.py +22 -0
- arkruntime/types/responses/response_created_event.py +28 -0
- arkruntime/types/responses/response_doubao_app_call_block_added_event.py +21 -0
- arkruntime/types/responses/response_doubao_app_call_block_done_event.py +21 -0
- arkruntime/types/responses/response_doubao_app_call_completed_event.py +22 -0
- arkruntime/types/responses/response_doubao_app_call_failed_event.py +19 -0
- arkruntime/types/responses/response_doubao_app_call_in_progress_event.py +19 -0
- arkruntime/types/responses/response_doubao_app_call_output_text_delta_event.py +20 -0
- arkruntime/types/responses/response_doubao_app_call_output_text_done_event.py +20 -0
- arkruntime/types/responses/response_doubao_app_call_reasoning_search_completed_event.py +24 -0
- arkruntime/types/responses/response_doubao_app_call_reasoning_search_in_progress_event.py +19 -0
- arkruntime/types/responses/response_doubao_app_call_reasoning_search_searching_event.py +20 -0
- arkruntime/types/responses/response_doubao_app_call_reasoning_text_delta_event.py +20 -0
- arkruntime/types/responses/response_doubao_app_call_reasoning_text_done_event.py +20 -0
- arkruntime/types/responses/response_doubao_app_call_search_completed_event.py +24 -0
- arkruntime/types/responses/response_doubao_app_call_search_in_progress_event.py +19 -0
- arkruntime/types/responses/response_doubao_app_call_search_searching_event.py +20 -0
- arkruntime/types/responses/response_error.py +20 -0
- arkruntime/types/responses/response_error_event.py +34 -0
- arkruntime/types/responses/response_failed_event.py +28 -0
- arkruntime/types/responses/response_function_call_arguments_delta_event.py +34 -0
- arkruntime/types/responses/response_function_call_arguments_done_event.py +31 -0
- arkruntime/types/responses/response_image_process_action.py +16 -0
- arkruntime/types/responses/response_image_process_call_completed_event.py +22 -0
- arkruntime/types/responses/response_image_process_call_in_progress_event.py +21 -0
- arkruntime/types/responses/response_image_process_call_processing_event.py +22 -0
- arkruntime/types/responses/response_image_process_error.py +13 -0
- arkruntime/types/responses/response_in_progress_event.py +28 -0
- arkruntime/types/responses/response_includable.py +15 -0
- arkruntime/types/responses/response_incomplete_event.py +28 -0
- arkruntime/types/responses/response_knowledge_search_call_completed_event.py +21 -0
- arkruntime/types/responses/response_knowledge_search_call_failed_event.py +21 -0
- arkruntime/types/responses/response_knowledge_search_call_in_progress_event.py +21 -0
- arkruntime/types/responses/response_knowledge_search_call_searching_event.py +21 -0
- arkruntime/types/responses/response_mcp_approval_request_event.py +20 -0
- arkruntime/types/responses/response_mcp_call_arguments_delta_event.py +35 -0
- arkruntime/types/responses/response_mcp_call_arguments_done_event.py +34 -0
- arkruntime/types/responses/response_mcp_call_completed_event.py +30 -0
- arkruntime/types/responses/response_mcp_call_failed_event.py +30 -0
- arkruntime/types/responses/response_mcp_call_in_progress_event.py +30 -0
- arkruntime/types/responses/response_mcp_list_tools_completed_event.py +30 -0
- arkruntime/types/responses/response_mcp_list_tools_failed_event.py +30 -0
- arkruntime/types/responses/response_mcp_list_tools_in_progress_event.py +30 -0
- arkruntime/types/responses/response_output_item_added_event.py +20 -0
- arkruntime/types/responses/response_output_item_done_event.py +20 -0
- arkruntime/types/responses/response_output_text_annotation_added_event.py +46 -0
- arkruntime/types/responses/response_reasoning_raw_text_delta_event.py +38 -0
- arkruntime/types/responses/response_reasoning_raw_text_done_event.py +38 -0
- arkruntime/types/responses/response_reasoning_summary_part_added_event.py +22 -0
- arkruntime/types/responses/response_reasoning_summary_part_done_event.py +22 -0
- arkruntime/types/responses/response_reasoning_summary_text_delta_event.py +38 -0
- arkruntime/types/responses/response_reasoning_summary_text_done_event.py +38 -0
- arkruntime/types/responses/response_reasoning_text_delta_event.py +38 -0
- arkruntime/types/responses/response_reasoning_text_done_event.py +38 -0
- arkruntime/types/responses/response_status.py +16 -0
- arkruntime/types/responses/response_stream_event.py +216 -0
- arkruntime/types/responses/response_text_config.py +15 -0
- arkruntime/types/responses/response_text_config_param.py +16 -0
- arkruntime/types/responses/response_text_delta_event.py +38 -0
- arkruntime/types/responses/response_text_done_event.py +38 -0
- arkruntime/types/responses/response_transcription_part_added_event.py +22 -0
- arkruntime/types/responses/response_transcription_part_done_event.py +22 -0
- arkruntime/types/responses/response_transcription_text_delta_event.py +46 -0
- arkruntime/types/responses/response_transcription_text_done_event.py +52 -0
- arkruntime/types/responses/response_usage.py +47 -0
- arkruntime/types/responses/response_web_search_call_completed_event.py +30 -0
- arkruntime/types/responses/response_web_search_call_in_progress_event.py +30 -0
- arkruntime/types/responses/response_web_search_call_searching_event.py +30 -0
- arkruntime/types/responses/responses_input.py +15 -0
- arkruntime/types/responses/responses_input_param.py +13 -0
- arkruntime/types/responses/responses_request.py +50 -0
- arkruntime/types/responses/responses_request_param.py +73 -0
- arkruntime/types/responses/service_tier.py +14 -0
- arkruntime/types/responses/session.py +13 -0
- arkruntime/types/responses/session_param.py +13 -0
- arkruntime/types/responses/text_format.py +22 -0
- arkruntime/types/responses/text_format_param.py +25 -0
- arkruntime/types/responses/text_format_type.py +15 -0
- arkruntime/types/responses/text_translation_options.py +14 -0
- arkruntime/types/responses/thinking.py +17 -0
- arkruntime/types/responses/thinking_mode.py +15 -0
- arkruntime/types/responses/thinking_param.py +17 -0
- arkruntime/types/responses/thinking_turns_param.py +16 -0
- arkruntime/types/responses/thinking_turns_param_param.py +17 -0
- arkruntime/types/responses/tool.py +34 -0
- arkruntime/types/responses/tool_choice.py +16 -0
- arkruntime/types/responses/tool_choice_function.py +22 -0
- arkruntime/types/responses/tool_choice_function_param.py +19 -0
- arkruntime/types/responses/tool_choice_knowledge_search.py +15 -0
- arkruntime/types/responses/tool_choice_knowledge_search_param.py +15 -0
- arkruntime/types/responses/tool_choice_mcp.py +26 -0
- arkruntime/types/responses/tool_choice_mcp_param.py +22 -0
- arkruntime/types/responses/tool_choice_options.py +15 -0
- arkruntime/types/responses/tool_choice_param.py +14 -0
- arkruntime/types/responses/tool_choice_web_search.py +15 -0
- arkruntime/types/responses/tool_choice_web_search_param.py +15 -0
- arkruntime/types/responses/tool_name_list.py +15 -0
- arkruntime/types/responses/tool_name_list_param.py +15 -0
- arkruntime/types/responses/tool_param.py +25 -0
- arkruntime/types/responses/tool_usage.py +27 -0
- arkruntime/types/responses/tool_usage_details.py +30 -0
- arkruntime/types/responses/tool_uses_keep.py +16 -0
- arkruntime/types/responses/tool_uses_keep_param.py +17 -0
- arkruntime/types/responses/tool_uses_trigger.py +16 -0
- arkruntime/types/responses/tool_uses_trigger_param.py +17 -0
- arkruntime/types/responses/transcription_part.py +19 -0
- arkruntime/types/responses/truncation_mode.py +14 -0
- arkruntime/types/responses/typed_tool_choice.py +30 -0
- arkruntime/types/responses/typed_tool_choice_param.py +21 -0
- arkruntime/types/responses/url_citation.py +26 -0
- arkruntime/types/responses/url_citation_param.py +35 -0
- arkruntime/types/responses/user_location.py +34 -0
- arkruntime/types/responses/user_location_param.py +28 -0
- arkruntime/types/responses/web_search_action.py +16 -0
- arkruntime/types/responses/web_search_source.py +16 -0
- arkruntime/types/responses/web_search_tool.py +22 -0
- arkruntime/types/responses/web_search_tool_param.py +26 -0
- arkruntime/types/session/__init__.py +154 -0
- arkruntime/types/session/_init_extras_shim.py +88 -0
- arkruntime/types/session/agent_identifier.py +19 -0
- arkruntime/types/session/agent_ref.py +31 -0
- arkruntime/types/session/base64_document_source.py +27 -0
- arkruntime/types/session/base64_image_source.py +27 -0
- arkruntime/types/session/cache_creation.py +26 -0
- arkruntime/types/session/create_session_request.py +50 -0
- arkruntime/types/session/create_session_resource_request.py +29 -0
- arkruntime/types/session/delete_session_response.py +24 -0
- arkruntime/types/session/document_source.py +34 -0
- arkruntime/types/session/file_document_source.py +23 -0
- arkruntime/types/session/file_image_source.py +23 -0
- arkruntime/types/session/image_source.py +28 -0
- arkruntime/types/session/list_session_events_response_wire.py +31 -0
- arkruntime/types/session/list_session_resources_response.py +24 -0
- arkruntime/types/session/list_session_threads_response.py +28 -0
- arkruntime/types/session/list_sessions_order.py +18 -0
- arkruntime/types/session/list_sessions_response.py +28 -0
- arkruntime/types/session/managed_agents_agent_message_preview.py +27 -0
- arkruntime/types/session/managed_agents_agent_thinking_preview.py +27 -0
- arkruntime/types/session/managed_agents_delta_content.py +34 -0
- arkruntime/types/session/managed_agents_delta_event.py +34 -0
- arkruntime/types/session/managed_agents_delta_text_block.py +27 -0
- arkruntime/types/session/managed_agents_document_block.py +33 -0
- arkruntime/types/session/managed_agents_event_params.py +57 -0
- arkruntime/types/session/managed_agents_file_rubric_params.py +23 -0
- arkruntime/types/session/managed_agents_image_block.py +25 -0
- arkruntime/types/session/managed_agents_message_content_block.py +30 -0
- arkruntime/types/session/managed_agents_rubric.py +26 -0
- arkruntime/types/session/managed_agents_search_result_block.py +38 -0
- arkruntime/types/session/managed_agents_session_event.py +34 -0
- arkruntime/types/session/managed_agents_start_event.py +31 -0
- arkruntime/types/session/managed_agents_start_event_preview.py +27 -0
- arkruntime/types/session/managed_agents_stream_preview_event.py +26 -0
- arkruntime/types/session/managed_agents_system_content_block.py +23 -0
- arkruntime/types/session/managed_agents_system_message_event_params.py +34 -0
- arkruntime/types/session/managed_agents_text_block.py +23 -0
- arkruntime/types/session/managed_agents_text_rubric_params.py +23 -0
- arkruntime/types/session/managed_agents_tool_result_content_block.py +34 -0
- arkruntime/types/session/managed_agents_user_custom_tool_result_event_params.py +44 -0
- arkruntime/types/session/managed_agents_user_define_outcome_event_params.py +45 -0
- arkruntime/types/session/managed_agents_user_interrupt_event_params.py +31 -0
- arkruntime/types/session/managed_agents_user_message_event_params.py +34 -0
- arkruntime/types/session/managed_agents_user_tool_confirmation_event_params.py +46 -0
- arkruntime/types/session/managed_agents_user_tool_result_event_params.py +44 -0
- arkruntime/types/session/plain_text_document_source.py +27 -0
- arkruntime/types/session/search_result_citations.py +20 -0
- arkruntime/types/session/search_result_content.py +20 -0
- arkruntime/types/session/send_session_events_request.py +24 -0
- arkruntime/types/session/send_session_events_response.py +22 -0
- arkruntime/types/session/session.py +80 -0
- arkruntime/types/session/session_resource.py +70 -0
- arkruntime/types/session/session_resource_access.py +18 -0
- arkruntime/types/session/session_resource_type.py +19 -0
- arkruntime/types/session/session_status.py +20 -0
- arkruntime/types/session/session_stream_shim.py +540 -0
- arkruntime/types/session/session_thread.py +56 -0
- arkruntime/types/session/session_thread_status.py +20 -0
- arkruntime/types/session/session_usage.py +36 -0
- arkruntime/types/session/tag.py +26 -0
- arkruntime/types/session/tool_confirmation_result.py +18 -0
- arkruntime/types/session/update_session_request.py +28 -0
- arkruntime/types/session/url_document_source.py +23 -0
- arkruntime/types/session/url_image_source.py +23 -0
- arkruntime/types/skill/__init__.py +18 -0
- arkruntime/types/skill/_init_extras_shim.py +12 -0
- arkruntime/types/skill/create_skill_request.py +18 -0
- arkruntime/types/skill/skill.py +46 -0
- arkruntime/types/tokenization/__init__.py +24 -0
- arkruntime/types/tokenization/_init_extras_shim.py +12 -0
- arkruntime/types/tokenization/tokenization_input.py +17 -0
- arkruntime/types/tokenization/tokenization_input_param.py +15 -0
- arkruntime/types/tokenization/tokenization_item.py +39 -0
- arkruntime/types/tokenization/tokenization_request.py +30 -0
- arkruntime/types/tokenization/tokenization_request_param.py +30 -0
- arkruntime/types/tokenization/tokenization_response.py +36 -0
- arkruntime/types/vault/__init__.py +62 -0
- arkruntime/types/vault/_init_extras_shim.py +12 -0
- arkruntime/types/vault/create_credential_request.py +32 -0
- arkruntime/types/vault/create_vault_request.py +26 -0
- arkruntime/types/vault/credential.py +52 -0
- arkruntime/types/vault/credential_auth.py +64 -0
- arkruntime/types/vault/credential_auth_type.py +22 -0
- arkruntime/types/vault/credential_networking.py +29 -0
- arkruntime/types/vault/credential_networking_type.py +18 -0
- arkruntime/types/vault/credential_validation.py +54 -0
- arkruntime/types/vault/delete_credential_response.py +26 -0
- arkruntime/types/vault/delete_vault_response.py +26 -0
- arkruntime/types/vault/limited_credential_networking.py +22 -0
- arkruntime/types/vault/list_credentials_response.py +35 -0
- arkruntime/types/vault/list_vaults_response.py +32 -0
- arkruntime/types/vault/mcp_probe.py +26 -0
- arkruntime/types/vault/mcpo_auth_refresh.py +45 -0
- arkruntime/types/vault/refresh_http_response.py +32 -0
- arkruntime/types/vault/refresh_object.py +27 -0
- arkruntime/types/vault/refresh_status.py +20 -0
- arkruntime/types/vault/token_endpoint_auth.py +29 -0
- arkruntime/types/vault/token_endpoint_auth_type.py +19 -0
- arkruntime/types/vault/update_credential_request.py +35 -0
- arkruntime/types/vault/update_vault_request.py +27 -0
- arkruntime/types/vault/validation_status.py +19 -0
- arkruntime/types/vault/vault.py +42 -0
- arkruntime-0.1.0.dist-info/METADATA +347 -0
- arkruntime-0.1.0.dist-info/RECORD +714 -0
- arkruntime-0.1.0.dist-info/WHEEL +5 -0
- arkruntime-0.1.0.dist-info/licenses/LICENSE +201 -0
- arkruntime-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import Any, AsyncIterator, Dict, Iterator, List, Union
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
from ..._base_client import make_request_options
|
|
9
|
+
from ..._constants import CLIENT_REQUEST_HEADER
|
|
10
|
+
from ..._managed_agents_serialize import dump_body
|
|
11
|
+
from ..._resource import AsyncAPIResource, SyncAPIResource
|
|
12
|
+
from ..._types import NOT_GIVEN, NotGiven
|
|
13
|
+
from ...types.session.managed_agents_event_params import ManagedAgentsEventParams
|
|
14
|
+
from ...types.session.send_session_events_response import SendSessionEventsResponse
|
|
15
|
+
from ...types.session.session_stream_shim import (
|
|
16
|
+
ListSessionEventsResponse,
|
|
17
|
+
SessionStreamEvent,
|
|
18
|
+
decode_session_event,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = ["SessionEvents", "AsyncSessionEvents"]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _raise_for_stream_status(resource: Any, resp: httpx.Response) -> None:
|
|
25
|
+
"""Translate a non-2xx SSE-open response into an ``ArkAPIStatusError``.
|
|
26
|
+
|
|
27
|
+
The stream methods run their HTTP GET outside the base client's
|
|
28
|
+
``_request()`` path (so we get access to the raw response body as an
|
|
29
|
+
SSE line iterator), which means ``resp.raise_for_status()`` would leak
|
|
30
|
+
an ``httpx.HTTPStatusError`` to callers — inconsistent with every
|
|
31
|
+
other SDK method that maps 404/401/etc. onto typed
|
|
32
|
+
``ArkNotFoundError``/``ArkAuthenticationError`` etc. This helper mirrors
|
|
33
|
+
the base client's own error path so a caller catching ``ArkAPIError``
|
|
34
|
+
covers streams too.
|
|
35
|
+
"""
|
|
36
|
+
if resp.status_code < 400:
|
|
37
|
+
return
|
|
38
|
+
# Reading the body is safe here — httpx has already headers-only'd this
|
|
39
|
+
# response, and the SSE stream we intended never began, so nothing else
|
|
40
|
+
# will consume it.
|
|
41
|
+
if not resp.is_closed:
|
|
42
|
+
resp.read()
|
|
43
|
+
request_id = resp.headers.get(CLIENT_REQUEST_HEADER, "")
|
|
44
|
+
raise resource._client._make_status_error_from_response(resp, request_id=request_id) from None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
async def _araise_for_stream_status(resource: Any, resp: httpx.Response) -> None:
|
|
48
|
+
"""Async variant of :func:`_raise_for_stream_status` — same contract,
|
|
49
|
+
only differs in how the response body is drained.
|
|
50
|
+
"""
|
|
51
|
+
if resp.status_code < 400:
|
|
52
|
+
return
|
|
53
|
+
if not resp.is_closed:
|
|
54
|
+
await resp.aread()
|
|
55
|
+
request_id = resp.headers.get(CLIENT_REQUEST_HEADER, "")
|
|
56
|
+
raise resource._client._make_status_error_from_response(resp, request_id=request_id) from None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _peek_event_type(event_name: str, data: str) -> str:
|
|
60
|
+
"""Resolve the effective SSE event type.
|
|
61
|
+
|
|
62
|
+
The ark-managed-agents stream emits data-only frames (no explicit
|
|
63
|
+
``event:`` line); the type lives inside the JSON payload under the
|
|
64
|
+
top-level ``type`` field. Prefer the explicit ``event:`` when
|
|
65
|
+
present, otherwise peek the JSON. Non-JSON or type-less payloads
|
|
66
|
+
fall through with an empty string.
|
|
67
|
+
"""
|
|
68
|
+
if event_name:
|
|
69
|
+
return event_name
|
|
70
|
+
if not data or not data.startswith("{"):
|
|
71
|
+
return ""
|
|
72
|
+
try:
|
|
73
|
+
obj = json.loads(data)
|
|
74
|
+
except ValueError:
|
|
75
|
+
return ""
|
|
76
|
+
return obj.get("type", "") or "" if isinstance(obj, dict) else ""
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _decode_stream_frame(event_name: str, data: str) -> SessionStreamEvent:
|
|
80
|
+
"""Build a SessionStreamEvent from a decoded SSE frame. Runs the
|
|
81
|
+
payload through :func:`decode_session_event` so ``.data`` is a
|
|
82
|
+
concrete typed variant (``ManagedAgentsAgentMessageEvent`` /
|
|
83
|
+
``ManagedAgentsSpanOutcomeEvaluationEndEvent`` / …), not a raw dict.
|
|
84
|
+
Empty or non-JSON payloads become
|
|
85
|
+
:class:`ManagedAgentsUnknownSessionEvent` so callers can filter by
|
|
86
|
+
``event.type`` without special-casing malformed frames.
|
|
87
|
+
"""
|
|
88
|
+
typ = _peek_event_type(event_name, data)
|
|
89
|
+
typed = decode_session_event(data if data else "")
|
|
90
|
+
if not typ and getattr(typed, "type", ""):
|
|
91
|
+
typ = typed.type
|
|
92
|
+
return SessionStreamEvent(type=typ, data=typed)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _list_events_query(
|
|
96
|
+
*,
|
|
97
|
+
created_at_gt: Union[str, NotGiven] = NOT_GIVEN,
|
|
98
|
+
created_at_gte: Union[str, NotGiven] = NOT_GIVEN,
|
|
99
|
+
created_at_lt: Union[str, NotGiven] = NOT_GIVEN,
|
|
100
|
+
created_at_lte: Union[str, NotGiven] = NOT_GIVEN,
|
|
101
|
+
limit: Union[int, NotGiven] = NOT_GIVEN,
|
|
102
|
+
order: Union[str, NotGiven] = NOT_GIVEN,
|
|
103
|
+
page: Union[str, NotGiven] = NOT_GIVEN,
|
|
104
|
+
types: Union[List[str], NotGiven] = NOT_GIVEN,
|
|
105
|
+
) -> Dict[str, Any]:
|
|
106
|
+
"""Assemble the query dict for List Session Events / List Thread Events.
|
|
107
|
+
|
|
108
|
+
Field names & wire tags mirror the thrift IDL:
|
|
109
|
+
- created_at[gt|gte|lt|lte] — RFC 3339 window bounds
|
|
110
|
+
- limit / page / order / types — pagination + filter
|
|
111
|
+
"""
|
|
112
|
+
q: Dict[str, Any] = {}
|
|
113
|
+
if not isinstance(created_at_gt, NotGiven):
|
|
114
|
+
q["created_at[gt]"] = created_at_gt
|
|
115
|
+
if not isinstance(created_at_gte, NotGiven):
|
|
116
|
+
q["created_at[gte]"] = created_at_gte
|
|
117
|
+
if not isinstance(created_at_lt, NotGiven):
|
|
118
|
+
q["created_at[lt]"] = created_at_lt
|
|
119
|
+
if not isinstance(created_at_lte, NotGiven):
|
|
120
|
+
q["created_at[lte]"] = created_at_lte
|
|
121
|
+
if not isinstance(limit, NotGiven):
|
|
122
|
+
q["limit"] = limit
|
|
123
|
+
if not isinstance(order, NotGiven):
|
|
124
|
+
q["order"] = order
|
|
125
|
+
if not isinstance(page, NotGiven):
|
|
126
|
+
q["page"] = page
|
|
127
|
+
if not isinstance(types, NotGiven):
|
|
128
|
+
q["types"] = types
|
|
129
|
+
return q
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class SessionEvents(SyncAPIResource):
|
|
133
|
+
def send(
|
|
134
|
+
self,
|
|
135
|
+
session_id: str,
|
|
136
|
+
*,
|
|
137
|
+
events: List[ManagedAgentsEventParams],
|
|
138
|
+
extra_headers=None,
|
|
139
|
+
extra_query=None,
|
|
140
|
+
extra_body=None,
|
|
141
|
+
timeout=None,
|
|
142
|
+
) -> SendSessionEventsResponse:
|
|
143
|
+
if not session_id:
|
|
144
|
+
raise ValueError("session_id is required")
|
|
145
|
+
return self._post(
|
|
146
|
+
f"/sessions/{session_id}/events",
|
|
147
|
+
body=dump_body({"events": events}),
|
|
148
|
+
options=make_request_options(
|
|
149
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
150
|
+
),
|
|
151
|
+
cast_to=SendSessionEventsResponse,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
def list(
|
|
155
|
+
self,
|
|
156
|
+
session_id: str,
|
|
157
|
+
*,
|
|
158
|
+
created_at_gt: Union[str, NotGiven] = NOT_GIVEN,
|
|
159
|
+
created_at_gte: Union[str, NotGiven] = NOT_GIVEN,
|
|
160
|
+
created_at_lt: Union[str, NotGiven] = NOT_GIVEN,
|
|
161
|
+
created_at_lte: Union[str, NotGiven] = NOT_GIVEN,
|
|
162
|
+
limit: Union[int, NotGiven] = NOT_GIVEN,
|
|
163
|
+
order: Union[str, NotGiven] = NOT_GIVEN,
|
|
164
|
+
page: Union[str, NotGiven] = NOT_GIVEN,
|
|
165
|
+
types: Union[List[str], NotGiven] = NOT_GIVEN,
|
|
166
|
+
extra_headers=None,
|
|
167
|
+
extra_query=None,
|
|
168
|
+
extra_body=None,
|
|
169
|
+
timeout=None,
|
|
170
|
+
) -> ListSessionEventsResponse:
|
|
171
|
+
"""List historical session events. Returns a
|
|
172
|
+
:class:`ListSessionEventsResponse` whose ``.events`` list holds
|
|
173
|
+
concrete ``ManagedAgents*Event`` instances (dispatched from the
|
|
174
|
+
wire ``type`` discriminator via :func:`decode_session_event`)."""
|
|
175
|
+
if not session_id:
|
|
176
|
+
raise ValueError("session_id is required")
|
|
177
|
+
query = _list_events_query(
|
|
178
|
+
created_at_gt=created_at_gt,
|
|
179
|
+
created_at_gte=created_at_gte,
|
|
180
|
+
created_at_lt=created_at_lt,
|
|
181
|
+
created_at_lte=created_at_lte,
|
|
182
|
+
limit=limit,
|
|
183
|
+
order=order,
|
|
184
|
+
page=page,
|
|
185
|
+
types=types,
|
|
186
|
+
)
|
|
187
|
+
merged_query: Dict[str, Any] = {**query, **(extra_query or {})}
|
|
188
|
+
return self._get(
|
|
189
|
+
f"/sessions/{session_id}/events",
|
|
190
|
+
options=make_request_options(
|
|
191
|
+
extra_headers=extra_headers, extra_query=merged_query, extra_body=extra_body, timeout=timeout
|
|
192
|
+
),
|
|
193
|
+
cast_to=ListSessionEventsResponse,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
def stream(
|
|
197
|
+
self,
|
|
198
|
+
session_id: str,
|
|
199
|
+
*,
|
|
200
|
+
timeout: Union[float, None] = None,
|
|
201
|
+
) -> Iterator[SessionStreamEvent]:
|
|
202
|
+
"""Open the session's SSE event stream. Yields
|
|
203
|
+
:class:`SessionStreamEvent` for each frame — ``event.type`` gives
|
|
204
|
+
the wire event type (``agent.message`` / ``session.status_idle`` / …)
|
|
205
|
+
and ``event.data`` is a concrete ``ManagedAgents*Event`` instance
|
|
206
|
+
(dispatched via :func:`decode_session_event`). Caller iterates the
|
|
207
|
+
returned generator; the underlying HTTP connection closes when
|
|
208
|
+
the generator is exhausted or GC'd.
|
|
209
|
+
"""
|
|
210
|
+
if not session_id:
|
|
211
|
+
raise ValueError("session_id is required")
|
|
212
|
+
client = self._client._client # httpx.Client
|
|
213
|
+
base = str(self._client._base_url).rstrip("/")
|
|
214
|
+
url = f"{base}/sessions/{session_id}/events/stream"
|
|
215
|
+
headers = {"Accept": "text/event-stream", **(self._client.auth_headers or {})}
|
|
216
|
+
with client.stream("GET", url, headers=headers, timeout=timeout) as resp:
|
|
217
|
+
_raise_for_stream_status(self, resp)
|
|
218
|
+
event_name = ""
|
|
219
|
+
data_buf: List[str] = []
|
|
220
|
+
for raw_line in resp.iter_lines():
|
|
221
|
+
if raw_line is None:
|
|
222
|
+
continue
|
|
223
|
+
line = raw_line if isinstance(raw_line, str) else raw_line.decode("utf-8")
|
|
224
|
+
if line == "":
|
|
225
|
+
if data_buf:
|
|
226
|
+
yield _decode_stream_frame(event_name, "\n".join(data_buf))
|
|
227
|
+
event_name = ""
|
|
228
|
+
data_buf = []
|
|
229
|
+
continue
|
|
230
|
+
if line.startswith(":"):
|
|
231
|
+
continue
|
|
232
|
+
name, _, value = line.partition(":")
|
|
233
|
+
if value.startswith(" "):
|
|
234
|
+
value = value[1:]
|
|
235
|
+
if name == "event":
|
|
236
|
+
event_name = value
|
|
237
|
+
elif name == "data":
|
|
238
|
+
data_buf.append(value)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
class AsyncSessionEvents(AsyncAPIResource):
|
|
242
|
+
async def send(
|
|
243
|
+
self,
|
|
244
|
+
session_id: str,
|
|
245
|
+
*,
|
|
246
|
+
events: List[ManagedAgentsEventParams],
|
|
247
|
+
extra_headers=None,
|
|
248
|
+
extra_query=None,
|
|
249
|
+
extra_body=None,
|
|
250
|
+
timeout=None,
|
|
251
|
+
) -> SendSessionEventsResponse:
|
|
252
|
+
if not session_id:
|
|
253
|
+
raise ValueError("session_id is required")
|
|
254
|
+
return await self._post(
|
|
255
|
+
f"/sessions/{session_id}/events",
|
|
256
|
+
body=dump_body({"events": events}),
|
|
257
|
+
options=make_request_options(
|
|
258
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
259
|
+
),
|
|
260
|
+
cast_to=SendSessionEventsResponse,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
async def list(
|
|
264
|
+
self,
|
|
265
|
+
session_id: str,
|
|
266
|
+
*,
|
|
267
|
+
created_at_gt: Union[str, NotGiven] = NOT_GIVEN,
|
|
268
|
+
created_at_gte: Union[str, NotGiven] = NOT_GIVEN,
|
|
269
|
+
created_at_lt: Union[str, NotGiven] = NOT_GIVEN,
|
|
270
|
+
created_at_lte: Union[str, NotGiven] = NOT_GIVEN,
|
|
271
|
+
limit: Union[int, NotGiven] = NOT_GIVEN,
|
|
272
|
+
order: Union[str, NotGiven] = NOT_GIVEN,
|
|
273
|
+
page: Union[str, NotGiven] = NOT_GIVEN,
|
|
274
|
+
types: Union[List[str], NotGiven] = NOT_GIVEN,
|
|
275
|
+
extra_headers=None,
|
|
276
|
+
extra_query=None,
|
|
277
|
+
extra_body=None,
|
|
278
|
+
timeout=None,
|
|
279
|
+
) -> ListSessionEventsResponse:
|
|
280
|
+
"""Async variant of list()."""
|
|
281
|
+
if not session_id:
|
|
282
|
+
raise ValueError("session_id is required")
|
|
283
|
+
query = _list_events_query(
|
|
284
|
+
created_at_gt=created_at_gt,
|
|
285
|
+
created_at_gte=created_at_gte,
|
|
286
|
+
created_at_lt=created_at_lt,
|
|
287
|
+
created_at_lte=created_at_lte,
|
|
288
|
+
limit=limit,
|
|
289
|
+
order=order,
|
|
290
|
+
page=page,
|
|
291
|
+
types=types,
|
|
292
|
+
)
|
|
293
|
+
merged_query: Dict[str, Any] = {**query, **(extra_query or {})}
|
|
294
|
+
return await self._get(
|
|
295
|
+
f"/sessions/{session_id}/events",
|
|
296
|
+
options=make_request_options(
|
|
297
|
+
extra_headers=extra_headers, extra_query=merged_query, extra_body=extra_body, timeout=timeout
|
|
298
|
+
),
|
|
299
|
+
cast_to=ListSessionEventsResponse,
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
async def stream(
|
|
303
|
+
self,
|
|
304
|
+
session_id: str,
|
|
305
|
+
*,
|
|
306
|
+
timeout: Union[float, None] = None,
|
|
307
|
+
) -> AsyncIterator[SessionStreamEvent]:
|
|
308
|
+
"""Async variant of :meth:`SessionEvents.stream`. Yields
|
|
309
|
+
:class:`SessionStreamEvent` for each SSE frame."""
|
|
310
|
+
if not session_id:
|
|
311
|
+
raise ValueError("session_id is required")
|
|
312
|
+
client = self._client._client # httpx.AsyncClient
|
|
313
|
+
base = str(self._client._base_url).rstrip("/")
|
|
314
|
+
url = f"{base}/sessions/{session_id}/events/stream"
|
|
315
|
+
headers = {"Accept": "text/event-stream", **(self._client.auth_headers or {})}
|
|
316
|
+
async with client.stream("GET", url, headers=headers, timeout=timeout) as resp:
|
|
317
|
+
await _araise_for_stream_status(self, resp)
|
|
318
|
+
event_name = ""
|
|
319
|
+
data_buf: List[str] = []
|
|
320
|
+
async for raw_line in resp.aiter_lines():
|
|
321
|
+
line = raw_line
|
|
322
|
+
if line == "":
|
|
323
|
+
if data_buf:
|
|
324
|
+
yield _decode_stream_frame(event_name, "\n".join(data_buf))
|
|
325
|
+
event_name = ""
|
|
326
|
+
data_buf = []
|
|
327
|
+
continue
|
|
328
|
+
if line.startswith(":"):
|
|
329
|
+
continue
|
|
330
|
+
name, _, value = line.partition(":")
|
|
331
|
+
if value.startswith(" "):
|
|
332
|
+
value = value[1:]
|
|
333
|
+
if name == "event":
|
|
334
|
+
event_name = value
|
|
335
|
+
elif name == "data":
|
|
336
|
+
data_buf.append(value)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from ..._base_client import make_request_options
|
|
4
|
+
from ..._managed_agents_serialize import dump_body
|
|
5
|
+
from ..._resource import AsyncAPIResource, SyncAPIResource
|
|
6
|
+
from ...types.session.list_session_resources_response import (
|
|
7
|
+
ListSessionResourcesResponse,
|
|
8
|
+
)
|
|
9
|
+
from ...types.session.session_resource import SessionResource
|
|
10
|
+
|
|
11
|
+
__all__ = ["SessionResources", "AsyncSessionResources"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _prefix(session_id: str) -> str:
|
|
15
|
+
return f"/sessions/{session_id}/resources"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class SessionResources(SyncAPIResource):
|
|
19
|
+
def create(
|
|
20
|
+
self,
|
|
21
|
+
session_id: str,
|
|
22
|
+
*,
|
|
23
|
+
file_id: str,
|
|
24
|
+
type: str = "file",
|
|
25
|
+
extra_headers=None,
|
|
26
|
+
extra_query=None,
|
|
27
|
+
extra_body=None,
|
|
28
|
+
timeout=None,
|
|
29
|
+
) -> SessionResource:
|
|
30
|
+
if not session_id:
|
|
31
|
+
raise ValueError("session_id is required")
|
|
32
|
+
return self._post(
|
|
33
|
+
_prefix(session_id),
|
|
34
|
+
body=dump_body({"file_id": file_id, "type": type}),
|
|
35
|
+
options=make_request_options(
|
|
36
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
37
|
+
),
|
|
38
|
+
cast_to=SessionResource,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
def list(
|
|
42
|
+
self, session_id: str, *, extra_headers=None, extra_query=None, extra_body=None, timeout=None
|
|
43
|
+
) -> ListSessionResourcesResponse:
|
|
44
|
+
if not session_id:
|
|
45
|
+
raise ValueError("session_id is required")
|
|
46
|
+
return self._get(
|
|
47
|
+
_prefix(session_id),
|
|
48
|
+
options=make_request_options(
|
|
49
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
50
|
+
),
|
|
51
|
+
cast_to=ListSessionResourcesResponse,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class AsyncSessionResources(AsyncAPIResource):
|
|
56
|
+
async def create(
|
|
57
|
+
self,
|
|
58
|
+
session_id: str,
|
|
59
|
+
*,
|
|
60
|
+
file_id: str,
|
|
61
|
+
type: str = "file",
|
|
62
|
+
extra_headers=None,
|
|
63
|
+
extra_query=None,
|
|
64
|
+
extra_body=None,
|
|
65
|
+
timeout=None,
|
|
66
|
+
) -> SessionResource:
|
|
67
|
+
if not session_id:
|
|
68
|
+
raise ValueError("session_id is required")
|
|
69
|
+
return await self._post(
|
|
70
|
+
_prefix(session_id),
|
|
71
|
+
body=dump_body({"file_id": file_id, "type": type}),
|
|
72
|
+
options=make_request_options(
|
|
73
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
74
|
+
),
|
|
75
|
+
cast_to=SessionResource,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
async def list(
|
|
79
|
+
self, session_id: str, *, extra_headers=None, extra_query=None, extra_body=None, timeout=None
|
|
80
|
+
) -> ListSessionResourcesResponse:
|
|
81
|
+
if not session_id:
|
|
82
|
+
raise ValueError("session_id is required")
|
|
83
|
+
return await self._get(
|
|
84
|
+
_prefix(session_id),
|
|
85
|
+
options=make_request_options(
|
|
86
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
87
|
+
),
|
|
88
|
+
cast_to=ListSessionResourcesResponse,
|
|
89
|
+
)
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, AsyncIterator, Dict, Iterator, List, Union
|
|
4
|
+
|
|
5
|
+
from ..._base_client import make_request_options
|
|
6
|
+
from ..._resource import AsyncAPIResource, SyncAPIResource
|
|
7
|
+
from ..._types import NOT_GIVEN, NotGiven
|
|
8
|
+
from ...types.session.list_session_threads_response import ListSessionThreadsResponse
|
|
9
|
+
from ...types.session.session_stream_shim import (
|
|
10
|
+
ListSessionEventsResponse,
|
|
11
|
+
SessionStreamEvent,
|
|
12
|
+
)
|
|
13
|
+
from ...types.session.session_thread import SessionThread
|
|
14
|
+
from .session_events import (
|
|
15
|
+
_araise_for_stream_status,
|
|
16
|
+
_decode_stream_frame,
|
|
17
|
+
_list_events_query,
|
|
18
|
+
_raise_for_stream_status,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = ["SessionThreads", "AsyncSessionThreads"]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _list_threads_query(
|
|
25
|
+
*,
|
|
26
|
+
limit: Union[int, NotGiven] = NOT_GIVEN,
|
|
27
|
+
page: Union[str, NotGiven] = NOT_GIVEN,
|
|
28
|
+
) -> Dict[str, Any]:
|
|
29
|
+
q: Dict[str, Any] = {}
|
|
30
|
+
if not isinstance(limit, NotGiven):
|
|
31
|
+
q["limit"] = limit
|
|
32
|
+
if not isinstance(page, NotGiven):
|
|
33
|
+
q["page"] = page
|
|
34
|
+
return q
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class SessionThreads(SyncAPIResource):
|
|
38
|
+
"""Thread endpoints under a session.
|
|
39
|
+
|
|
40
|
+
The primary thread is materialized lazily on the first event — send at
|
|
41
|
+
least one user.message + wait for session.status_idle before expecting
|
|
42
|
+
``list()`` to return a non-empty page.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def list(
|
|
46
|
+
self,
|
|
47
|
+
session_id: str,
|
|
48
|
+
*,
|
|
49
|
+
limit: Union[int, NotGiven] = NOT_GIVEN,
|
|
50
|
+
page: Union[str, NotGiven] = NOT_GIVEN,
|
|
51
|
+
extra_headers=None,
|
|
52
|
+
extra_query=None,
|
|
53
|
+
extra_body=None,
|
|
54
|
+
timeout=None,
|
|
55
|
+
) -> ListSessionThreadsResponse:
|
|
56
|
+
if not session_id:
|
|
57
|
+
raise ValueError("session_id is required")
|
|
58
|
+
merged_query: Dict[str, Any] = {**_list_threads_query(limit=limit, page=page), **(extra_query or {})}
|
|
59
|
+
return self._get(
|
|
60
|
+
f"/sessions/{session_id}/threads",
|
|
61
|
+
options=make_request_options(
|
|
62
|
+
extra_headers=extra_headers, extra_query=merged_query, extra_body=extra_body, timeout=timeout
|
|
63
|
+
),
|
|
64
|
+
cast_to=ListSessionThreadsResponse,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
def retrieve(
|
|
68
|
+
self, session_id: str, thread_id: str, *, extra_headers=None, extra_query=None, extra_body=None, timeout=None
|
|
69
|
+
) -> SessionThread:
|
|
70
|
+
if not session_id:
|
|
71
|
+
raise ValueError("session_id is required")
|
|
72
|
+
if not thread_id:
|
|
73
|
+
raise ValueError("thread_id is required")
|
|
74
|
+
return self._get(
|
|
75
|
+
f"/sessions/{session_id}/threads/{thread_id}",
|
|
76
|
+
options=make_request_options(
|
|
77
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
78
|
+
),
|
|
79
|
+
cast_to=SessionThread,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
def list_events(
|
|
83
|
+
self,
|
|
84
|
+
session_id: str,
|
|
85
|
+
thread_id: str,
|
|
86
|
+
*,
|
|
87
|
+
created_at_gt: Union[str, NotGiven] = NOT_GIVEN,
|
|
88
|
+
created_at_gte: Union[str, NotGiven] = NOT_GIVEN,
|
|
89
|
+
created_at_lt: Union[str, NotGiven] = NOT_GIVEN,
|
|
90
|
+
created_at_lte: Union[str, NotGiven] = NOT_GIVEN,
|
|
91
|
+
limit: Union[int, NotGiven] = NOT_GIVEN,
|
|
92
|
+
order: Union[str, NotGiven] = NOT_GIVEN,
|
|
93
|
+
page: Union[str, NotGiven] = NOT_GIVEN,
|
|
94
|
+
types: Union[List[str], NotGiven] = NOT_GIVEN,
|
|
95
|
+
extra_headers=None,
|
|
96
|
+
extra_query=None,
|
|
97
|
+
extra_body=None,
|
|
98
|
+
timeout=None,
|
|
99
|
+
) -> ListSessionEventsResponse:
|
|
100
|
+
if not session_id:
|
|
101
|
+
raise ValueError("session_id is required")
|
|
102
|
+
if not thread_id:
|
|
103
|
+
raise ValueError("thread_id is required")
|
|
104
|
+
query = _list_events_query(
|
|
105
|
+
created_at_gt=created_at_gt,
|
|
106
|
+
created_at_gte=created_at_gte,
|
|
107
|
+
created_at_lt=created_at_lt,
|
|
108
|
+
created_at_lte=created_at_lte,
|
|
109
|
+
limit=limit,
|
|
110
|
+
order=order,
|
|
111
|
+
page=page,
|
|
112
|
+
types=types,
|
|
113
|
+
)
|
|
114
|
+
merged_query: Dict[str, Any] = {**query, **(extra_query or {})}
|
|
115
|
+
return self._get(
|
|
116
|
+
f"/sessions/{session_id}/threads/{thread_id}/events",
|
|
117
|
+
options=make_request_options(
|
|
118
|
+
extra_headers=extra_headers, extra_query=merged_query, extra_body=extra_body, timeout=timeout
|
|
119
|
+
),
|
|
120
|
+
cast_to=ListSessionEventsResponse,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
def stream(
|
|
124
|
+
self, session_id: str, thread_id: str, *, timeout: Union[float, None] = None
|
|
125
|
+
) -> Iterator[SessionStreamEvent]:
|
|
126
|
+
"""SSE stream scoped to one thread. Same shape as
|
|
127
|
+
:meth:`SessionEvents.stream`: yields :class:`SessionStreamEvent`
|
|
128
|
+
for each frame — ``event.type`` gives the wire event type,
|
|
129
|
+
``event.data`` the parsed JSON payload."""
|
|
130
|
+
if not session_id:
|
|
131
|
+
raise ValueError("session_id is required")
|
|
132
|
+
if not thread_id:
|
|
133
|
+
raise ValueError("thread_id is required")
|
|
134
|
+
client = self._client._client
|
|
135
|
+
base = str(self._client._base_url).rstrip("/")
|
|
136
|
+
url = f"{base}/sessions/{session_id}/threads/{thread_id}/stream"
|
|
137
|
+
headers = {"Accept": "text/event-stream", **(self._client.auth_headers or {})}
|
|
138
|
+
with client.stream("GET", url, headers=headers, timeout=timeout) as resp:
|
|
139
|
+
_raise_for_stream_status(self, resp)
|
|
140
|
+
event_name = ""
|
|
141
|
+
data_buf: List[str] = []
|
|
142
|
+
for raw_line in resp.iter_lines():
|
|
143
|
+
if raw_line is None:
|
|
144
|
+
continue
|
|
145
|
+
line = raw_line if isinstance(raw_line, str) else raw_line.decode("utf-8")
|
|
146
|
+
if line == "":
|
|
147
|
+
if data_buf:
|
|
148
|
+
yield _decode_stream_frame(event_name, "\n".join(data_buf))
|
|
149
|
+
event_name = ""
|
|
150
|
+
data_buf = []
|
|
151
|
+
continue
|
|
152
|
+
if line.startswith(":"):
|
|
153
|
+
continue
|
|
154
|
+
name, _, value = line.partition(":")
|
|
155
|
+
if value.startswith(" "):
|
|
156
|
+
value = value[1:]
|
|
157
|
+
if name == "event":
|
|
158
|
+
event_name = value
|
|
159
|
+
elif name == "data":
|
|
160
|
+
data_buf.append(value)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class AsyncSessionThreads(AsyncAPIResource):
|
|
164
|
+
async def list(
|
|
165
|
+
self,
|
|
166
|
+
session_id: str,
|
|
167
|
+
*,
|
|
168
|
+
limit: Union[int, NotGiven] = NOT_GIVEN,
|
|
169
|
+
page: Union[str, NotGiven] = NOT_GIVEN,
|
|
170
|
+
extra_headers=None,
|
|
171
|
+
extra_query=None,
|
|
172
|
+
extra_body=None,
|
|
173
|
+
timeout=None,
|
|
174
|
+
) -> ListSessionThreadsResponse:
|
|
175
|
+
if not session_id:
|
|
176
|
+
raise ValueError("session_id is required")
|
|
177
|
+
merged_query: Dict[str, Any] = {**_list_threads_query(limit=limit, page=page), **(extra_query or {})}
|
|
178
|
+
return await self._get(
|
|
179
|
+
f"/sessions/{session_id}/threads",
|
|
180
|
+
options=make_request_options(
|
|
181
|
+
extra_headers=extra_headers, extra_query=merged_query, extra_body=extra_body, timeout=timeout
|
|
182
|
+
),
|
|
183
|
+
cast_to=ListSessionThreadsResponse,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
async def retrieve(
|
|
187
|
+
self, session_id: str, thread_id: str, *, extra_headers=None, extra_query=None, extra_body=None, timeout=None
|
|
188
|
+
) -> SessionThread:
|
|
189
|
+
if not session_id:
|
|
190
|
+
raise ValueError("session_id is required")
|
|
191
|
+
if not thread_id:
|
|
192
|
+
raise ValueError("thread_id is required")
|
|
193
|
+
return await self._get(
|
|
194
|
+
f"/sessions/{session_id}/threads/{thread_id}",
|
|
195
|
+
options=make_request_options(
|
|
196
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
197
|
+
),
|
|
198
|
+
cast_to=SessionThread,
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
async def list_events(
|
|
202
|
+
self,
|
|
203
|
+
session_id: str,
|
|
204
|
+
thread_id: str,
|
|
205
|
+
*,
|
|
206
|
+
created_at_gt: Union[str, NotGiven] = NOT_GIVEN,
|
|
207
|
+
created_at_gte: Union[str, NotGiven] = NOT_GIVEN,
|
|
208
|
+
created_at_lt: Union[str, NotGiven] = NOT_GIVEN,
|
|
209
|
+
created_at_lte: Union[str, NotGiven] = NOT_GIVEN,
|
|
210
|
+
limit: Union[int, NotGiven] = NOT_GIVEN,
|
|
211
|
+
order: Union[str, NotGiven] = NOT_GIVEN,
|
|
212
|
+
page: Union[str, NotGiven] = NOT_GIVEN,
|
|
213
|
+
types: Union[List[str], NotGiven] = NOT_GIVEN,
|
|
214
|
+
extra_headers=None,
|
|
215
|
+
extra_query=None,
|
|
216
|
+
extra_body=None,
|
|
217
|
+
timeout=None,
|
|
218
|
+
) -> ListSessionEventsResponse:
|
|
219
|
+
if not session_id:
|
|
220
|
+
raise ValueError("session_id is required")
|
|
221
|
+
if not thread_id:
|
|
222
|
+
raise ValueError("thread_id is required")
|
|
223
|
+
query = _list_events_query(
|
|
224
|
+
created_at_gt=created_at_gt,
|
|
225
|
+
created_at_gte=created_at_gte,
|
|
226
|
+
created_at_lt=created_at_lt,
|
|
227
|
+
created_at_lte=created_at_lte,
|
|
228
|
+
limit=limit,
|
|
229
|
+
order=order,
|
|
230
|
+
page=page,
|
|
231
|
+
types=types,
|
|
232
|
+
)
|
|
233
|
+
merged_query: Dict[str, Any] = {**query, **(extra_query or {})}
|
|
234
|
+
return await self._get(
|
|
235
|
+
f"/sessions/{session_id}/threads/{thread_id}/events",
|
|
236
|
+
options=make_request_options(
|
|
237
|
+
extra_headers=extra_headers, extra_query=merged_query, extra_body=extra_body, timeout=timeout
|
|
238
|
+
),
|
|
239
|
+
cast_to=ListSessionEventsResponse,
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
async def stream(
|
|
243
|
+
self, session_id: str, thread_id: str, *, timeout: Union[float, None] = None
|
|
244
|
+
) -> AsyncIterator[SessionStreamEvent]:
|
|
245
|
+
"""Async variant of :meth:`SessionThreads.stream`. Yields
|
|
246
|
+
:class:`SessionStreamEvent` for each frame."""
|
|
247
|
+
if not session_id:
|
|
248
|
+
raise ValueError("session_id is required")
|
|
249
|
+
if not thread_id:
|
|
250
|
+
raise ValueError("thread_id is required")
|
|
251
|
+
client = self._client._client
|
|
252
|
+
base = str(self._client._base_url).rstrip("/")
|
|
253
|
+
url = f"{base}/sessions/{session_id}/threads/{thread_id}/stream"
|
|
254
|
+
headers = {"Accept": "text/event-stream", **(self._client.auth_headers or {})}
|
|
255
|
+
async with client.stream("GET", url, headers=headers, timeout=timeout) as resp:
|
|
256
|
+
await _araise_for_stream_status(self, resp)
|
|
257
|
+
event_name = ""
|
|
258
|
+
data_buf: List[str] = []
|
|
259
|
+
async for raw_line in resp.aiter_lines():
|
|
260
|
+
line = raw_line
|
|
261
|
+
if line == "":
|
|
262
|
+
if data_buf:
|
|
263
|
+
yield _decode_stream_frame(event_name, "\n".join(data_buf))
|
|
264
|
+
event_name = ""
|
|
265
|
+
data_buf = []
|
|
266
|
+
continue
|
|
267
|
+
if line.startswith(":"):
|
|
268
|
+
continue
|
|
269
|
+
name, _, value = line.partition(":")
|
|
270
|
+
if value.startswith(" "):
|
|
271
|
+
value = value[1:]
|
|
272
|
+
if name == "event":
|
|
273
|
+
event_name = value
|
|
274
|
+
elif name == "data":
|
|
275
|
+
data_buf.append(value)
|