e2b 2.60.0__tar.gz → 2.62.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. {e2b-2.60.0 → e2b-2.62.0}/PKG-INFO +1 -1
  2. {e2b-2.60.0 → e2b-2.62.0}/e2b/__init__.py +9 -1
  3. {e2b-2.60.0 → e2b-2.62.0}/e2b/retry.py +19 -0
  4. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/commands/command_handle.py +25 -5
  5. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/filesystem/filesystem.py +228 -23
  6. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/commands/command.py +170 -5
  7. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/commands/command_handle.py +34 -17
  8. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/filesystem/filesystem.py +33 -14
  9. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/main.py +8 -0
  10. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/sandbox_api.py +4 -0
  11. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/commands/command.py +150 -3
  12. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/commands/command_handle.py +25 -14
  13. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/filesystem/filesystem.py +33 -14
  14. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/main.py +8 -0
  15. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/sandbox_api.py +4 -0
  16. {e2b-2.60.0 → e2b-2.62.0}/pyproject.toml +2 -2
  17. {e2b-2.60.0 → e2b-2.62.0}/pyproject.toml.orig +2 -2
  18. {e2b-2.60.0 → e2b-2.62.0}/README.md +0 -0
  19. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/__init__.py +0 -0
  20. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/__init__.py +0 -0
  21. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/__init__.py +0 -0
  22. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/__init__.py +0 -0
  23. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py +0 -0
  24. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_sandboxes.py +0 -0
  25. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_sandboxes_metrics.py +0 -0
  26. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_sandboxes_sandbox_id.py +0 -0
  27. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_sandboxes_sandbox_id_logs.py +0 -0
  28. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py +0 -0
  29. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_v2_sandboxes.py +0 -0
  30. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_v_2_sandboxes_sandbox_id_logs.py +0 -0
  31. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes.py +0 -0
  32. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py +0 -0
  33. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_fork.py +0 -0
  34. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_pause.py +0 -0
  35. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py +0 -0
  36. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_resume.py +0 -0
  37. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_snapshots.py +0 -0
  38. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py +0 -0
  39. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_v2_sandboxes.py +0 -0
  40. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_v_2_sandboxes_sandbox_id_connect.py +0 -0
  41. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/put_sandboxes_sandbox_id_network.py +0 -0
  42. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/__init__.py +0 -0
  43. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/delete_secrets_secret_id.py +0 -0
  44. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/get_secrets.py +0 -0
  45. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/get_secrets_secret_id.py +0 -0
  46. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/post_secrets.py +0 -0
  47. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/post_secrets_secret_id.py +0 -0
  48. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/snapshots/__init__.py +0 -0
  49. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/snapshots/get_snapshots.py +0 -0
  50. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/__init__.py +0 -0
  51. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/delete_templates_tags.py +0 -0
  52. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/get_templates_template_id_tags.py +0 -0
  53. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/get_templates_template_id_tags_count.py +0 -0
  54. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/get_templates_template_id_tags_exists.py +0 -0
  55. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/get_templates_template_id_tags_groups.py +0 -0
  56. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/get_templates_template_id_tags_tag_assignments.py +0 -0
  57. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/post_templates_tags.py +0 -0
  58. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/__init__.py +0 -0
  59. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/delete_templates_template_id.py +0 -0
  60. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_default_templates.py +0 -0
  61. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates.py +0 -0
  62. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates_aliases_alias.py +0 -0
  63. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates_template_id.py +0 -0
  64. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates_template_id_builds_build_id_logs.py +0 -0
  65. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates_template_id_builds_build_id_status.py +0 -0
  66. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates_template_id_files_hash.py +0 -0
  67. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_v2_templates.py +0 -0
  68. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/patch_templates_template_id.py +0 -0
  69. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/patch_v_2_templates_template_id.py +0 -0
  70. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/post_v3_templates.py +0 -0
  71. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/post_v_2_templates_template_id_builds_build_id.py +0 -0
  72. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/volumes/__init__.py +0 -0
  73. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/volumes/delete_volumes_volume_id.py +0 -0
  74. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/volumes/get_volumes.py +0 -0
  75. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/volumes/get_volumes_volume_id.py +0 -0
  76. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/volumes/post_volumes.py +0 -0
  77. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/client.py +0 -0
  78. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/errors.py +0 -0
  79. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/__init__.py +0 -0
  80. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/assign_template_tags_request.py +0 -0
  81. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/assigned_template_tags.py +0 -0
  82. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/aws_registry.py +0 -0
  83. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/aws_registry_type.py +0 -0
  84. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/build_log_entry.py +0 -0
  85. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/build_status_reason.py +0 -0
  86. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/connect_sandbox.py +0 -0
  87. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/connect_sandbox_v2.py +0 -0
  88. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/delete_template_tags_request.py +0 -0
  89. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/error.py +0 -0
  90. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/gcp_registry.py +0 -0
  91. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/gcp_registry_type.py +0 -0
  92. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/general_registry.py +0 -0
  93. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/general_registry_type.py +0 -0
  94. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/get_templates_template_id_tags_groups_sort.py +0 -0
  95. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/listed_sandbox.py +0 -0
  96. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/log_level.py +0 -0
  97. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/logs_direction.py +0 -0
  98. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/logs_source.py +0 -0
  99. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/mcp_type_0.py +0 -0
  100. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/new_sandbox.py +0 -0
  101. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/new_sandbox_v2.py +0 -0
  102. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/new_secret.py +0 -0
  103. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/new_volume.py +0 -0
  104. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/order_direction.py +0 -0
  105. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/resumed_sandbox.py +0 -0
  106. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox.py +0 -0
  107. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_auto_resume_config.py +0 -0
  108. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_detail.py +0 -0
  109. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_egress_proxy_config_type_0.py +0 -0
  110. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_egress_proxy_tls_config_type_0.py +0 -0
  111. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_fork_request.py +0 -0
  112. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_fork_result.py +0 -0
  113. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_iam.py +0 -0
  114. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_iam_token.py +0 -0
  115. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_iam_tokens.py +0 -0
  116. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_lifecycle.py +0 -0
  117. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_log.py +0 -0
  118. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_log_entry.py +0 -0
  119. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_log_entry_fields.py +0 -0
  120. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_logs.py +0 -0
  121. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_logs_v2_response.py +0 -0
  122. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_metric.py +0 -0
  123. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_config.py +0 -0
  124. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_config_rules.py +0 -0
  125. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_rule.py +0 -0
  126. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_transform.py +0 -0
  127. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_transform_headers.py +0 -0
  128. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_update_config.py +0 -0
  129. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_update_config_rules.py +0 -0
  130. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_on_timeout.py +0 -0
  131. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_pause_mode.py +0 -0
  132. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_pause_request.py +0 -0
  133. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_refresh_request.py +0 -0
  134. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_snapshot_request.py +0 -0
  135. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_state.py +0 -0
  136. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_timeout_request.py +0 -0
  137. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_volume_mount.py +0 -0
  138. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandboxes_with_metrics.py +0 -0
  139. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/secret.py +0 -0
  140. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/secret_metadata.py +0 -0
  141. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/secret_update.py +0 -0
  142. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/snapshot_info.py +0 -0
  143. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/team_user.py +0 -0
  144. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template.py +0 -0
  145. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_alias_response.py +0 -0
  146. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build.py +0 -0
  147. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_file_upload.py +0 -0
  148. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_file_upload_headers.py +0 -0
  149. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_info.py +0 -0
  150. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_logs_response.py +0 -0
  151. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_request_v3.py +0 -0
  152. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_start_v2.py +0 -0
  153. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_status.py +0 -0
  154. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_request_response_v3.py +0 -0
  155. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_step.py +0 -0
  156. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag.py +0 -0
  157. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag_assignment.py +0 -0
  158. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag_assignments_response.py +0 -0
  159. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag_exists_response.py +0 -0
  160. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag_group.py +0 -0
  161. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag_groups_response.py +0 -0
  162. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tags_count_response.py +0 -0
  163. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_update_request.py +0 -0
  164. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_update_response.py +0 -0
  165. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_with_builds.py +0 -0
  166. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/volume.py +0 -0
  167. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/volume_and_token.py +0 -0
  168. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/py.typed +0 -0
  169. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/types.py +0 -0
  170. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client_async/__init__.py +0 -0
  171. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client_sync/__init__.py +0 -0
  172. {e2b-2.60.0 → e2b-2.62.0}/e2b/api/metadata.py +0 -0
  173. {e2b-2.60.0 → e2b-2.62.0}/e2b/client.py +0 -0
  174. {e2b-2.60.0 → e2b-2.62.0}/e2b/connection_config.py +0 -0
  175. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/__init__.py +0 -0
  176. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/api.py +0 -0
  177. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/client_async/__init__.py +0 -0
  178. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/client_shared.py +0 -0
  179. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/client_sync/__init__.py +0 -0
  180. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/filesystem/__init__.py +0 -0
  181. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/filesystem/filesystem_connect.py +0 -0
  182. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/filesystem/filesystem_pb.py +0 -0
  183. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/interceptors.py +0 -0
  184. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/process/__init__.py +0 -0
  185. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/process/process_connect.py +0 -0
  186. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/process/process_pb.py +0 -0
  187. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/rpc.py +0 -0
  188. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/utils.py +0 -0
  189. {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/versions.py +0 -0
  190. {e2b-2.60.0 → e2b-2.62.0}/e2b/exceptions.py +0 -0
  191. {e2b-2.60.0 → e2b-2.62.0}/e2b/io_utils.py +0 -0
  192. {e2b-2.60.0 → e2b-2.62.0}/e2b/paginator.py +0 -0
  193. {e2b-2.60.0 → e2b-2.62.0}/e2b/py.typed +0 -0
  194. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/__init__.py +0 -0
  195. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/args.py +0 -0
  196. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/auth.py +0 -0
  197. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/config.py +0 -0
  198. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/parse.py +0 -0
  199. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/types.py +0 -0
  200. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/commands/main.py +0 -0
  201. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/commands/stream_input.py +0 -0
  202. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/filesystem/watch_handle.py +0 -0
  203. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/iam.py +0 -0
  204. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/main.py +0 -0
  205. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/mcp.py +0 -0
  206. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/network.py +0 -0
  207. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/sandbox_api.py +0 -0
  208. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/signature.py +0 -0
  209. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/utils.py +0 -0
  210. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/commands/command_input_handle.py +0 -0
  211. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/commands/pty.py +0 -0
  212. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/filesystem/watch_handle.py +0 -0
  213. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/git.py +0 -0
  214. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/paginator.py +0 -0
  215. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/utils.py +0 -0
  216. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_domains.py +0 -0
  217. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/commands/pty.py +0 -0
  218. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/filesystem/watch_handle.py +0 -0
  219. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/git.py +0 -0
  220. {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/paginator.py +0 -0
  221. {e2b-2.60.0 → e2b-2.62.0}/e2b/secret/__init__.py +0 -0
  222. {e2b-2.60.0 → e2b-2.62.0}/e2b/secret/base.py +0 -0
  223. {e2b-2.60.0 → e2b-2.62.0}/e2b/secret/secret_async.py +0 -0
  224. {e2b-2.60.0 → e2b-2.62.0}/e2b/secret/secret_sync.py +0 -0
  225. {e2b-2.60.0 → e2b-2.62.0}/e2b/secret/types.py +0 -0
  226. {e2b-2.60.0 → e2b-2.62.0}/e2b/template/consts.py +0 -0
  227. {e2b-2.60.0 → e2b-2.62.0}/e2b/template/dockerfile_parser.py +0 -0
  228. {e2b-2.60.0 → e2b-2.62.0}/e2b/template/logger.py +0 -0
  229. {e2b-2.60.0 → e2b-2.62.0}/e2b/template/main.py +0 -0
  230. {e2b-2.60.0 → e2b-2.62.0}/e2b/template/readycmd.py +0 -0
  231. {e2b-2.60.0 → e2b-2.62.0}/e2b/template/types.py +0 -0
  232. {e2b-2.60.0 → e2b-2.62.0}/e2b/template/utils.py +0 -0
  233. {e2b-2.60.0 → e2b-2.62.0}/e2b/template_async/build_api.py +0 -0
  234. {e2b-2.60.0 → e2b-2.62.0}/e2b/template_async/main.py +0 -0
  235. {e2b-2.60.0 → e2b-2.62.0}/e2b/template_sync/build_api.py +0 -0
  236. {e2b-2.60.0 → e2b-2.62.0}/e2b/template_sync/main.py +0 -0
  237. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/__init__.py +0 -0
  238. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/__init__.py +0 -0
  239. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/__init__.py +0 -0
  240. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/delete_volumecontent_volume_id_path.py +0 -0
  241. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/get_volumecontent_volume_id_dir.py +0 -0
  242. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/get_volumecontent_volume_id_file.py +0 -0
  243. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/get_volumecontent_volume_id_path.py +0 -0
  244. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/patch_volumecontent_volume_id_path.py +0 -0
  245. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/post_volumecontent_volume_id_dir.py +0 -0
  246. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/put_volumecontent_volume_id_file.py +0 -0
  247. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/client.py +0 -0
  248. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/errors.py +0 -0
  249. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/models/__init__.py +0 -0
  250. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/models/error.py +0 -0
  251. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/models/patch_volumecontent_volume_id_path_body.py +0 -0
  252. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/models/volume_entry_stat.py +0 -0
  253. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/models/volume_entry_stat_type.py +0 -0
  254. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/py.typed +0 -0
  255. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/types.py +0 -0
  256. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client_async/__init__.py +0 -0
  257. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client_sync/__init__.py +0 -0
  258. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/connection_config.py +0 -0
  259. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/types.py +0 -0
  260. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/utils.py +0 -0
  261. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/volume_async.py +0 -0
  262. {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/volume_sync.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: e2b
3
- Version: 2.60.0
3
+ Version: 2.62.0
4
4
  Summary: E2B SDK that give agents cloud environments
5
5
  Author: e2b
6
6
  Author-email: e2b <hello@e2b.dev>
@@ -70,7 +70,13 @@ from .sandbox.commands.command_handle import (
70
70
  Stdout,
71
71
  )
72
72
  from .sandbox.commands.main import ProcessInfo
73
- from .sandbox.filesystem.filesystem import EntryInfo, FileType, WriteInfo
73
+ from .sandbox.filesystem.filesystem import (
74
+ AsyncWriteData,
75
+ EntryInfo,
76
+ FileType,
77
+ WriteData,
78
+ WriteInfo,
79
+ )
74
80
  from .sandbox.filesystem.watch_handle import (
75
81
  FilesystemEvent,
76
82
  FilesystemEventType,
@@ -231,6 +237,8 @@ __all__ = [
231
237
  "FilesystemEventType",
232
238
  "EntryInfo",
233
239
  "WriteInfo",
240
+ "WriteData",
241
+ "AsyncWriteData",
234
242
  "FileType",
235
243
  # Network
236
244
  "SandboxEgressProxyOpts",
@@ -2,6 +2,7 @@
2
2
 
3
3
  import asyncio
4
4
  import random
5
+ import re
5
6
  import time
6
7
  from typing import Awaitable, Callable, Optional
7
8
 
@@ -25,6 +26,24 @@ def resolve_max_retries(retries: int) -> int:
25
26
  return retries
26
27
 
27
28
 
29
+ def resolve_idempotency_key(key: Optional[str]) -> Optional[str]:
30
+ if key is None:
31
+ return None
32
+ if not isinstance(key, str):
33
+ raise InvalidArgumentException(
34
+ f"Invalid idempotency_key: expected a string, got {type(key).__name__}."
35
+ )
36
+ if len(key) < 1 or len(key) > 255:
37
+ raise InvalidArgumentException(
38
+ f"Invalid idempotency_key: expected 1-255 characters, got {len(key)}."
39
+ )
40
+ if re.fullmatch(r"[a-z0-9-]+", key) is None:
41
+ raise InvalidArgumentException(
42
+ "Invalid idempotency_key: only lowercase letters, digits and hyphens are allowed."
43
+ )
44
+ return key
45
+
46
+
28
47
  def parse_retry_after(value: Optional[str]) -> Optional[int]:
29
48
  if not value:
30
49
  return None
@@ -1,5 +1,7 @@
1
1
  from dataclasses import dataclass
2
- from typing import Optional
2
+ from typing import Generic, List, Optional
3
+
4
+ from typing_extensions import TypeVar
3
5
 
4
6
  from e2b.exceptions import SandboxException
5
7
 
@@ -16,6 +18,18 @@ PtyOutput = bytes
16
18
  Pty output.
17
19
  """
18
20
 
21
+ OutputT = TypeVar("OutputT", bound=Optional[str], default=str)
22
+ """
23
+ Type of the accumulated command output: `None` when the command was started with `retain_output=False`, `str` otherwise.
24
+ """
25
+
26
+
27
+ def join_output(chunks: Optional[List[str]]) -> Optional[str]:
28
+ """
29
+ Join accumulated output chunks, or return `None` when output is not retained.
30
+ """
31
+ return None if chunks is None else "".join(chunks)
32
+
19
33
 
20
34
  @dataclass
21
35
  class PtySize:
@@ -34,18 +48,22 @@ class PtySize:
34
48
 
35
49
 
36
50
  @dataclass
37
- class CommandResult:
51
+ class CommandResult(Generic[OutputT]):
38
52
  """
39
53
  Command execution result.
40
54
  """
41
55
 
42
- stderr: str
56
+ stderr: OutputT
43
57
  """
44
58
  Command stderr output.
59
+
60
+ `None` if the command was started with `retain_output=False`.
45
61
  """
46
- stdout: str
62
+ stdout: OutputT
47
63
  """
48
64
  Command stdout output.
65
+
66
+ `None` if the command was started with `retain_output=False`.
49
67
  """
50
68
  exit_code: int
51
69
  """
@@ -60,10 +78,12 @@ class CommandResult:
60
78
 
61
79
 
62
80
  @dataclass
63
- class CommandExitException(SandboxException, CommandResult):
81
+ class CommandExitException(SandboxException, CommandResult[OutputT]):
64
82
  """
65
83
  Exception raised when a command exits with a non-zero exit code.
66
84
  """
67
85
 
68
86
  def __str__(self):
87
+ if self.stderr is None:
88
+ return f"Command exited with code {self.exit_code}"
69
89
  return f"Command exited with code {self.exit_code} and error:\n{self.stderr}"
@@ -1,18 +1,32 @@
1
1
  import asyncio
2
2
  import gzip
3
+ import inspect
3
4
  import re
4
5
  from dataclasses import dataclass, field
5
6
  from datetime import datetime
6
7
  from enum import Enum
7
8
  from io import IOBase, TextIOBase
8
- from typing import IO, AsyncIterator, Dict, Iterator, List, Optional, Union, TypedDict
9
+ from typing import (
10
+ IO,
11
+ AsyncIterable,
12
+ AsyncIterator,
13
+ Dict,
14
+ Iterable,
15
+ Iterator,
16
+ Optional,
17
+ Sequence,
18
+ TypedDict,
19
+ TypeGuard,
20
+ Union,
21
+ cast,
22
+ )
9
23
 
10
24
  import httpx
11
25
 
12
26
  from protobuf.wkt import Timestamp
13
27
 
14
28
  from e2b.envd.filesystem import filesystem_pb
15
- from e2b.exceptions import InvalidArgumentException
29
+ from e2b.exceptions import InvalidArgumentException, TemplateException
16
30
  from e2b.io_utils import agzip_iter, aiter_io_chunks, gzip_iter, iter_io_chunks
17
31
 
18
32
 
@@ -148,15 +162,53 @@ def map_entry_info(entry: filesystem_pb.EntryInfo) -> EntryInfo:
148
162
  )
149
163
 
150
164
 
165
+ WriteData = Union[str, bytes, IO, Iterable[bytes]]
166
+ """Data accepted by ``Sandbox.files.write``."""
167
+
168
+ AsyncWriteData = Union[str, bytes, IO, AsyncIterable[bytes]]
169
+ """Data accepted by ``AsyncSandbox.files.write``."""
170
+
171
+
151
172
  class WriteEntry(TypedDict):
152
173
  """
153
174
  Contains path and data of the file to be written to the filesystem.
175
+
176
+ ``data`` can be a ``str``, ``bytes`` or a file-like object; such an entry is
177
+ accepted by both ``Sandbox`` and ``AsyncSandbox``. Use :class:`SyncWriteEntry`
178
+ or :class:`AsyncWriteEntry` to stream an iterable of ``bytes`` chunks.
154
179
  """
155
180
 
156
181
  path: str
157
182
  data: Union[str, bytes, IO]
158
183
 
159
184
 
185
+ class SyncWriteEntry(TypedDict):
186
+ """
187
+ Contains path and data of the file to be written to the filesystem by ``Sandbox``.
188
+
189
+ ``data`` can be anything :class:`WriteEntry` accepts, or an iterable of
190
+ ``bytes`` chunks.
191
+ """
192
+
193
+ path: str
194
+ data: WriteData
195
+
196
+
197
+ class AsyncWriteEntry(TypedDict):
198
+ """
199
+ Contains path and data of the file to be written to the filesystem by ``AsyncSandbox``.
200
+
201
+ ``data`` can be anything :class:`WriteEntry` accepts, or an async iterable
202
+ of ``bytes`` chunks.
203
+ """
204
+
205
+ path: str
206
+ data: AsyncWriteData
207
+
208
+
209
+ AnyWriteEntry = Union[WriteEntry, SyncWriteEntry, AsyncWriteEntry]
210
+
211
+
160
212
  class FileStreamReader(Iterator[bytes]):
161
213
  """Iterator over a streamed file download.
162
214
 
@@ -264,7 +316,143 @@ class AsyncFileStreamReader(AsyncIterator[bytes]):
264
316
  await self.aclose()
265
317
 
266
318
 
267
- def _to_httpx_file(file_path: str, file_data: Union[str, bytes, IO]):
319
+ def _is_file_like(data) -> TypeGuard[IO]:
320
+ """Whether ``data`` is read as a file: an ``IOBase``, or any object with a
321
+ sync ``read`` method (``tempfile`` wrappers, werkzeug ``FileStorage``, Django
322
+ ``File``), which would otherwise be iterated line by line.
323
+
324
+ An async ``read`` (aiofiles files, aiohttp ``response.content``) doesn't
325
+ count: those are consumed as async iterables."""
326
+ if isinstance(data, IOBase):
327
+ return True
328
+ if isinstance(data, (str, bytes)):
329
+ return False
330
+ read = getattr(data, "read", None)
331
+ return callable(read) and not inspect.iscoroutinefunction(read)
332
+
333
+
334
+ def _is_chunk_iterable(data) -> TypeGuard[Iterable[bytes]]:
335
+ """Whether ``data`` is an iterable of ``bytes`` chunks (not a buffer or file)."""
336
+ return (
337
+ isinstance(data, Iterable)
338
+ and not isinstance(data, (str, bytes, bytearray, memoryview))
339
+ and not _is_file_like(data)
340
+ )
341
+
342
+
343
+ def _is_async_chunk_iterable(data) -> TypeGuard[AsyncIterable[bytes]]:
344
+ return isinstance(data, AsyncIterable) and not _is_file_like(data)
345
+
346
+
347
+ class ChunkCheck:
348
+ """Records a chunk validation error raised while the transport pulls the
349
+ upload body: the transport reports it as its own ``httpx.WriteError``, so
350
+ the write re-raises the recorded error instead."""
351
+
352
+ def __init__(self) -> None:
353
+ self.error: Optional[InvalidArgumentException] = None
354
+
355
+
356
+ def _check_chunk(chunk, check: Optional[ChunkCheck] = None) -> bytes:
357
+ if isinstance(chunk, bytes):
358
+ return chunk
359
+ if isinstance(chunk, (bytearray, memoryview)):
360
+ return bytes(chunk)
361
+ err = InvalidArgumentException(
362
+ f"Iterable upload data must yield bytes chunks, got {type(chunk).__name__}"
363
+ )
364
+ if check is not None:
365
+ check.error = err
366
+ raise err
367
+
368
+
369
+ def iter_chunks(
370
+ data: Iterable[bytes], check: Optional[ChunkCheck] = None
371
+ ) -> Iterator[bytes]:
372
+ """Iterate user-supplied upload chunks, rejecting anything but bytes."""
373
+ for chunk in data:
374
+ yield _check_chunk(chunk, check)
375
+
376
+
377
+ async def aiter_chunks(
378
+ data: AsyncIterable[bytes], check: Optional[ChunkCheck] = None
379
+ ) -> AsyncIterator[bytes]:
380
+ """Iterate user-supplied async upload chunks, rejecting anything but bytes."""
381
+ async for chunk in data:
382
+ yield _check_chunk(chunk, check)
383
+
384
+
385
+ def _is_wrong_iterable(data, is_async: bool) -> bool:
386
+ """Whether ``data`` is an iterable of the kind the other SDK takes: async
387
+ iterables only go to ``AsyncSandbox``, sync ones only to ``Sandbox``."""
388
+ if is_async:
389
+ return _is_chunk_iterable(data) and not _is_async_chunk_iterable(data)
390
+ return _is_async_chunk_iterable(data) and not _is_chunk_iterable(data)
391
+
392
+
393
+ def _unsupported_data(
394
+ data, is_async: bool, file_path: Optional[str] = None
395
+ ) -> InvalidArgumentException:
396
+ target = f" for file {file_path}" if file_path else ""
397
+ if _is_wrong_iterable(data, is_async):
398
+ if is_async:
399
+ return InvalidArgumentException(
400
+ f"Sync iterable data{target} is only supported by `Sandbox`; "
401
+ "pass an async iterable of bytes, a file-like object or bytes to `AsyncSandbox.files.write`."
402
+ )
403
+ return InvalidArgumentException(
404
+ f"Async iterable data{target} is only supported by `AsyncSandbox`; "
405
+ "pass a sync iterable of bytes, a file-like object or bytes to `Sandbox.files.write`."
406
+ )
407
+ return InvalidArgumentException(f"Unsupported data type{target}: {type(data)}")
408
+
409
+
410
+ def check_stream_upload(
411
+ files: Sequence[AnyWriteEntry],
412
+ use_octet_stream: bool,
413
+ supports_octet_stream: bool,
414
+ is_async: bool,
415
+ ) -> None:
416
+ """Reject iterable data on the multipart upload, which would buffer it.
417
+
418
+ Iterables of the other SDK's kind are rejected outright: sync ones in
419
+ ``AsyncSandbox`` (``is_async``), async ones in ``Sandbox``.
420
+ """
421
+ for file in files:
422
+ if _is_wrong_iterable(file["data"], is_async):
423
+ raise _unsupported_data(file["data"], is_async, file["path"])
424
+ if not any(
425
+ _is_chunk_iterable(file["data"]) or _is_async_chunk_iterable(file["data"])
426
+ for file in files
427
+ ):
428
+ return
429
+ if not supports_octet_stream:
430
+ raise TemplateException("Uploading iterable data requires envd 0.5.7 or later.")
431
+ if not use_octet_stream:
432
+ raise InvalidArgumentException(
433
+ "Iterable data is only uploaded with octet-stream; "
434
+ "`use_octet_stream=False` is not supported for it."
435
+ )
436
+
437
+
438
+ class _BinaryReader:
439
+ """Reads a non-``IOBase`` file-like of either mode as UTF-8 bytes.
440
+
441
+ httpx sizes a multipart file by its descriptor, which miscounts text that
442
+ re-encodes to a different length, so this hides the descriptor and httpx
443
+ streams the field without a precomputed length."""
444
+
445
+ def __init__(self, data: IO) -> None:
446
+ self._data = data
447
+
448
+ def read(self, size: int = -1) -> bytes:
449
+ chunk = self._data.read(size)
450
+ return chunk if isinstance(chunk, bytes) else chunk.encode("utf-8")
451
+
452
+
453
+ def _to_httpx_file(
454
+ file_path: str, file_data: Union[WriteData, AsyncWriteData], is_async: bool
455
+ ):
268
456
  """Build an httpx multipart `("file", (name, data))` tuple for the upload."""
269
457
  if isinstance(file_data, (str, bytes)):
270
458
  return ("file", (file_path, file_data))
@@ -276,11 +464,15 @@ def _to_httpx_file(file_path: str, file_data: Union[str, bytes, IO]):
276
464
  return ("file", (file_path, file_data.read()))
277
465
  elif isinstance(file_data, IOBase):
278
466
  return ("file", (file_path, file_data))
467
+ elif _is_file_like(file_data):
468
+ return ("file", (file_path, cast(IO[bytes], _BinaryReader(file_data))))
279
469
  else:
280
- raise InvalidArgumentException(f"Unsupported data type for file {file_path}")
470
+ raise _unsupported_data(file_data, is_async, file_path)
281
471
 
282
472
 
283
- def multipart_body_is_streamed(files: List[WriteEntry]) -> bool:
473
+ def multipart_body_is_streamed(
474
+ files: Sequence[AnyWriteEntry],
475
+ ) -> bool:
284
476
  """Whether the multipart body built from ``files`` streams any entry.
285
477
 
286
478
  Only binary file-like data is handed to httpx as a stream:
@@ -291,52 +483,65 @@ def multipart_body_is_streamed(files: List[WriteEntry]) -> bool:
291
483
  ``to_upload_body``, which streams text and binary alike on the
292
484
  octet-stream path (``iter_io_chunks`` encodes the chunks)."""
293
485
  return any(
294
- isinstance(file["data"], IOBase) and not isinstance(file["data"], TextIOBase)
486
+ _is_file_like(file["data"]) and not isinstance(file["data"], TextIOBase)
295
487
  for file in files
296
488
  )
297
489
 
298
490
 
299
491
  def to_upload_body(
300
- data: Union[str, bytes, IO],
492
+ data: WriteData,
301
493
  use_gzip: bool = False,
494
+ check: Optional[ChunkCheck] = None,
302
495
  ) -> Union[bytes, IO, Iterator[bytes]]:
303
496
  """Prepare file data for upload, optionally gzip-compressed.
304
497
 
305
- File-like objects are streamed in chunks instead of being buffered in
306
- memory.
498
+ File-like objects and iterables of bytes are streamed in chunks instead of
499
+ being buffered in memory.
307
500
  """
308
501
  if isinstance(data, (str, bytes)):
309
502
  raw = data.encode("utf-8") if isinstance(data, str) else data
310
503
  return gzip.compress(raw) if use_gzip else raw
311
- elif isinstance(data, (TextIOBase, IOBase)):
312
- if use_gzip:
313
- return gzip_iter(iter_io_chunks(data))
314
- if isinstance(data, TextIOBase):
315
- # Text-mode IO yields str chunks—encode them while streaming.
316
- return iter_io_chunks(data)
317
- # httpx streams binary file-like objects in chunks without buffering.
318
- return data
504
+ elif _is_file_like(data):
505
+ if (
506
+ isinstance(data, IOBase)
507
+ and not isinstance(data, TextIOBase)
508
+ and not use_gzip
509
+ ):
510
+ # httpx streams binary file-like objects in chunks without buffering.
511
+ return cast(IO, data)
512
+ # Text-mode IO yields str chunks—encode them while streaming. Other
513
+ # file-likes may be either mode, and httpx would iterate them by line.
514
+ chunks = iter_io_chunks(data)
515
+ return gzip_iter(chunks) if use_gzip else chunks
516
+ elif _is_chunk_iterable(data):
517
+ chunks = iter_chunks(data, check)
518
+ return gzip_iter(chunks) if use_gzip else chunks
319
519
  else:
320
- raise InvalidArgumentException(f"Unsupported data type: {type(data)}")
520
+ raise _unsupported_data(data, is_async=False)
321
521
 
322
522
 
323
523
  def to_upload_body_async(
324
- data: Union[str, bytes, IO],
524
+ data: AsyncWriteData,
325
525
  use_gzip: bool = False,
526
+ check: Optional[ChunkCheck] = None,
326
527
  ) -> Union[bytes, AsyncIterator[bytes]]:
327
528
  """Prepare file data for upload with async httpx, optionally gzip-compressed.
328
529
 
329
- File-like objects are streamed in chunks instead of being buffered in
330
- memory. Async httpx requires an async iterable for streamed request bodies.
530
+ File-like objects and async iterables of bytes are streamed in chunks
531
+ instead of being buffered in memory. Async httpx requires an async iterable
532
+ for streamed request bodies.
331
533
  """
332
534
  if isinstance(data, (str, bytes)):
333
535
  raw = data.encode("utf-8") if isinstance(data, str) else data
334
536
  return gzip.compress(raw) if use_gzip else raw
335
- elif isinstance(data, (TextIOBase, IOBase)):
537
+ elif _is_file_like(data):
336
538
  chunks = aiter_io_chunks(data)
337
539
  return agzip_iter(chunks) if use_gzip else chunks
540
+ elif _is_async_chunk_iterable(data):
541
+ chunks = aiter_chunks(data, check)
542
+ return agzip_iter(chunks) if use_gzip else chunks
338
543
  else:
339
- raise InvalidArgumentException(f"Unsupported data type: {type(data)}")
544
+ raise _unsupported_data(data, is_async=True)
340
545
 
341
546
 
342
547
  METADATA_HEADER_PREFIX = "X-Metadata-"