northrays 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (711) hide show
  1. northrays/__init__.py +245 -0
  2. northrays/_async/__init__.py +2 -0
  3. northrays/_async/code_interpreter.py +302 -0
  4. northrays/_async/computer_use.py +930 -0
  5. northrays/_async/filesystem.py +1240 -0
  6. northrays/_async/git.py +391 -0
  7. northrays/_async/lsp_server.py +256 -0
  8. northrays/_async/northrays.py +819 -0
  9. northrays/_async/object_storage.py +190 -0
  10. northrays/_async/process.py +781 -0
  11. northrays/_async/sandbox.py +904 -0
  12. northrays/_async/snapshot.py +262 -0
  13. northrays/_async/volume.py +94 -0
  14. northrays/_sync/__init__.py +2 -0
  15. northrays/_sync/code_interpreter.py +271 -0
  16. northrays/_sync/computer_use.py +929 -0
  17. northrays/_sync/filesystem.py +1063 -0
  18. northrays/_sync/git.py +389 -0
  19. northrays/_sync/lsp_server.py +256 -0
  20. northrays/_sync/northrays.py +704 -0
  21. northrays/_sync/object_storage.py +184 -0
  22. northrays/_sync/process.py +778 -0
  23. northrays/_sync/sandbox.py +919 -0
  24. northrays/_sync/snapshot.py +262 -0
  25. northrays/_sync/volume.py +94 -0
  26. northrays/_utils/__init__.py +2 -0
  27. northrays/_utils/deprecation.py +95 -0
  28. northrays/_utils/docs_ignore.py +11 -0
  29. northrays/_utils/enum.py +27 -0
  30. northrays/_utils/env.py +38 -0
  31. northrays/_utils/environment.py +23 -0
  32. northrays/_utils/errors.py +298 -0
  33. northrays/_utils/otel_decorator.py +331 -0
  34. northrays/_utils/stream.py +368 -0
  35. northrays/_utils/timeout.py +484 -0
  36. northrays/_utils/types.py +16 -0
  37. northrays/common/__init__.py +2 -0
  38. northrays/common/charts.py +118 -0
  39. northrays/common/code_interpreter.py +44 -0
  40. northrays/common/computer_use.py +44 -0
  41. northrays/common/errors.py +187 -0
  42. northrays/common/file_transfer.py +69 -0
  43. northrays/common/filesystem.py +177 -0
  44. northrays/common/git.py +13 -0
  45. northrays/common/image.py +700 -0
  46. northrays/common/lsp_server.py +45 -0
  47. northrays/common/northrays.py +202 -0
  48. northrays/common/process.py +140 -0
  49. northrays/common/protocols.py +14 -0
  50. northrays/common/pty.py +65 -0
  51. northrays/common/sandbox.py +99 -0
  52. northrays/common/snapshot.py +84 -0
  53. northrays/common/volume.py +39 -0
  54. northrays/handle/async_pty_handle.py +323 -0
  55. northrays/handle/pty_handle.py +341 -0
  56. northrays/internal/__init__.py +2 -0
  57. northrays/internal/api_client_proxy.py +22 -0
  58. northrays/internal/http_client.py +99 -0
  59. northrays/internal/pool_tracker.py +44 -0
  60. northrays/internal/shared_session.py +262 -0
  61. northrays/internal/toolbox_api_client_proxy.py +114 -0
  62. northrays/internal/urllib3_retry.py +53 -0
  63. northrays/py.typed +0 -0
  64. northrays-0.1.0.dist-info/METADATA +211 -0
  65. northrays-0.1.0.dist-info/RECORD +711 -0
  66. northrays-0.1.0.dist-info/WHEEL +5 -0
  67. northrays-0.1.0.dist-info/licenses/LICENSE +191 -0
  68. northrays-0.1.0.dist-info/licenses/NOTICE +46 -0
  69. northrays-0.1.0.dist-info/top_level.txt +5 -0
  70. northrays_api_client/__init__.py +684 -0
  71. northrays_api_client/api/__init__.py +64 -0
  72. northrays_api_client/api/admin_api.py +5998 -0
  73. northrays_api_client/api/api_keys_api.py +1672 -0
  74. northrays_api_client/api/audit_api.py +402 -0
  75. northrays_api_client/api/config_api.py +278 -0
  76. northrays_api_client/api/docker_registry_api.py +1707 -0
  77. northrays_api_client/api/health_api.py +517 -0
  78. northrays_api_client/api/jobs_api.py +1185 -0
  79. northrays_api_client/api/object_storage_api.py +298 -0
  80. northrays_api_client/api/organizations_api.py +10857 -0
  81. northrays_api_client/api/preview_api.py +1104 -0
  82. northrays_api_client/api/regions_api.py +279 -0
  83. northrays_api_client/api/runners_api.py +2987 -0
  84. northrays_api_client/api/sandbox_api.py +12813 -0
  85. northrays_api_client/api/snapshots_api.py +2331 -0
  86. northrays_api_client/api/toolbox_api.py +20758 -0
  87. northrays_api_client/api/users_api.py +1304 -0
  88. northrays_api_client/api/volumes_api.py +1421 -0
  89. northrays_api_client/api/webhooks_api.py +1135 -0
  90. northrays_api_client/api_client.py +810 -0
  91. northrays_api_client/api_response.py +21 -0
  92. northrays_api_client/configuration.py +607 -0
  93. northrays_api_client/exceptions.py +219 -0
  94. northrays_api_client/models/__init__.py +405 -0
  95. northrays_api_client/models/account_provider.py +105 -0
  96. northrays_api_client/models/admin_create_runner.py +131 -0
  97. northrays_api_client/models/admin_get_webhook_status200_response.py +103 -0
  98. northrays_api_client/models/announcement.py +105 -0
  99. northrays_api_client/models/api_key_list.py +126 -0
  100. northrays_api_client/models/api_key_response.py +117 -0
  101. northrays_api_client/models/audit_log.py +134 -0
  102. northrays_api_client/models/build_info.py +112 -0
  103. northrays_api_client/models/command.py +107 -0
  104. northrays_api_client/models/completion_context.py +105 -0
  105. northrays_api_client/models/completion_item.py +115 -0
  106. northrays_api_client/models/completion_list.py +113 -0
  107. northrays_api_client/models/compressed_screenshot_response.py +107 -0
  108. northrays_api_client/models/computer_use_start_response.py +105 -0
  109. northrays_api_client/models/computer_use_status_response.py +103 -0
  110. northrays_api_client/models/computer_use_stop_response.py +105 -0
  111. northrays_api_client/models/create_api_key.py +113 -0
  112. northrays_api_client/models/create_build_info.py +105 -0
  113. northrays_api_client/models/create_docker_registry.py +111 -0
  114. northrays_api_client/models/create_linked_account.py +105 -0
  115. northrays_api_client/models/create_organization.py +105 -0
  116. northrays_api_client/models/create_organization_invitation.py +110 -0
  117. northrays_api_client/models/create_organization_quota.py +119 -0
  118. northrays_api_client/models/create_organization_region_quota.py +169 -0
  119. northrays_api_client/models/create_organization_role.py +107 -0
  120. northrays_api_client/models/create_region.py +124 -0
  121. northrays_api_client/models/create_region_response.py +131 -0
  122. northrays_api_client/models/create_runner.py +107 -0
  123. northrays_api_client/models/create_runner_response.py +105 -0
  124. northrays_api_client/models/create_sandbox.py +156 -0
  125. northrays_api_client/models/create_sandbox_snapshot.py +105 -0
  126. northrays_api_client/models/create_session_request.py +103 -0
  127. northrays_api_client/models/create_snapshot.py +129 -0
  128. northrays_api_client/models/create_user.py +119 -0
  129. northrays_api_client/models/create_volume.py +103 -0
  130. northrays_api_client/models/display_info_response.py +103 -0
  131. northrays_api_client/models/docker_registry.py +118 -0
  132. northrays_api_client/models/download_files.py +103 -0
  133. northrays_api_client/models/execute_request.py +107 -0
  134. northrays_api_client/models/execute_response.py +105 -0
  135. northrays_api_client/models/file_info.py +117 -0
  136. northrays_api_client/models/file_status.py +109 -0
  137. northrays_api_client/models/fork_sandbox.py +103 -0
  138. northrays_api_client/models/git_add_request.py +105 -0
  139. northrays_api_client/models/git_branch_request.py +105 -0
  140. northrays_api_client/models/git_checkout_request.py +105 -0
  141. northrays_api_client/models/git_clone_request.py +113 -0
  142. northrays_api_client/models/git_commit_info.py +111 -0
  143. northrays_api_client/models/git_commit_request.py +111 -0
  144. northrays_api_client/models/git_commit_response.py +103 -0
  145. northrays_api_client/models/git_delete_branch_request.py +105 -0
  146. northrays_api_client/models/git_repo_request.py +107 -0
  147. northrays_api_client/models/git_status.py +119 -0
  148. northrays_api_client/models/gpu_type.py +43 -0
  149. northrays_api_client/models/health_controller_check200_response.py +156 -0
  150. northrays_api_client/models/health_controller_check200_response_info_value.py +103 -0
  151. northrays_api_client/models/health_controller_check503_response.py +156 -0
  152. northrays_api_client/models/job.py +123 -0
  153. northrays_api_client/models/job_status.py +45 -0
  154. northrays_api_client/models/job_type.py +56 -0
  155. northrays_api_client/models/keyboard_hotkey_request.py +103 -0
  156. northrays_api_client/models/keyboard_press_request.py +105 -0
  157. northrays_api_client/models/keyboard_type_request.py +105 -0
  158. northrays_api_client/models/list_branch_response.py +103 -0
  159. northrays_api_client/models/list_sandboxes_response.py +118 -0
  160. northrays_api_client/models/log_entry.py +119 -0
  161. northrays_api_client/models/lsp_completion_params.py +119 -0
  162. northrays_api_client/models/lsp_document_request.py +107 -0
  163. northrays_api_client/models/lsp_location.py +109 -0
  164. northrays_api_client/models/lsp_server_request.py +105 -0
  165. northrays_api_client/models/lsp_symbol.py +111 -0
  166. northrays_api_client/models/match.py +107 -0
  167. northrays_api_client/models/metric_data_point.py +105 -0
  168. northrays_api_client/models/metric_series.py +113 -0
  169. northrays_api_client/models/metrics_response.py +111 -0
  170. northrays_api_client/models/mouse_click_request.py +109 -0
  171. northrays_api_client/models/mouse_click_response.py +105 -0
  172. northrays_api_client/models/mouse_drag_request.py +111 -0
  173. northrays_api_client/models/mouse_drag_response.py +105 -0
  174. northrays_api_client/models/mouse_move_request.py +105 -0
  175. northrays_api_client/models/mouse_move_response.py +105 -0
  176. northrays_api_client/models/mouse_position.py +105 -0
  177. northrays_api_client/models/mouse_scroll_request.py +109 -0
  178. northrays_api_client/models/mouse_scroll_response.py +103 -0
  179. northrays_api_client/models/northrays_configuration.py +162 -0
  180. northrays_api_client/models/oidc_config.py +107 -0
  181. northrays_api_client/models/organization.py +191 -0
  182. northrays_api_client/models/organization_invitation.py +132 -0
  183. northrays_api_client/models/organization_role.py +116 -0
  184. northrays_api_client/models/organization_sandbox_default_limited_network_egress.py +103 -0
  185. northrays_api_client/models/organization_suspension.py +109 -0
  186. northrays_api_client/models/organization_usage_overview.py +119 -0
  187. northrays_api_client/models/organization_user.py +126 -0
  188. northrays_api_client/models/otel_config.py +110 -0
  189. northrays_api_client/models/paginated_audit_logs.py +119 -0
  190. northrays_api_client/models/paginated_jobs.py +117 -0
  191. northrays_api_client/models/paginated_logs.py +117 -0
  192. northrays_api_client/models/paginated_sandboxes_deprecated.py +117 -0
  193. northrays_api_client/models/paginated_snapshots.py +117 -0
  194. northrays_api_client/models/paginated_traces.py +117 -0
  195. northrays_api_client/models/poll_jobs_response.py +111 -0
  196. northrays_api_client/models/port_preview_url.py +107 -0
  197. northrays_api_client/models/position.py +105 -0
  198. northrays_api_client/models/posthog_config.py +105 -0
  199. northrays_api_client/models/process_errors_response.py +105 -0
  200. northrays_api_client/models/process_logs_response.py +105 -0
  201. northrays_api_client/models/process_restart_response.py +105 -0
  202. northrays_api_client/models/process_status_response.py +105 -0
  203. northrays_api_client/models/project_dir_response.py +103 -0
  204. northrays_api_client/models/pty_create_request.py +113 -0
  205. northrays_api_client/models/pty_create_response.py +103 -0
  206. northrays_api_client/models/pty_list_response.py +111 -0
  207. northrays_api_client/models/pty_resize_request.py +105 -0
  208. northrays_api_client/models/pty_session_info.py +117 -0
  209. northrays_api_client/models/range.py +112 -0
  210. northrays_api_client/models/rate_limit_config.py +122 -0
  211. northrays_api_client/models/rate_limit_entry.py +105 -0
  212. northrays_api_client/models/regenerate_api_key_response.py +103 -0
  213. northrays_api_client/models/region.py +140 -0
  214. northrays_api_client/models/region_quota.py +168 -0
  215. northrays_api_client/models/region_screenshot_response.py +107 -0
  216. northrays_api_client/models/region_type.py +44 -0
  217. northrays_api_client/models/region_usage_overview.py +174 -0
  218. northrays_api_client/models/registry_push_access_dto.py +113 -0
  219. northrays_api_client/models/replace_request.py +107 -0
  220. northrays_api_client/models/replace_result.py +107 -0
  221. northrays_api_client/models/resize_sandbox.py +108 -0
  222. northrays_api_client/models/runner.py +166 -0
  223. northrays_api_client/models/runner_class.py +42 -0
  224. northrays_api_client/models/runner_full.py +171 -0
  225. northrays_api_client/models/runner_health_metrics.py +129 -0
  226. northrays_api_client/models/runner_healthcheck.py +125 -0
  227. northrays_api_client/models/runner_service_health.py +107 -0
  228. northrays_api_client/models/runner_snapshot_dto.py +107 -0
  229. northrays_api_client/models/runner_state.py +46 -0
  230. northrays_api_client/models/sandbox.py +188 -0
  231. northrays_api_client/models/sandbox_class.py +45 -0
  232. northrays_api_client/models/sandbox_desired_state.py +47 -0
  233. northrays_api_client/models/sandbox_labels.py +103 -0
  234. northrays_api_client/models/sandbox_list_item.py +161 -0
  235. northrays_api_client/models/sandbox_list_sort_direction.py +43 -0
  236. northrays_api_client/models/sandbox_list_sort_field.py +47 -0
  237. northrays_api_client/models/sandbox_state.py +63 -0
  238. northrays_api_client/models/sandbox_volume.py +107 -0
  239. northrays_api_client/models/screenshot_response.py +107 -0
  240. northrays_api_client/models/search_files_response.py +103 -0
  241. northrays_api_client/models/send_webhook_dto.py +108 -0
  242. northrays_api_client/models/session.py +118 -0
  243. northrays_api_client/models/session_execute_request.py +107 -0
  244. northrays_api_client/models/session_execute_response.py +107 -0
  245. northrays_api_client/models/set_snapshot_general_status_dto.py +103 -0
  246. northrays_api_client/models/signed_port_preview_url.py +109 -0
  247. northrays_api_client/models/snapshot_dto.py +172 -0
  248. northrays_api_client/models/snapshot_manager_credentials.py +105 -0
  249. northrays_api_client/models/snapshot_state.py +49 -0
  250. northrays_api_client/models/ssh_access_dto.py +116 -0
  251. northrays_api_client/models/ssh_access_validation_dto.py +105 -0
  252. northrays_api_client/models/storage_access_dto.py +113 -0
  253. northrays_api_client/models/toolbox_proxy_url.py +103 -0
  254. northrays_api_client/models/trace_span.py +119 -0
  255. northrays_api_client/models/trace_summary.py +115 -0
  256. northrays_api_client/models/update_docker_registry.py +111 -0
  257. northrays_api_client/models/update_job_status.py +108 -0
  258. northrays_api_client/models/update_organization_default_region.py +103 -0
  259. northrays_api_client/models/update_organization_invitation.py +108 -0
  260. northrays_api_client/models/update_organization_member_access.py +105 -0
  261. northrays_api_client/models/update_organization_quota.py +192 -0
  262. northrays_api_client/models/update_organization_region_quota.py +189 -0
  263. northrays_api_client/models/update_organization_role.py +107 -0
  264. northrays_api_client/models/update_region.py +122 -0
  265. northrays_api_client/models/update_sandbox_network_settings.py +107 -0
  266. northrays_api_client/models/update_sandbox_state_dto.py +107 -0
  267. northrays_api_client/models/url.py +103 -0
  268. northrays_api_client/models/user.py +120 -0
  269. northrays_api_client/models/user_home_dir_response.py +103 -0
  270. northrays_api_client/models/user_public_key.py +105 -0
  271. northrays_api_client/models/volume_dto.py +128 -0
  272. northrays_api_client/models/volume_state.py +48 -0
  273. northrays_api_client/models/webhook_app_portal_access.py +105 -0
  274. northrays_api_client/models/webhook_event.py +48 -0
  275. northrays_api_client/models/webhook_initialization_status.py +123 -0
  276. northrays_api_client/models/windows_response.py +105 -0
  277. northrays_api_client/models/work_dir_response.py +103 -0
  278. northrays_api_client/py.typed +0 -0
  279. northrays_api_client/rest.py +264 -0
  280. northrays_api_client_async/__init__.py +684 -0
  281. northrays_api_client_async/api/__init__.py +64 -0
  282. northrays_api_client_async/api/admin_api.py +5998 -0
  283. northrays_api_client_async/api/api_keys_api.py +1672 -0
  284. northrays_api_client_async/api/audit_api.py +402 -0
  285. northrays_api_client_async/api/config_api.py +278 -0
  286. northrays_api_client_async/api/docker_registry_api.py +1707 -0
  287. northrays_api_client_async/api/health_api.py +517 -0
  288. northrays_api_client_async/api/jobs_api.py +1185 -0
  289. northrays_api_client_async/api/object_storage_api.py +298 -0
  290. northrays_api_client_async/api/organizations_api.py +10857 -0
  291. northrays_api_client_async/api/preview_api.py +1104 -0
  292. northrays_api_client_async/api/regions_api.py +279 -0
  293. northrays_api_client_async/api/runners_api.py +2987 -0
  294. northrays_api_client_async/api/sandbox_api.py +12813 -0
  295. northrays_api_client_async/api/snapshots_api.py +2331 -0
  296. northrays_api_client_async/api/toolbox_api.py +20758 -0
  297. northrays_api_client_async/api/users_api.py +1304 -0
  298. northrays_api_client_async/api/volumes_api.py +1421 -0
  299. northrays_api_client_async/api/webhooks_api.py +1135 -0
  300. northrays_api_client_async/api_client.py +813 -0
  301. northrays_api_client_async/api_response.py +21 -0
  302. northrays_api_client_async/configuration.py +605 -0
  303. northrays_api_client_async/exceptions.py +219 -0
  304. northrays_api_client_async/models/__init__.py +405 -0
  305. northrays_api_client_async/models/account_provider.py +105 -0
  306. northrays_api_client_async/models/admin_create_runner.py +131 -0
  307. northrays_api_client_async/models/admin_get_webhook_status200_response.py +103 -0
  308. northrays_api_client_async/models/announcement.py +105 -0
  309. northrays_api_client_async/models/api_key_list.py +126 -0
  310. northrays_api_client_async/models/api_key_response.py +117 -0
  311. northrays_api_client_async/models/audit_log.py +134 -0
  312. northrays_api_client_async/models/build_info.py +112 -0
  313. northrays_api_client_async/models/command.py +107 -0
  314. northrays_api_client_async/models/completion_context.py +105 -0
  315. northrays_api_client_async/models/completion_item.py +115 -0
  316. northrays_api_client_async/models/completion_list.py +113 -0
  317. northrays_api_client_async/models/compressed_screenshot_response.py +107 -0
  318. northrays_api_client_async/models/computer_use_start_response.py +105 -0
  319. northrays_api_client_async/models/computer_use_status_response.py +103 -0
  320. northrays_api_client_async/models/computer_use_stop_response.py +105 -0
  321. northrays_api_client_async/models/create_api_key.py +113 -0
  322. northrays_api_client_async/models/create_build_info.py +105 -0
  323. northrays_api_client_async/models/create_docker_registry.py +111 -0
  324. northrays_api_client_async/models/create_linked_account.py +105 -0
  325. northrays_api_client_async/models/create_organization.py +105 -0
  326. northrays_api_client_async/models/create_organization_invitation.py +110 -0
  327. northrays_api_client_async/models/create_organization_quota.py +119 -0
  328. northrays_api_client_async/models/create_organization_region_quota.py +169 -0
  329. northrays_api_client_async/models/create_organization_role.py +107 -0
  330. northrays_api_client_async/models/create_region.py +124 -0
  331. northrays_api_client_async/models/create_region_response.py +131 -0
  332. northrays_api_client_async/models/create_runner.py +107 -0
  333. northrays_api_client_async/models/create_runner_response.py +105 -0
  334. northrays_api_client_async/models/create_sandbox.py +156 -0
  335. northrays_api_client_async/models/create_sandbox_snapshot.py +105 -0
  336. northrays_api_client_async/models/create_session_request.py +103 -0
  337. northrays_api_client_async/models/create_snapshot.py +129 -0
  338. northrays_api_client_async/models/create_user.py +119 -0
  339. northrays_api_client_async/models/create_volume.py +103 -0
  340. northrays_api_client_async/models/display_info_response.py +103 -0
  341. northrays_api_client_async/models/docker_registry.py +118 -0
  342. northrays_api_client_async/models/download_files.py +103 -0
  343. northrays_api_client_async/models/execute_request.py +107 -0
  344. northrays_api_client_async/models/execute_response.py +105 -0
  345. northrays_api_client_async/models/file_info.py +117 -0
  346. northrays_api_client_async/models/file_status.py +109 -0
  347. northrays_api_client_async/models/fork_sandbox.py +103 -0
  348. northrays_api_client_async/models/git_add_request.py +105 -0
  349. northrays_api_client_async/models/git_branch_request.py +105 -0
  350. northrays_api_client_async/models/git_checkout_request.py +105 -0
  351. northrays_api_client_async/models/git_clone_request.py +113 -0
  352. northrays_api_client_async/models/git_commit_info.py +111 -0
  353. northrays_api_client_async/models/git_commit_request.py +111 -0
  354. northrays_api_client_async/models/git_commit_response.py +103 -0
  355. northrays_api_client_async/models/git_delete_branch_request.py +105 -0
  356. northrays_api_client_async/models/git_repo_request.py +107 -0
  357. northrays_api_client_async/models/git_status.py +119 -0
  358. northrays_api_client_async/models/gpu_type.py +43 -0
  359. northrays_api_client_async/models/health_controller_check200_response.py +156 -0
  360. northrays_api_client_async/models/health_controller_check200_response_info_value.py +103 -0
  361. northrays_api_client_async/models/health_controller_check503_response.py +156 -0
  362. northrays_api_client_async/models/job.py +123 -0
  363. northrays_api_client_async/models/job_status.py +45 -0
  364. northrays_api_client_async/models/job_type.py +56 -0
  365. northrays_api_client_async/models/keyboard_hotkey_request.py +103 -0
  366. northrays_api_client_async/models/keyboard_press_request.py +105 -0
  367. northrays_api_client_async/models/keyboard_type_request.py +105 -0
  368. northrays_api_client_async/models/list_branch_response.py +103 -0
  369. northrays_api_client_async/models/list_sandboxes_response.py +118 -0
  370. northrays_api_client_async/models/log_entry.py +119 -0
  371. northrays_api_client_async/models/lsp_completion_params.py +119 -0
  372. northrays_api_client_async/models/lsp_document_request.py +107 -0
  373. northrays_api_client_async/models/lsp_location.py +109 -0
  374. northrays_api_client_async/models/lsp_server_request.py +105 -0
  375. northrays_api_client_async/models/lsp_symbol.py +111 -0
  376. northrays_api_client_async/models/match.py +107 -0
  377. northrays_api_client_async/models/metric_data_point.py +105 -0
  378. northrays_api_client_async/models/metric_series.py +113 -0
  379. northrays_api_client_async/models/metrics_response.py +111 -0
  380. northrays_api_client_async/models/mouse_click_request.py +109 -0
  381. northrays_api_client_async/models/mouse_click_response.py +105 -0
  382. northrays_api_client_async/models/mouse_drag_request.py +111 -0
  383. northrays_api_client_async/models/mouse_drag_response.py +105 -0
  384. northrays_api_client_async/models/mouse_move_request.py +105 -0
  385. northrays_api_client_async/models/mouse_move_response.py +105 -0
  386. northrays_api_client_async/models/mouse_position.py +105 -0
  387. northrays_api_client_async/models/mouse_scroll_request.py +109 -0
  388. northrays_api_client_async/models/mouse_scroll_response.py +103 -0
  389. northrays_api_client_async/models/northrays_configuration.py +162 -0
  390. northrays_api_client_async/models/oidc_config.py +107 -0
  391. northrays_api_client_async/models/organization.py +191 -0
  392. northrays_api_client_async/models/organization_invitation.py +132 -0
  393. northrays_api_client_async/models/organization_role.py +116 -0
  394. northrays_api_client_async/models/organization_sandbox_default_limited_network_egress.py +103 -0
  395. northrays_api_client_async/models/organization_suspension.py +109 -0
  396. northrays_api_client_async/models/organization_usage_overview.py +119 -0
  397. northrays_api_client_async/models/organization_user.py +126 -0
  398. northrays_api_client_async/models/otel_config.py +110 -0
  399. northrays_api_client_async/models/paginated_audit_logs.py +119 -0
  400. northrays_api_client_async/models/paginated_jobs.py +117 -0
  401. northrays_api_client_async/models/paginated_logs.py +117 -0
  402. northrays_api_client_async/models/paginated_sandboxes_deprecated.py +117 -0
  403. northrays_api_client_async/models/paginated_snapshots.py +117 -0
  404. northrays_api_client_async/models/paginated_traces.py +117 -0
  405. northrays_api_client_async/models/poll_jobs_response.py +111 -0
  406. northrays_api_client_async/models/port_preview_url.py +107 -0
  407. northrays_api_client_async/models/position.py +105 -0
  408. northrays_api_client_async/models/posthog_config.py +105 -0
  409. northrays_api_client_async/models/process_errors_response.py +105 -0
  410. northrays_api_client_async/models/process_logs_response.py +105 -0
  411. northrays_api_client_async/models/process_restart_response.py +105 -0
  412. northrays_api_client_async/models/process_status_response.py +105 -0
  413. northrays_api_client_async/models/project_dir_response.py +103 -0
  414. northrays_api_client_async/models/pty_create_request.py +113 -0
  415. northrays_api_client_async/models/pty_create_response.py +103 -0
  416. northrays_api_client_async/models/pty_list_response.py +111 -0
  417. northrays_api_client_async/models/pty_resize_request.py +105 -0
  418. northrays_api_client_async/models/pty_session_info.py +117 -0
  419. northrays_api_client_async/models/range.py +112 -0
  420. northrays_api_client_async/models/rate_limit_config.py +122 -0
  421. northrays_api_client_async/models/rate_limit_entry.py +105 -0
  422. northrays_api_client_async/models/regenerate_api_key_response.py +103 -0
  423. northrays_api_client_async/models/region.py +140 -0
  424. northrays_api_client_async/models/region_quota.py +168 -0
  425. northrays_api_client_async/models/region_screenshot_response.py +107 -0
  426. northrays_api_client_async/models/region_type.py +44 -0
  427. northrays_api_client_async/models/region_usage_overview.py +174 -0
  428. northrays_api_client_async/models/registry_push_access_dto.py +113 -0
  429. northrays_api_client_async/models/replace_request.py +107 -0
  430. northrays_api_client_async/models/replace_result.py +107 -0
  431. northrays_api_client_async/models/resize_sandbox.py +108 -0
  432. northrays_api_client_async/models/runner.py +166 -0
  433. northrays_api_client_async/models/runner_class.py +42 -0
  434. northrays_api_client_async/models/runner_full.py +171 -0
  435. northrays_api_client_async/models/runner_health_metrics.py +129 -0
  436. northrays_api_client_async/models/runner_healthcheck.py +125 -0
  437. northrays_api_client_async/models/runner_service_health.py +107 -0
  438. northrays_api_client_async/models/runner_snapshot_dto.py +107 -0
  439. northrays_api_client_async/models/runner_state.py +46 -0
  440. northrays_api_client_async/models/sandbox.py +188 -0
  441. northrays_api_client_async/models/sandbox_class.py +45 -0
  442. northrays_api_client_async/models/sandbox_desired_state.py +47 -0
  443. northrays_api_client_async/models/sandbox_labels.py +103 -0
  444. northrays_api_client_async/models/sandbox_list_item.py +161 -0
  445. northrays_api_client_async/models/sandbox_list_sort_direction.py +43 -0
  446. northrays_api_client_async/models/sandbox_list_sort_field.py +47 -0
  447. northrays_api_client_async/models/sandbox_state.py +63 -0
  448. northrays_api_client_async/models/sandbox_volume.py +107 -0
  449. northrays_api_client_async/models/screenshot_response.py +107 -0
  450. northrays_api_client_async/models/search_files_response.py +103 -0
  451. northrays_api_client_async/models/send_webhook_dto.py +108 -0
  452. northrays_api_client_async/models/session.py +118 -0
  453. northrays_api_client_async/models/session_execute_request.py +107 -0
  454. northrays_api_client_async/models/session_execute_response.py +107 -0
  455. northrays_api_client_async/models/set_snapshot_general_status_dto.py +103 -0
  456. northrays_api_client_async/models/signed_port_preview_url.py +109 -0
  457. northrays_api_client_async/models/snapshot_dto.py +172 -0
  458. northrays_api_client_async/models/snapshot_manager_credentials.py +105 -0
  459. northrays_api_client_async/models/snapshot_state.py +49 -0
  460. northrays_api_client_async/models/ssh_access_dto.py +116 -0
  461. northrays_api_client_async/models/ssh_access_validation_dto.py +105 -0
  462. northrays_api_client_async/models/storage_access_dto.py +113 -0
  463. northrays_api_client_async/models/toolbox_proxy_url.py +103 -0
  464. northrays_api_client_async/models/trace_span.py +119 -0
  465. northrays_api_client_async/models/trace_summary.py +115 -0
  466. northrays_api_client_async/models/update_docker_registry.py +111 -0
  467. northrays_api_client_async/models/update_job_status.py +108 -0
  468. northrays_api_client_async/models/update_organization_default_region.py +103 -0
  469. northrays_api_client_async/models/update_organization_invitation.py +108 -0
  470. northrays_api_client_async/models/update_organization_member_access.py +105 -0
  471. northrays_api_client_async/models/update_organization_quota.py +192 -0
  472. northrays_api_client_async/models/update_organization_region_quota.py +189 -0
  473. northrays_api_client_async/models/update_organization_role.py +107 -0
  474. northrays_api_client_async/models/update_region.py +122 -0
  475. northrays_api_client_async/models/update_sandbox_network_settings.py +107 -0
  476. northrays_api_client_async/models/update_sandbox_state_dto.py +107 -0
  477. northrays_api_client_async/models/url.py +103 -0
  478. northrays_api_client_async/models/user.py +120 -0
  479. northrays_api_client_async/models/user_home_dir_response.py +103 -0
  480. northrays_api_client_async/models/user_public_key.py +105 -0
  481. northrays_api_client_async/models/volume_dto.py +128 -0
  482. northrays_api_client_async/models/volume_state.py +48 -0
  483. northrays_api_client_async/models/webhook_app_portal_access.py +105 -0
  484. northrays_api_client_async/models/webhook_event.py +48 -0
  485. northrays_api_client_async/models/webhook_initialization_status.py +123 -0
  486. northrays_api_client_async/models/windows_response.py +105 -0
  487. northrays_api_client_async/models/work_dir_response.py +103 -0
  488. northrays_api_client_async/py.typed +0 -0
  489. northrays_api_client_async/rest.py +227 -0
  490. northrays_toolbox_api_client/__init__.py +386 -0
  491. northrays_toolbox_api_client/api/__init__.py +46 -0
  492. northrays_toolbox_api_client/api/computer_use_api.py +9075 -0
  493. northrays_toolbox_api_client/api/file_system_api.py +3583 -0
  494. northrays_toolbox_api_client/api/git_api.py +2969 -0
  495. northrays_toolbox_api_client/api/info_api.py +773 -0
  496. northrays_toolbox_api_client/api/interpreter_api.py +1075 -0
  497. northrays_toolbox_api_client/api/lsp_api.py +1971 -0
  498. northrays_toolbox_api_client/api/port_api.py +543 -0
  499. northrays_toolbox_api_client/api/process_api.py +4865 -0
  500. northrays_toolbox_api_client/api/server_api.py +298 -0
  501. northrays_toolbox_api_client/api_client.py +809 -0
  502. northrays_toolbox_api_client/api_response.py +21 -0
  503. northrays_toolbox_api_client/configuration.py +626 -0
  504. northrays_toolbox_api_client/exceptions.py +218 -0
  505. northrays_toolbox_api_client/models/__init__.py +224 -0
  506. northrays_toolbox_api_client/models/accessibility_bounds.py +108 -0
  507. northrays_toolbox_api_client/models/accessibility_invoke_request.py +104 -0
  508. northrays_toolbox_api_client/models/accessibility_node_request.py +102 -0
  509. northrays_toolbox_api_client/models/accessibility_nodes_response.py +112 -0
  510. northrays_toolbox_api_client/models/accessibility_set_value_request.py +104 -0
  511. northrays_toolbox_api_client/models/accessibility_tree_response.py +108 -0
  512. northrays_toolbox_api_client/models/chart.py +132 -0
  513. northrays_toolbox_api_client/models/chart_element.py +134 -0
  514. northrays_toolbox_api_client/models/code_run_artifacts.py +110 -0
  515. northrays_toolbox_api_client/models/code_run_request.py +110 -0
  516. northrays_toolbox_api_client/models/code_run_response.py +110 -0
  517. northrays_toolbox_api_client/models/command.py +106 -0
  518. northrays_toolbox_api_client/models/completion_context.py +104 -0
  519. northrays_toolbox_api_client/models/completion_item.py +114 -0
  520. northrays_toolbox_api_client/models/completion_list.py +112 -0
  521. northrays_toolbox_api_client/models/computer_use_accessibility_node.py +129 -0
  522. northrays_toolbox_api_client/models/computer_use_start_response.py +117 -0
  523. northrays_toolbox_api_client/models/computer_use_status_response.py +102 -0
  524. northrays_toolbox_api_client/models/computer_use_stop_response.py +117 -0
  525. northrays_toolbox_api_client/models/create_context_request.py +104 -0
  526. northrays_toolbox_api_client/models/create_session_request.py +102 -0
  527. northrays_toolbox_api_client/models/display_info.py +112 -0
  528. northrays_toolbox_api_client/models/display_info_response.py +110 -0
  529. northrays_toolbox_api_client/models/execute_request.py +108 -0
  530. northrays_toolbox_api_client/models/execute_response.py +104 -0
  531. northrays_toolbox_api_client/models/file_info.py +118 -0
  532. northrays_toolbox_api_client/models/file_status.py +109 -0
  533. northrays_toolbox_api_client/models/files_download_request.py +102 -0
  534. northrays_toolbox_api_client/models/find_accessibility_nodes_request.py +114 -0
  535. northrays_toolbox_api_client/models/git_add_request.py +104 -0
  536. northrays_toolbox_api_client/models/git_branch_request.py +104 -0
  537. northrays_toolbox_api_client/models/git_checkout_request.py +104 -0
  538. northrays_toolbox_api_client/models/git_clone_request.py +114 -0
  539. northrays_toolbox_api_client/models/git_commit_info.py +110 -0
  540. northrays_toolbox_api_client/models/git_commit_request.py +110 -0
  541. northrays_toolbox_api_client/models/git_commit_response.py +102 -0
  542. northrays_toolbox_api_client/models/git_delete_branch_request.py +104 -0
  543. northrays_toolbox_api_client/models/git_repo_request.py +106 -0
  544. northrays_toolbox_api_client/models/git_status.py +118 -0
  545. northrays_toolbox_api_client/models/initialize_request.py +102 -0
  546. northrays_toolbox_api_client/models/interpreter_context.py +110 -0
  547. northrays_toolbox_api_client/models/is_port_in_use_response.py +102 -0
  548. northrays_toolbox_api_client/models/keyboard_hotkey_request.py +102 -0
  549. northrays_toolbox_api_client/models/keyboard_press_request.py +104 -0
  550. northrays_toolbox_api_client/models/keyboard_type_request.py +104 -0
  551. northrays_toolbox_api_client/models/list_branch_response.py +102 -0
  552. northrays_toolbox_api_client/models/list_contexts_response.py +110 -0
  553. northrays_toolbox_api_client/models/list_recordings_response.py +110 -0
  554. northrays_toolbox_api_client/models/lsp_completion_params.py +118 -0
  555. northrays_toolbox_api_client/models/lsp_document_request.py +106 -0
  556. northrays_toolbox_api_client/models/lsp_location.py +108 -0
  557. northrays_toolbox_api_client/models/lsp_position.py +104 -0
  558. northrays_toolbox_api_client/models/lsp_range.py +111 -0
  559. northrays_toolbox_api_client/models/lsp_server_request.py +104 -0
  560. northrays_toolbox_api_client/models/lsp_symbol.py +110 -0
  561. northrays_toolbox_api_client/models/match.py +106 -0
  562. northrays_toolbox_api_client/models/mouse_click_request.py +108 -0
  563. northrays_toolbox_api_client/models/mouse_click_response.py +104 -0
  564. northrays_toolbox_api_client/models/mouse_drag_request.py +110 -0
  565. northrays_toolbox_api_client/models/mouse_drag_response.py +104 -0
  566. northrays_toolbox_api_client/models/mouse_move_request.py +104 -0
  567. northrays_toolbox_api_client/models/mouse_position_response.py +104 -0
  568. northrays_toolbox_api_client/models/mouse_scroll_request.py +109 -0
  569. northrays_toolbox_api_client/models/port_list.py +102 -0
  570. northrays_toolbox_api_client/models/position.py +104 -0
  571. northrays_toolbox_api_client/models/process_errors_response.py +104 -0
  572. northrays_toolbox_api_client/models/process_logs_response.py +104 -0
  573. northrays_toolbox_api_client/models/process_restart_response.py +104 -0
  574. northrays_toolbox_api_client/models/process_status.py +108 -0
  575. northrays_toolbox_api_client/models/process_status_response.py +104 -0
  576. northrays_toolbox_api_client/models/pty_create_request.py +112 -0
  577. northrays_toolbox_api_client/models/pty_create_response.py +102 -0
  578. northrays_toolbox_api_client/models/pty_list_response.py +110 -0
  579. northrays_toolbox_api_client/models/pty_resize_request.py +105 -0
  580. northrays_toolbox_api_client/models/pty_session_info.py +116 -0
  581. northrays_toolbox_api_client/models/recording.py +116 -0
  582. northrays_toolbox_api_client/models/replace_request.py +106 -0
  583. northrays_toolbox_api_client/models/replace_result.py +106 -0
  584. northrays_toolbox_api_client/models/screenshot_response.py +110 -0
  585. northrays_toolbox_api_client/models/scroll_response.py +102 -0
  586. northrays_toolbox_api_client/models/search_files_response.py +102 -0
  587. northrays_toolbox_api_client/models/session.py +112 -0
  588. northrays_toolbox_api_client/models/session_command_logs_response.py +106 -0
  589. northrays_toolbox_api_client/models/session_execute_request.py +108 -0
  590. northrays_toolbox_api_client/models/session_execute_response.py +110 -0
  591. northrays_toolbox_api_client/models/session_send_input_request.py +102 -0
  592. northrays_toolbox_api_client/models/start_recording_request.py +102 -0
  593. northrays_toolbox_api_client/models/status.py +48 -0
  594. northrays_toolbox_api_client/models/stop_recording_request.py +102 -0
  595. northrays_toolbox_api_client/models/user_home_dir_response.py +102 -0
  596. northrays_toolbox_api_client/models/window_info.py +114 -0
  597. northrays_toolbox_api_client/models/windows_response.py +110 -0
  598. northrays_toolbox_api_client/models/work_dir_response.py +102 -0
  599. northrays_toolbox_api_client/py.typed +0 -0
  600. northrays_toolbox_api_client/rest.py +263 -0
  601. northrays_toolbox_api_client_async/__init__.py +386 -0
  602. northrays_toolbox_api_client_async/api/__init__.py +46 -0
  603. northrays_toolbox_api_client_async/api/computer_use_api.py +9075 -0
  604. northrays_toolbox_api_client_async/api/file_system_api.py +3583 -0
  605. northrays_toolbox_api_client_async/api/git_api.py +2969 -0
  606. northrays_toolbox_api_client_async/api/info_api.py +773 -0
  607. northrays_toolbox_api_client_async/api/interpreter_api.py +1075 -0
  608. northrays_toolbox_api_client_async/api/lsp_api.py +1971 -0
  609. northrays_toolbox_api_client_async/api/port_api.py +543 -0
  610. northrays_toolbox_api_client_async/api/process_api.py +4865 -0
  611. northrays_toolbox_api_client_async/api/server_api.py +298 -0
  612. northrays_toolbox_api_client_async/api_client.py +812 -0
  613. northrays_toolbox_api_client_async/api_response.py +21 -0
  614. northrays_toolbox_api_client_async/configuration.py +624 -0
  615. northrays_toolbox_api_client_async/exceptions.py +218 -0
  616. northrays_toolbox_api_client_async/models/__init__.py +224 -0
  617. northrays_toolbox_api_client_async/models/accessibility_bounds.py +108 -0
  618. northrays_toolbox_api_client_async/models/accessibility_invoke_request.py +104 -0
  619. northrays_toolbox_api_client_async/models/accessibility_node_request.py +102 -0
  620. northrays_toolbox_api_client_async/models/accessibility_nodes_response.py +112 -0
  621. northrays_toolbox_api_client_async/models/accessibility_set_value_request.py +104 -0
  622. northrays_toolbox_api_client_async/models/accessibility_tree_response.py +108 -0
  623. northrays_toolbox_api_client_async/models/chart.py +132 -0
  624. northrays_toolbox_api_client_async/models/chart_element.py +134 -0
  625. northrays_toolbox_api_client_async/models/code_run_artifacts.py +110 -0
  626. northrays_toolbox_api_client_async/models/code_run_request.py +110 -0
  627. northrays_toolbox_api_client_async/models/code_run_response.py +110 -0
  628. northrays_toolbox_api_client_async/models/command.py +106 -0
  629. northrays_toolbox_api_client_async/models/completion_context.py +104 -0
  630. northrays_toolbox_api_client_async/models/completion_item.py +114 -0
  631. northrays_toolbox_api_client_async/models/completion_list.py +112 -0
  632. northrays_toolbox_api_client_async/models/computer_use_accessibility_node.py +129 -0
  633. northrays_toolbox_api_client_async/models/computer_use_start_response.py +117 -0
  634. northrays_toolbox_api_client_async/models/computer_use_status_response.py +102 -0
  635. northrays_toolbox_api_client_async/models/computer_use_stop_response.py +117 -0
  636. northrays_toolbox_api_client_async/models/create_context_request.py +104 -0
  637. northrays_toolbox_api_client_async/models/create_session_request.py +102 -0
  638. northrays_toolbox_api_client_async/models/display_info.py +112 -0
  639. northrays_toolbox_api_client_async/models/display_info_response.py +110 -0
  640. northrays_toolbox_api_client_async/models/execute_request.py +108 -0
  641. northrays_toolbox_api_client_async/models/execute_response.py +104 -0
  642. northrays_toolbox_api_client_async/models/file_info.py +118 -0
  643. northrays_toolbox_api_client_async/models/file_status.py +109 -0
  644. northrays_toolbox_api_client_async/models/files_download_request.py +102 -0
  645. northrays_toolbox_api_client_async/models/find_accessibility_nodes_request.py +114 -0
  646. northrays_toolbox_api_client_async/models/git_add_request.py +104 -0
  647. northrays_toolbox_api_client_async/models/git_branch_request.py +104 -0
  648. northrays_toolbox_api_client_async/models/git_checkout_request.py +104 -0
  649. northrays_toolbox_api_client_async/models/git_clone_request.py +114 -0
  650. northrays_toolbox_api_client_async/models/git_commit_info.py +110 -0
  651. northrays_toolbox_api_client_async/models/git_commit_request.py +110 -0
  652. northrays_toolbox_api_client_async/models/git_commit_response.py +102 -0
  653. northrays_toolbox_api_client_async/models/git_delete_branch_request.py +104 -0
  654. northrays_toolbox_api_client_async/models/git_repo_request.py +106 -0
  655. northrays_toolbox_api_client_async/models/git_status.py +118 -0
  656. northrays_toolbox_api_client_async/models/initialize_request.py +102 -0
  657. northrays_toolbox_api_client_async/models/interpreter_context.py +110 -0
  658. northrays_toolbox_api_client_async/models/is_port_in_use_response.py +102 -0
  659. northrays_toolbox_api_client_async/models/keyboard_hotkey_request.py +102 -0
  660. northrays_toolbox_api_client_async/models/keyboard_press_request.py +104 -0
  661. northrays_toolbox_api_client_async/models/keyboard_type_request.py +104 -0
  662. northrays_toolbox_api_client_async/models/list_branch_response.py +102 -0
  663. northrays_toolbox_api_client_async/models/list_contexts_response.py +110 -0
  664. northrays_toolbox_api_client_async/models/list_recordings_response.py +110 -0
  665. northrays_toolbox_api_client_async/models/lsp_completion_params.py +118 -0
  666. northrays_toolbox_api_client_async/models/lsp_document_request.py +106 -0
  667. northrays_toolbox_api_client_async/models/lsp_location.py +108 -0
  668. northrays_toolbox_api_client_async/models/lsp_position.py +104 -0
  669. northrays_toolbox_api_client_async/models/lsp_range.py +111 -0
  670. northrays_toolbox_api_client_async/models/lsp_server_request.py +104 -0
  671. northrays_toolbox_api_client_async/models/lsp_symbol.py +110 -0
  672. northrays_toolbox_api_client_async/models/match.py +106 -0
  673. northrays_toolbox_api_client_async/models/mouse_click_request.py +108 -0
  674. northrays_toolbox_api_client_async/models/mouse_click_response.py +104 -0
  675. northrays_toolbox_api_client_async/models/mouse_drag_request.py +110 -0
  676. northrays_toolbox_api_client_async/models/mouse_drag_response.py +104 -0
  677. northrays_toolbox_api_client_async/models/mouse_move_request.py +104 -0
  678. northrays_toolbox_api_client_async/models/mouse_position_response.py +104 -0
  679. northrays_toolbox_api_client_async/models/mouse_scroll_request.py +109 -0
  680. northrays_toolbox_api_client_async/models/port_list.py +102 -0
  681. northrays_toolbox_api_client_async/models/position.py +104 -0
  682. northrays_toolbox_api_client_async/models/process_errors_response.py +104 -0
  683. northrays_toolbox_api_client_async/models/process_logs_response.py +104 -0
  684. northrays_toolbox_api_client_async/models/process_restart_response.py +104 -0
  685. northrays_toolbox_api_client_async/models/process_status.py +108 -0
  686. northrays_toolbox_api_client_async/models/process_status_response.py +104 -0
  687. northrays_toolbox_api_client_async/models/pty_create_request.py +112 -0
  688. northrays_toolbox_api_client_async/models/pty_create_response.py +102 -0
  689. northrays_toolbox_api_client_async/models/pty_list_response.py +110 -0
  690. northrays_toolbox_api_client_async/models/pty_resize_request.py +105 -0
  691. northrays_toolbox_api_client_async/models/pty_session_info.py +116 -0
  692. northrays_toolbox_api_client_async/models/recording.py +116 -0
  693. northrays_toolbox_api_client_async/models/replace_request.py +106 -0
  694. northrays_toolbox_api_client_async/models/replace_result.py +106 -0
  695. northrays_toolbox_api_client_async/models/screenshot_response.py +110 -0
  696. northrays_toolbox_api_client_async/models/scroll_response.py +102 -0
  697. northrays_toolbox_api_client_async/models/search_files_response.py +102 -0
  698. northrays_toolbox_api_client_async/models/session.py +112 -0
  699. northrays_toolbox_api_client_async/models/session_command_logs_response.py +106 -0
  700. northrays_toolbox_api_client_async/models/session_execute_request.py +108 -0
  701. northrays_toolbox_api_client_async/models/session_execute_response.py +110 -0
  702. northrays_toolbox_api_client_async/models/session_send_input_request.py +102 -0
  703. northrays_toolbox_api_client_async/models/start_recording_request.py +102 -0
  704. northrays_toolbox_api_client_async/models/status.py +48 -0
  705. northrays_toolbox_api_client_async/models/stop_recording_request.py +102 -0
  706. northrays_toolbox_api_client_async/models/user_home_dir_response.py +102 -0
  707. northrays_toolbox_api_client_async/models/window_info.py +114 -0
  708. northrays_toolbox_api_client_async/models/windows_response.py +110 -0
  709. northrays_toolbox_api_client_async/models/work_dir_response.py +102 -0
  710. northrays_toolbox_api_client_async/py.typed +0 -0
  711. northrays_toolbox_api_client_async/rest.py +226 -0
@@ -0,0 +1,1240 @@
1
+ # Copyright 2025 Daytona Platforms Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from __future__ import annotations
4
+
5
+ import inspect
6
+ import io
7
+ import os
8
+ import secrets
9
+ from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Callable
10
+ from contextlib import ExitStack
11
+ from typing import Any, cast, final, overload
12
+
13
+ import aiofiles
14
+ import aiofiles.os
15
+ import aiohttp
16
+ import httpx
17
+ from aiofiles.threadpool.binary import AsyncBufferedIOBase
18
+ from python_multipart.multipart import MultipartParser, parse_options_header
19
+ from typing_extensions import override
20
+
21
+ from northrays_toolbox_api_client_async import (
22
+ FileInfo,
23
+ FilesDownloadRequest,
24
+ FileSystemApi,
25
+ Match,
26
+ ReplaceRequest,
27
+ ReplaceResult,
28
+ SearchFilesResponse,
29
+ )
30
+
31
+ from .._utils.errors import intercept_errors
32
+ from .._utils.otel_decorator import with_instrumentation
33
+ from ..common.errors import NorthraysError
34
+ from ..common.file_transfer import (
35
+ create_multipart_parser,
36
+ parse_content_type_boundary,
37
+ raise_if_multipart_truncated,
38
+ serialize_download_request,
39
+ )
40
+ from ..common.filesystem import (
41
+ CancelEvent,
42
+ DownloadProgress,
43
+ FileDownloadErrorDetails,
44
+ FileDownloadRequest,
45
+ FileDownloadResponse,
46
+ FileUpload,
47
+ UploadProgress,
48
+ create_file_download_error,
49
+ parse_file_download_error_payload,
50
+ raise_if_stream_error,
51
+ )
52
+ from ..internal.http_client import aiohttp_request_timeout as _request_timeout
53
+ from ..internal.shared_session import http_session_of
54
+
55
+
56
+ class AsyncFileSystem:
57
+ """Provides file system operations within a Sandbox.
58
+
59
+ This class implements a high-level interface to file system operations that can
60
+ be performed within a Northrays Sandbox.
61
+ """
62
+
63
+ def __init__(
64
+ self,
65
+ api_client: FileSystemApi,
66
+ ):
67
+ """Initializes a new FileSystem instance.
68
+
69
+ Args:
70
+ api_client (FileSystemApi): API client for Sandbox file system operations.
71
+ """
72
+ self._api_client: FileSystemApi = api_client
73
+
74
+ @intercept_errors(message_prefix="Failed to create folder: ")
75
+ @with_instrumentation()
76
+ async def create_folder(self, path: str, mode: str) -> None:
77
+ """Creates a new directory in the Sandbox at the specified path with the given
78
+ permissions.
79
+
80
+ Args:
81
+ path (str): Path where the folder should be created. Relative paths are resolved based
82
+ on the sandbox working directory.
83
+ mode (str): Folder permissions in octal format (e.g., "755" for rwxr-xr-x).
84
+
85
+ Example:
86
+ ```python
87
+ # Create a directory with standard permissions
88
+ await sandbox.fs.create_folder("workspace/data", "755")
89
+
90
+ # Create a private directory
91
+ await sandbox.fs.create_folder("workspace/secrets", "700")
92
+ ```
93
+ """
94
+ await self._api_client.create_folder(
95
+ path=path,
96
+ mode=mode,
97
+ )
98
+
99
+ @intercept_errors(message_prefix="Failed to delete file: ")
100
+ @with_instrumentation()
101
+ async def delete_file(self, path: str, recursive: bool = False) -> None:
102
+ """Deletes a file from the Sandbox.
103
+
104
+ Args:
105
+ path (str): Path to the file to delete. Relative paths are resolved based on the sandbox working directory.
106
+ recursive (bool): If the file is a directory, this must be true to delete it.
107
+
108
+ Example:
109
+ ```python
110
+ # Delete a file
111
+ await sandbox.fs.delete_file("workspace/data/old_file.txt")
112
+ ```
113
+ """
114
+ await self._api_client.delete_file(path=path, recursive=recursive)
115
+
116
+ @overload
117
+ async def download_file(self, remote_path: str, timeout: int = 30 * 60) -> bytes:
118
+ """Downloads a file from the Sandbox. Returns the file contents as a bytes object.
119
+ This method is useful when you want to load the file into memory without saving it to disk.
120
+ It can only be used for smaller files.
121
+
122
+ Args:
123
+ remote_path (str): Path to the file in the Sandbox. Relative paths are resolved based
124
+ on the sandbox working directory.
125
+ timeout (int): Timeout for the download operation in seconds. 0 means no timeout. Default is 30 minutes.
126
+
127
+ Returns:
128
+ bytes: The file contents as a bytes object.
129
+
130
+ Example:
131
+ ```python
132
+ # Download and save a file locally
133
+ content = await sandbox.fs.download_file("workspace/data/file.txt")
134
+ with open("local_copy.txt", "wb") as f:
135
+ f.write(content)
136
+
137
+ # Download and process text content
138
+ content = await sandbox.fs.download_file("workspace/data/config.json")
139
+ config = json.loads(content.decode('utf-8'))
140
+ ```
141
+ """
142
+
143
+ @overload
144
+ async def download_file(self, remote_path: str, local_path: str, timeout: int = 30 * 60) -> None:
145
+ """Downloads a file from the Sandbox and saves it to a local file using stream.
146
+ This method is useful when you want to download larger files that may not fit into memory.
147
+
148
+ Args:
149
+ remote_path (str): Path to the file in the Sandbox. Relative paths are resolved based
150
+ on the sandbox working directory.
151
+ local_path (str): Path to save the file locally.
152
+ timeout (int): Timeout for the download operation in seconds. 0 means no timeout. Default is 30 minutes.
153
+
154
+ Example:
155
+ ```python
156
+ local_path = "local_copy.txt"
157
+ await sandbox.fs.download_file("tmp/large_file.txt", local_path)
158
+ size_mb = os.path.getsize(local_path) / 1024 / 1024
159
+ print(f"Size of the downloaded file {local_path}: {size_mb} MB")
160
+ ```
161
+ """
162
+
163
+ @intercept_errors(message_prefix="Failed to download file: ")
164
+ @with_instrumentation()
165
+ async def download_file(self, *args: str) -> bytes | None: # pyright: ignore[reportInconsistentOverload]
166
+ if len(args) == 1 or (len(args) == 2 and isinstance(args[1], int)):
167
+ remote_path = args[0]
168
+ timeout = int(args[1]) if len(args) == 2 else 30 * 60
169
+ response = (await self.download_files([FileDownloadRequest(source=remote_path)], timeout=timeout))[0]
170
+ if response.error:
171
+ raise create_file_download_error(response)
172
+ result = response.result
173
+ if isinstance(result, str):
174
+ result = result.encode("utf-8")
175
+ return result
176
+
177
+ remote_path = args[0]
178
+ local_path = args[1]
179
+ timeout = int(args[2]) if len(args) == 3 else 30 * 60
180
+ response = (
181
+ await self.download_files(
182
+ [FileDownloadRequest(source=remote_path, destination=local_path)], timeout=timeout
183
+ )
184
+ )[0]
185
+ if response.error:
186
+ raise create_file_download_error(response)
187
+ return None
188
+
189
+ @intercept_errors(message_prefix="Failed to download file: ")
190
+ @with_instrumentation()
191
+ async def download_file_stream(
192
+ self,
193
+ remote_path: str,
194
+ timeout: int = 30 * 60,
195
+ on_progress: Callable[[DownloadProgress], Awaitable[None] | None] | None = None,
196
+ cancel_event: CancelEvent | None = None,
197
+ ) -> AsyncIterator[bytes]:
198
+ """Downloads a single file from the Sandbox as a stream without buffering the entire file
199
+ into memory. Returns an async iterator that yields file content in chunks, which can be piped
200
+ directly to an HTTP response, written to a file incrementally, or processed on the fly.
201
+
202
+ Args:
203
+ remote_path (str): Path to the file in the Sandbox. Relative paths are resolved based
204
+ on the sandbox working directory.
205
+ timeout (int): Timeout for the download operation in seconds. 0 means no timeout.
206
+ Default is 30 minutes.
207
+ on_progress (Callable[[DownloadProgress], Awaitable[None] | None] | None): Optional
208
+ callback invoked with cumulative bytes received and total bytes, when known, as
209
+ the download progresses. May be either a regular function or an ``async def``
210
+ coroutine — coroutine returns are awaited before the next chunk is yielded.
211
+ Default is None.
212
+ cancel_event (CancelEvent | None): Optional ``asyncio.Event``-compatible token. When
213
+ set during streaming, the next chunk raises ``NorthraysError`` and the underlying
214
+ HTTP connection is closed. Standard ``asyncio.CancelledError`` from task
215
+ cancellation is also honoured automatically by the generator.
216
+
217
+ Returns:
218
+ AsyncIterator[bytes]: An async iterator yielding chunks of file content as bytes.
219
+
220
+ Raises:
221
+ NorthraysError: If the file does not exist, access is denied, or the download is
222
+ cancelled via ``cancel_event``.
223
+
224
+ Example:
225
+ ```python
226
+ # Stream to a local file without loading into memory
227
+ async with aiofiles.open("local_copy.bin", "wb") as f:
228
+ async for chunk in await sandbox.fs.download_file_stream("workspace/large-file.bin"):
229
+ await f.write(chunk)
230
+
231
+ # Cancel a download from another coroutine
232
+ import asyncio
233
+ cancel = asyncio.Event()
234
+ asyncio.get_running_loop().call_later(5.0, cancel.set)
235
+ async for chunk in await sandbox.fs.download_file_stream("workspace/big.bin", cancel_event=cancel):
236
+ process(chunk)
237
+ ```
238
+ """
239
+
240
+ async def stream_generator() -> AsyncIterator[bytes]:
241
+ method, url, headers, body = serialize_download_request(self._api_client, remote_path)
242
+
243
+ mode: str | None = None
244
+ part_content_type: str | None = None
245
+ header_field = bytearray()
246
+ header_value = bytearray()
247
+ part_headers: dict[str, str] = {}
248
+ error_buffer = bytearray()
249
+ pending_chunks: list[bytes] = []
250
+ error_text: str | None = None
251
+ error_details: FileDownloadErrorDetails | None = None
252
+ received_file_data = False
253
+ bytes_received = 0
254
+ total_bytes: int | None = None
255
+
256
+ def on_part_begin() -> None:
257
+ nonlocal total_bytes
258
+ part_headers.clear()
259
+ header_field.clear()
260
+ header_value.clear()
261
+ error_buffer.clear()
262
+ total_bytes = None
263
+
264
+ def on_header_field(data: bytes, start: int, end: int) -> None:
265
+ header_field.extend(data[start:end])
266
+
267
+ def on_header_value(data: bytes, start: int, end: int) -> None:
268
+ header_value.extend(data[start:end])
269
+
270
+ def on_header_end() -> None:
271
+ field = bytes(header_field).decode("utf-8", errors="ignore").lower()
272
+ value = bytes(header_value).decode("utf-8", errors="ignore")
273
+ part_headers[field] = value
274
+ header_field.clear()
275
+ header_value.clear()
276
+
277
+ def on_headers_finished() -> None:
278
+ nonlocal mode, part_content_type, total_bytes
279
+ cd = part_headers.get("content-disposition", "")
280
+ _, cd_params = parse_options_header(cd)
281
+ name = cd_params.get(b"name", b"").decode("utf-8", errors="ignore")
282
+ if not cd_params.get(b"filename"):
283
+ raise NorthraysError("No source path found for this file")
284
+ part_content_type = part_headers.get("content-type")
285
+ cl = part_headers.get("content-length")
286
+ if cl is not None:
287
+ try:
288
+ total_bytes = int(cl)
289
+ except (TypeError, ValueError):
290
+ total_bytes = None
291
+ else:
292
+ total_bytes = None
293
+ mode = name if name in ("file", "error") else None
294
+
295
+ def on_part_data(data: bytes, start: int, end: int) -> None:
296
+ if mode == "error":
297
+ error_buffer.extend(data[start:end])
298
+ elif mode == "file":
299
+ pending_chunks.append(bytes(data[start:end]))
300
+
301
+ def on_part_end() -> None:
302
+ nonlocal mode, part_content_type, error_text, error_details
303
+ if mode == "error" and error_buffer:
304
+ error_text, error_details = parse_file_download_error_payload(
305
+ bytes(error_buffer),
306
+ part_content_type,
307
+ )
308
+ error_buffer.clear()
309
+ mode = None
310
+ part_content_type = None
311
+
312
+ async def drain() -> AsyncIterator[bytes]:
313
+ nonlocal received_file_data, bytes_received
314
+ if not pending_chunks:
315
+ return
316
+ if cancel_event is not None and cancel_event.is_set():
317
+ raise NorthraysError(f"Download cancelled: {remote_path}")
318
+ emitted = pending_chunks.copy()
319
+ pending_chunks.clear()
320
+ received_file_data = True
321
+ for piece in emitted:
322
+ bytes_received += len(piece)
323
+ if on_progress is not None:
324
+ progress = DownloadProgress(bytes_received=bytes_received, total_bytes=total_bytes)
325
+ if inspect.iscoroutinefunction(on_progress):
326
+ await on_progress(progress)
327
+ else:
328
+ _ = on_progress(progress)
329
+ yield piece
330
+
331
+ async with http_session_of(self._api_client.api_client).request(
332
+ method,
333
+ url,
334
+ json=body,
335
+ headers=headers,
336
+ timeout=_request_timeout(timeout),
337
+ ) as resp:
338
+ resp.raise_for_status()
339
+
340
+ boundary = parse_content_type_boundary(resp.headers)
341
+ parser = create_multipart_parser(
342
+ boundary,
343
+ on_part_begin,
344
+ on_header_field,
345
+ on_header_value,
346
+ on_header_end,
347
+ on_headers_finished,
348
+ on_part_data,
349
+ on_part_end,
350
+ )
351
+
352
+ async for chunk in resp.content.iter_chunked(64 * 1024):
353
+ _ = parser.write(chunk)
354
+ async for piece in drain():
355
+ yield piece
356
+
357
+ parser.finalize()
358
+ async for piece in drain():
359
+ yield piece
360
+ raise_if_multipart_truncated(parser, remote_path)
361
+
362
+ raise_if_stream_error(remote_path, error_text, error_details, received_file_data)
363
+
364
+ return stream_generator()
365
+
366
+ @intercept_errors(message_prefix="Failed to download files: ")
367
+ @with_instrumentation()
368
+ async def download_files(
369
+ self, files: list[FileDownloadRequest], timeout: int = 30 * 60
370
+ ) -> list[FileDownloadResponse]:
371
+ """Downloads multiple files from the Sandbox. If the files already exist locally, they will be overwritten.
372
+
373
+ Args:
374
+ files (list[FileDownloadRequest]): List of files to download.
375
+ timeout (int): Timeout for the download operation in seconds. 0 means no timeout. Default is 30 minutes.
376
+
377
+ Returns:
378
+ list[FileDownloadResponse]: List of download results.
379
+
380
+ Raises:
381
+ Exception: Only if the request itself fails (network issues, invalid request/response, etc.). Individual
382
+ file download errors are returned in `FileDownloadResponse.error`. When the daemon provides structured
383
+ per-file metadata, it is also available in `FileDownloadResponse.error_details`.
384
+
385
+ Example:
386
+ ```python
387
+ # Download multiple files
388
+ results = await sandbox.fs.download_files([
389
+ FileDownloadRequest(source="tmp/data.json"),
390
+ FileDownloadRequest(source="tmp/config.json", destination="local_config.json")
391
+ ])
392
+ for result in results:
393
+ if result.error:
394
+ print(f"Error downloading {result.source}: {result.error}")
395
+ elif result.result:
396
+ print(f"Downloaded {result.source} to {result.result}")
397
+ ```
398
+ """
399
+ if not files:
400
+ return []
401
+
402
+ class FileMeta:
403
+ def __init__(self, dst: str | None):
404
+ self.dst: str | None = dst
405
+ self.error: str | None = None
406
+ self.error_details: FileDownloadErrorDetails | None = None
407
+ self.result: str | bytes | io.BytesIO | None = None
408
+
409
+ src_file_meta_dict: dict[str, FileMeta] = {}
410
+ file_writers: list[AsyncBufferedIOBase] = []
411
+ for f in files:
412
+ src_file_meta_dict[f.source] = FileMeta(dst=f.destination)
413
+
414
+ method, url, headers, body, *_ = self._api_client._download_files_serialize(
415
+ download_files=FilesDownloadRequest(paths=list(src_file_meta_dict.keys())),
416
+ _request_auth=None,
417
+ _content_type=None,
418
+ _headers=None,
419
+ _host_index=None,
420
+ )
421
+
422
+ try:
423
+ async with http_session_of(self._api_client.api_client).request(
424
+ method,
425
+ url,
426
+ json=body,
427
+ headers=headers,
428
+ timeout=_request_timeout(timeout),
429
+ ) as resp:
430
+ resp.raise_for_status()
431
+
432
+ content_type_raw, options = parse_options_header(resp.headers.get("Content-Type", ""))
433
+ if not (content_type_raw == b"multipart/form-data" and b"boundary" in options):
434
+ raise NorthraysError(f"Unexpected Content-Type: {content_type_raw!r}")
435
+ boundary = options[b"boundary"]
436
+
437
+ writer: io.BytesIO | AsyncBufferedIOBase | None = None
438
+ mode: str | None = None
439
+ part_content_type: str | None = None
440
+ source: str | None = None
441
+ header_field = bytearray()
442
+ header_value = bytearray()
443
+ pending_headers: list[tuple[str, str]] = []
444
+ error_buffer = bytearray()
445
+ events: list[tuple[str, Any]] = []
446
+
447
+ def on_part_begin() -> None:
448
+ pending_headers.clear()
449
+ header_field.clear()
450
+ header_value.clear()
451
+ events.append(("begin", None))
452
+
453
+ def on_header_field(data: bytes, start: int, end: int) -> None:
454
+ header_field.extend(data[start:end])
455
+
456
+ def on_header_value(data: bytes, start: int, end: int) -> None:
457
+ header_value.extend(data[start:end])
458
+
459
+ def on_header_end() -> None:
460
+ field = bytes(header_field).decode("utf-8", errors="ignore").lower()
461
+ value = bytes(header_value).decode("utf-8", errors="ignore")
462
+ pending_headers.append((field, value))
463
+ header_field.clear()
464
+ header_value.clear()
465
+
466
+ def on_headers_finished() -> None:
467
+ events.append(("headers_finished", dict(pending_headers)))
468
+
469
+ def on_part_data(data: bytes, start: int, end: int) -> None:
470
+ events.append(("data", bytes(data[start:end])))
471
+
472
+ def on_part_end() -> None:
473
+ events.append(("end", None))
474
+
475
+ parser = MultipartParser(
476
+ boundary,
477
+ callbacks={
478
+ "on_part_begin": on_part_begin,
479
+ "on_header_field": on_header_field,
480
+ "on_header_value": on_header_value,
481
+ "on_header_end": on_header_end,
482
+ "on_headers_finished": on_headers_finished,
483
+ "on_part_data": on_part_data,
484
+ "on_part_end": on_part_end,
485
+ },
486
+ )
487
+
488
+ async def _process_events() -> None:
489
+ nonlocal writer, mode, part_content_type, source
490
+ for event_tag, event_payload in events:
491
+ if event_tag == "begin":
492
+ error_buffer.clear()
493
+ writer = None
494
+ mode = None
495
+ part_content_type = None
496
+ source = None
497
+
498
+ elif event_tag == "headers_finished":
499
+ hdrs: dict[str, str] = event_payload
500
+ cd = hdrs.get("content-disposition", "")
501
+ _, cd_params = parse_options_header(cd)
502
+ name = cd_params.get(b"name", b"").decode("utf-8", errors="ignore")
503
+ source = cd_params.get(b"filename", b"").decode("utf-8", errors="ignore") or None
504
+ if not source:
505
+ raise NorthraysError("No source path found for this file")
506
+ part_content_type = hdrs.get("content-type")
507
+
508
+ if name == "error":
509
+ mode = "error"
510
+ elif name == "file":
511
+ mode = "file"
512
+ meta = src_file_meta_dict[source]
513
+ if meta.dst:
514
+ parent = os.path.dirname(meta.dst)
515
+ if parent:
516
+ await aiofiles.os.makedirs(parent, exist_ok=True)
517
+ # pylint: disable=consider-using-with
518
+ writer = await aiofiles.open(meta.dst, mode="wb")
519
+ file_writers.append(writer)
520
+ meta.result = meta.dst
521
+ else:
522
+ writer = io.BytesIO()
523
+ meta.result = writer
524
+
525
+ elif event_tag == "data":
526
+ part_data: bytes = event_payload
527
+ if mode == "error":
528
+ error_buffer.extend(part_data)
529
+ elif mode == "file":
530
+ try:
531
+ if isinstance(writer, io.BytesIO):
532
+ _ = writer.write(part_data)
533
+ elif writer:
534
+ _ = await writer.write(part_data)
535
+ except Exception as e:
536
+ if source:
537
+ src_file_meta_dict[source].error = f"Write failed: {e}"
538
+ else:
539
+ raise NorthraysError(f"Write failed for unknown file with error {e}") from e
540
+ mode = None
541
+
542
+ elif event_tag == "end":
543
+ if mode == "error" and error_buffer:
544
+ error_text, error_details = parse_file_download_error_payload(
545
+ bytes(error_buffer),
546
+ part_content_type,
547
+ )
548
+ if source:
549
+ src_file_meta_dict[source].error = error_text
550
+ src_file_meta_dict[source].error_details = error_details
551
+ else:
552
+ raise NorthraysError(f"Error happened for unknown file with error {error_text}")
553
+ error_buffer.clear()
554
+ if writer and not isinstance(writer, io.BytesIO):
555
+ await writer.close()
556
+ writer = None
557
+ mode = None
558
+ part_content_type = None
559
+ source = None
560
+
561
+ async for chunk in resp.content.iter_chunked(64 * 1024):
562
+ events.clear()
563
+ _ = parser.write(chunk)
564
+ await _process_events()
565
+
566
+ events.clear()
567
+ parser.finalize()
568
+ await _process_events()
569
+ raise_if_multipart_truncated(parser, "bulk-download")
570
+ finally:
571
+ for writer in file_writers:
572
+ await writer.close()
573
+
574
+ # Build results for all requested files
575
+ results: list[FileDownloadResponse] = []
576
+ for f in files:
577
+ meta = src_file_meta_dict[f.source]
578
+ # see if there's an explicit error; if not, but no data, set a default error
579
+ err = meta.error
580
+ if not err and not meta.result:
581
+ err = "No data received for this file"
582
+ # only fetch the value if there was no error
583
+ res = None
584
+ if err is None:
585
+ res = meta.result
586
+ if isinstance(res, io.BytesIO):
587
+ res = res.getvalue()
588
+ results.append(
589
+ FileDownloadResponse(
590
+ source=f.source,
591
+ result=res,
592
+ error=err,
593
+ error_details=meta.error_details,
594
+ )
595
+ )
596
+
597
+ return results
598
+
599
+ @intercept_errors(message_prefix="Failed to find files: ")
600
+ @with_instrumentation()
601
+ async def find_files(self, path: str, pattern: str) -> list[Match]:
602
+ """Searches for files containing a pattern, similar to
603
+ the grep command.
604
+
605
+ Args:
606
+ path (str): Path to the file or directory to search. If the path is a directory,
607
+ the search will be performed recursively. Relative paths are resolved based
608
+ on the sandbox working directory.
609
+ pattern (str): Search pattern to match against file contents.
610
+
611
+ Returns:
612
+ list[Match]: List of matches found in files. Each Match object includes:
613
+ - file: Path to the file containing the match
614
+ - line: The line number where the match was found
615
+ - content: The matching line content
616
+
617
+ Example:
618
+ ```python
619
+ # Search for TODOs in Python files
620
+ matches = await sandbox.fs.find_files("workspace/src", "TODO:")
621
+ for match in matches:
622
+ print(f"{match.file}:{match.line}: {match.content.strip()}")
623
+ ```
624
+ """
625
+ return await self._api_client.find_in_files(
626
+ path=path,
627
+ pattern=pattern,
628
+ )
629
+
630
+ @intercept_errors(message_prefix="Failed to get file info: ")
631
+ @with_instrumentation()
632
+ async def get_file_info(self, path: str) -> FileInfo:
633
+ """Gets detailed information about a file or directory, including its
634
+ size, permissions, and timestamps.
635
+
636
+ Args:
637
+ path (str): Path to the file or directory. Relative paths are resolved based
638
+ on the sandbox working directory.
639
+
640
+ Returns:
641
+ FileInfo: Detailed file information including:
642
+ - name: File name
643
+ - is_dir: Whether the path is a directory
644
+ - size: File size in bytes
645
+ - mode: File permissions
646
+ - mod_time: Last modification timestamp
647
+ - permissions: File permissions in octal format
648
+ - owner: File owner
649
+ - group: File group
650
+
651
+ Example:
652
+ ```python
653
+ # Get file metadata
654
+ info = await sandbox.fs.get_file_info("workspace/data/file.txt")
655
+ print(f"Size: {info.size} bytes")
656
+ print(f"Modified: {info.mod_time}")
657
+ print(f"Mode: {info.mode}")
658
+
659
+ # Check if path is a directory
660
+ info = await sandbox.fs.get_file_info("workspace/data")
661
+ if info.is_dir:
662
+ print("Path is a directory")
663
+ ```
664
+ """
665
+ return await self._api_client.get_file_info(path=path)
666
+
667
+ @intercept_errors(message_prefix="Failed to list files: ")
668
+ @with_instrumentation()
669
+ async def list_files(self, path: str) -> list[FileInfo]:
670
+ """Lists files and directories in a given path and returns their information, similar to the ls -l command.
671
+
672
+ Args:
673
+ path (str): Path to the directory to list contents from. Relative paths are resolved
674
+ based on the sandbox working directory.
675
+
676
+ Returns:
677
+ list[FileInfo]: List of file and directory information. Each FileInfo
678
+ object includes the same fields as described in get_file_info().
679
+
680
+ Example:
681
+ ```python
682
+ # List directory contents
683
+ files = await sandbox.fs.list_files("workspace/data")
684
+
685
+ # Print files and their sizes
686
+ for file in files:
687
+ if not file.is_dir:
688
+ print(f"{file.name}: {file.size} bytes")
689
+
690
+ # List only directories
691
+ dirs = [f for f in files if f.is_dir]
692
+ print("Subdirectories:", ", ".join(d.name for d in dirs))
693
+ ```
694
+ """
695
+ return await self._api_client.list_files(path=path)
696
+
697
+ @intercept_errors(message_prefix="Failed to move files: ")
698
+ @with_instrumentation()
699
+ async def move_files(self, source: str, destination: str) -> None:
700
+ """Moves or renames a file or directory. The parent directory of the destination must exist.
701
+
702
+ Args:
703
+ source (str): Path to the source file or directory. Relative paths are resolved
704
+ based on the sandbox working directory.
705
+ destination (str): Path to the destination. Relative paths are resolved based on
706
+ the sandbox working directory.
707
+
708
+ Example:
709
+ ```python
710
+ # Rename a file
711
+ await sandbox.fs.move_files(
712
+ "workspace/data/old_name.txt",
713
+ "workspace/data/new_name.txt"
714
+ )
715
+
716
+ # Move a file to a different directory
717
+ await sandbox.fs.move_files(
718
+ "workspace/data/file.txt",
719
+ "workspace/archive/file.txt"
720
+ )
721
+
722
+ # Move a directory
723
+ await sandbox.fs.move_files(
724
+ "workspace/old_dir",
725
+ "workspace/new_dir"
726
+ )
727
+ ```
728
+ """
729
+ await self._api_client.move_file(
730
+ source=source,
731
+ destination=destination,
732
+ )
733
+
734
+ @intercept_errors(message_prefix="Failed to replace in files: ")
735
+ @with_instrumentation()
736
+ async def replace_in_files(self, files: list[str], pattern: str, new_value: str) -> list[ReplaceResult]:
737
+ """Performs search and replace operations across multiple files.
738
+
739
+ Args:
740
+ files (list[str]): List of file paths to perform replacements in. Relative paths are
741
+ resolved based on the sandbox working directory.
742
+ pattern (str): Pattern to search for.
743
+ new_value (str): Text to replace matches with.
744
+
745
+ Returns:
746
+ list[ReplaceResult]: List of results indicating replacements made in
747
+ each file. Each ReplaceResult includes:
748
+ - file: Path to the modified file
749
+ - success: Whether the operation was successful
750
+ - error: Error message if the operation failed
751
+
752
+ Example:
753
+ ```python
754
+ # Replace in specific files
755
+ results = await sandbox.fs.replace_in_files(
756
+ files=["workspace/src/file1.py", "workspace/src/file2.py"],
757
+ pattern="old_function",
758
+ new_value="new_function"
759
+ )
760
+
761
+ # Print results
762
+ for result in results:
763
+ if result.success:
764
+ print(f"{result.file}: {result.success}")
765
+ else:
766
+ print(f"{result.file}: {result.error}")
767
+ ```
768
+ """
769
+ for i, file in enumerate(files):
770
+ files[i] = file
771
+
772
+ replace_request = ReplaceRequest(files=files, new_value=new_value, pattern=pattern)
773
+
774
+ return await self._api_client.replace_in_files(request=replace_request)
775
+
776
+ @intercept_errors(message_prefix="Failed to search files: ")
777
+ @with_instrumentation()
778
+ async def search_files(self, path: str, pattern: str) -> SearchFilesResponse:
779
+ """Searches for files and directories whose names match the
780
+ specified pattern. The pattern can be a simple string or a glob pattern.
781
+
782
+ Args:
783
+ path (str): Path to the root directory to start search from. Relative paths are resolved
784
+ based on the sandbox working directory.
785
+ pattern (str): Pattern to match against file names. Supports glob
786
+ patterns (e.g., "*.py" for Python files).
787
+
788
+ Returns:
789
+ SearchFilesResponse: Search results containing:
790
+ - files: List of matching file and directory paths
791
+
792
+ Example:
793
+ ```python
794
+ # Find all Python files
795
+ result = await sandbox.fs.search_files("workspace", "*.py")
796
+ for file in result.files:
797
+ print(file)
798
+
799
+ # Find files with specific prefix
800
+ result = await sandbox.fs.search_files("workspace/data", "test_*")
801
+ print(f"Found {len(result.files)} test files")
802
+ ```
803
+ """
804
+ return await self._api_client.search_files(
805
+ path=path,
806
+ pattern=pattern,
807
+ )
808
+
809
+ @intercept_errors(message_prefix="Failed to set file permissions: ")
810
+ @with_instrumentation()
811
+ async def set_file_permissions(
812
+ self, path: str, mode: str | None = None, owner: str | None = None, group: str | None = None
813
+ ) -> None:
814
+ """Sets permissions and ownership for a file or directory. Any of the parameters can be None
815
+ to leave that attribute unchanged.
816
+
817
+ Args:
818
+ path (str): Path to the file or directory. Relative paths are resolved based on
819
+ the sandbox working directory.
820
+ mode (str | None): File mode/permissions in octal format
821
+ (e.g., "644" for rw-r--r--).
822
+ owner (str | None): User owner of the file.
823
+ group (str | None): Group owner of the file.
824
+
825
+ Example:
826
+ ```python
827
+ # Make a file executable
828
+ await sandbox.fs.set_file_permissions(
829
+ path="workspace/scripts/run.sh",
830
+ mode="755" # rwxr-xr-x
831
+ )
832
+
833
+ # Change file owner
834
+ await sandbox.fs.set_file_permissions(
835
+ path="workspace/data/file.txt",
836
+ owner="northrays",
837
+ group="northrays"
838
+ )
839
+ ```
840
+ """
841
+ await self._api_client.set_file_permissions(
842
+ path=path,
843
+ mode=mode,
844
+ owner=owner,
845
+ group=group,
846
+ )
847
+
848
+ @overload
849
+ async def upload_file(self, file: bytes, remote_path: str, timeout: int = 30 * 60) -> None:
850
+ """Uploads a file to the specified path in the Sandbox. If a file already exists at
851
+ the destination path, it will be overwritten. This method is useful when you want to upload
852
+ small files that fit into memory.
853
+
854
+ Args:
855
+ file (bytes): File contents as a bytes object.
856
+ remote_path (str): Path to the destination file. Relative paths are resolved based on
857
+ the sandbox working directory.
858
+ timeout (int): Timeout for the upload operation in seconds. 0 means no timeout. Default is 30 minutes.
859
+
860
+ Example:
861
+ ```python
862
+ # Upload a text file
863
+ content = b"Hello, World!"
864
+ await sandbox.fs.upload_file(content, "tmp/hello.txt")
865
+
866
+ # Upload a local file
867
+ with open("local_file.txt", "rb") as f:
868
+ content = f.read()
869
+ await sandbox.fs.upload_file(content, "tmp/file.txt")
870
+
871
+ # Upload binary data
872
+ import json
873
+ data = {"key": "value"}
874
+ content = json.dumps(data).encode('utf-8')
875
+ await sandbox.fs.upload_file(content, "tmp/config.json")
876
+ ```
877
+ """
878
+
879
+ @overload
880
+ async def upload_file(self, local_path: str, remote_path: str, timeout: int = 30 * 60) -> None:
881
+ """Uploads a file from the local file system to the specified path in the Sandbox.
882
+ If a file already exists at the destination path, it will be overwritten. This method uses
883
+ streaming to upload the file, so it is useful when you want to upload larger files that may
884
+ not fit into memory.
885
+
886
+ Args:
887
+ local_path (str): Path to the local file to upload.
888
+ remote_path (str): Path to the destination file in the Sandbox. Relative paths are
889
+ resolved based on the sandbox working directory.
890
+ timeout (int): Timeout for the upload operation in seconds. 0 means no timeout. Default is 30 minutes.
891
+
892
+ Example:
893
+ ```python
894
+ await sandbox.fs.upload_file("local_file.txt", "tmp/large_file.txt")
895
+ ```
896
+ """
897
+
898
+ @with_instrumentation()
899
+ async def upload_file( # pyright: ignore[reportInconsistentOverload]
900
+ self, src: str | bytes, dst: str, timeout: int = 30 * 60
901
+ ) -> None:
902
+ await self.upload_files([FileUpload(src, dst)], timeout)
903
+
904
+ @intercept_errors(message_prefix="Failed to upload files: ")
905
+ @with_instrumentation()
906
+ async def upload_files(self, files: list[FileUpload], timeout: int = 30 * 60) -> None:
907
+ """Uploads multiple files to the Sandbox. If files already exist at the destination paths,
908
+ they will be overwritten.
909
+
910
+ Args:
911
+ files (list[FileUpload]): List of files to upload.
912
+ timeout (int): Timeout for the upload operation in seconds. 0 means no timeout. Default is 30 minutes.
913
+ Example:
914
+ ```python
915
+ # Upload multiple text files
916
+ files = [
917
+ FileUpload(
918
+ source=b"Content of file 1",
919
+ destination="/tmp/file1.txt"
920
+ ),
921
+ FileUpload(
922
+ source="workspace/data/file2.txt",
923
+ destination="/tmp/file2.txt"
924
+ ),
925
+ FileUpload(
926
+ source=b'{"key": "value"}',
927
+ destination="/tmp/config.json"
928
+ )
929
+ ]
930
+ await sandbox.fs.upload_files(files)
931
+ ```
932
+ """
933
+ with ExitStack() as stack:
934
+ form = aiohttp.FormData()
935
+
936
+ for i, f in enumerate(files):
937
+ form.add_field(f"files[{i}].path", f.destination)
938
+
939
+ if isinstance(f.source, (bytes, bytearray)):
940
+ stream: io.BytesIO | io.BufferedReader = io.BytesIO(f.source)
941
+ else:
942
+ stream = stack.enter_context(open(f.source, "rb"))
943
+
944
+ # aiohttp streams the file-like object chunk-by-chunk; the destination path
945
+ # rides on the multipart filename so the daemon doesn't have to parse a
946
+ # sidecar field.
947
+ form.add_field(
948
+ f"files[{i}].file",
949
+ stream,
950
+ filename=f.destination,
951
+ content_type="application/octet-stream",
952
+ )
953
+
954
+ _, url, headers, *_ = self._api_client._upload_files_serialize(None, None, None, None)
955
+ # strip any prior Content-Type so aiohttp can set its own multipart header
956
+ _ = headers.pop("Content-Type", None)
957
+
958
+ async with http_session_of(self._api_client.api_client).post(
959
+ url,
960
+ data=form,
961
+ headers=headers,
962
+ timeout=_request_timeout(timeout),
963
+ ) as response:
964
+ if response.status >= 400:
965
+ try:
966
+ payload = await response.json()
967
+ detail = ", ".join(payload["errors"])
968
+ except Exception:
969
+ detail = await response.text()
970
+ raise NorthraysError(
971
+ f"{response.status}: {detail}",
972
+ status_code=response.status,
973
+ )
974
+
975
+ @intercept_errors(message_prefix="Failed to upload file: ")
976
+ @with_instrumentation()
977
+ async def upload_file_stream(
978
+ self,
979
+ source: bytes | bytearray | str | io.IOBase | AsyncIterable[bytes] | object,
980
+ remote_path: str,
981
+ timeout: int = 30 * 60,
982
+ on_progress: Callable[[UploadProgress], Awaitable[None] | None] | None = None,
983
+ cancel_event: CancelEvent | None = None,
984
+ ) -> None:
985
+ """Uploads a single file to the Sandbox using true streaming, with optional progress
986
+ tracking and cancellation. Memory usage stays flat regardless of source size. The
987
+ HTTP layer uses chunked transfer encoding, so the source's natural EOF terminates
988
+ the upload — no advance size is needed.
989
+
990
+ Args:
991
+ source: Data to upload. Accepts:
992
+
993
+ * ``bytes`` / ``bytearray`` — uploaded from memory.
994
+ * ``str`` — treated as a local file path and read in chunks.
995
+ * sync file-like (anything with ``.read(n) -> bytes``) — streamed as-is.
996
+ * **async file-like** (anything with ``async def read(n) -> bytes``,
997
+ e.g. an ``aiofiles`` handle) — streamed without ever blocking the loop.
998
+ * ``AsyncIterable[bytes]`` — yielded chunks are forwarded to the wire.
999
+ remote_path (str): Destination path in the Sandbox.
1000
+ timeout (int): Timeout in seconds. 0 means no timeout. Default is 30 minutes.
1001
+ on_progress (Callable[[UploadProgress], Awaitable[None] | None] | None): Optional
1002
+ callback invoked with cumulative bytes sent. May be sync or ``async def``
1003
+ **when paired with an async source** (async file-like or ``AsyncIterable[bytes]``).
1004
+ Sync sources (``bytes``, ``str`` path, sync file-like) require a sync callback
1005
+ because the underlying httpx multipart serializer pulls bytes through a
1006
+ synchronous ``.read()``; passing an async callback alongside a sync source
1007
+ raises ``NorthraysError``.
1008
+ cancel_event (CancelEvent | None): Optional ``asyncio.Event``-compatible token.
1009
+ When set during streaming, the next chunk raises ``NorthraysError`` and
1010
+ tears down the request. Standard ``asyncio.CancelledError`` from task
1011
+ cancellation is also honoured automatically.
1012
+
1013
+ Raises:
1014
+ NorthraysError: If the upload fails or is cancelled via ``cancel_event``.
1015
+
1016
+ Example:
1017
+ ```python
1018
+ import aiofiles, asyncio
1019
+ cancel = asyncio.Event()
1020
+ async with aiofiles.open("large_dataset.csv", "rb") as f:
1021
+ await sandbox.fs.upload_file_stream(
1022
+ f,
1023
+ "tmp/dataset.csv",
1024
+ on_progress=lambda p: print(f"{p.bytes_sent} bytes sent"),
1025
+ cancel_event=cancel,
1026
+ )
1027
+ ```
1028
+ """
1029
+ if cancel_event is not None and cancel_event.is_set():
1030
+ raise NorthraysError(f"Upload cancelled: {remote_path}")
1031
+
1032
+ _, url, headers, *_ = self._api_client._upload_files_serialize(None, None, None, None)
1033
+ _ = headers.pop("Content-Type", None)
1034
+
1035
+ if _is_async_source(source):
1036
+ # Async file-like / AsyncIterable need their own multipart body builder
1037
+ # because httpx.files= demands a sync .read(). We build the multipart
1038
+ # envelope as an async byte iterator and ship it via httpx.content=.
1039
+ await self._upload_async_stream(
1040
+ source,
1041
+ remote_path,
1042
+ url,
1043
+ headers,
1044
+ timeout,
1045
+ on_progress,
1046
+ cancel_event,
1047
+ )
1048
+ return
1049
+
1050
+ # Sync sources flow through httpx's native multipart serialiser. The
1051
+ # _CountingUploadReader interleaves byte counting + cancel checks into
1052
+ # each .read() call that httpx makes during serialisation. That .read()
1053
+ # is necessarily synchronous, so an async on_progress can't be awaited
1054
+ # there — fail loudly instead of silently dropping the coroutine.
1055
+ if on_progress is not None and inspect.iscoroutinefunction(on_progress):
1056
+ raise NorthraysError(
1057
+ "An async on_progress callback is only supported with an async source"
1058
+ + " (async file-like or AsyncIterable[bytes]). With a sync source pass a"
1059
+ + " regular function, or convert the source to async."
1060
+ )
1061
+ # The iscoroutinefunction guard above ensures on_progress is a plain
1062
+ # sync callable on this branch, so the cast to the narrower type the
1063
+ # _CountingUploadReader constructor expects is safe.
1064
+ sync_on_progress = cast(Callable[[UploadProgress], None] | None, on_progress)
1065
+ with ExitStack() as stack:
1066
+ stream = _open_upload_source(stack, source)
1067
+ wrapped = _CountingUploadReader(stream, sync_on_progress, cancel_event, remote_path)
1068
+
1069
+ data_fields = {"files[0].path": remote_path}
1070
+ # httpx accepts any IO[bytes]-shaped object as a multipart file; our
1071
+ # _CountingUploadReader is RawIOBase but pyright can't see that the
1072
+ # (filename, reader) tuple satisfies the structural FileTypes union,
1073
+ # so we drop into Any for the call.
1074
+ file_fields = cast(Any, {"files[0].file": (remote_path, wrapped)})
1075
+
1076
+ async with httpx.AsyncClient(timeout=timeout or None) as client:
1077
+ response = await client.post(url, data=data_fields, files=file_fields, headers=headers)
1078
+ _raise_for_upload_status(response)
1079
+
1080
+ async def _upload_async_stream(
1081
+ self,
1082
+ source: object,
1083
+ remote_path: str,
1084
+ url: str,
1085
+ headers: dict[str, str],
1086
+ timeout: int,
1087
+ on_progress: Callable[[UploadProgress], Awaitable[None] | None] | None,
1088
+ cancel_event: CancelEvent | None,
1089
+ ) -> None:
1090
+ boundary = "----NorthraysUpload" + secrets.token_hex(12)
1091
+ envelope_header, envelope_trailer = _build_multipart_envelope(boundary, remote_path)
1092
+
1093
+ async def body_generator() -> AsyncIterator[bytes]:
1094
+ yield envelope_header
1095
+ sent = 0
1096
+ async for chunk in _iter_async_source_chunks(source):
1097
+ if cancel_event is not None and cancel_event.is_set():
1098
+ raise NorthraysError(f"Upload cancelled: {remote_path}")
1099
+ if not chunk:
1100
+ continue
1101
+ sent += len(chunk)
1102
+ if on_progress is not None:
1103
+ progress = UploadProgress(bytes_sent=sent)
1104
+ if inspect.iscoroutinefunction(on_progress):
1105
+ await on_progress(progress)
1106
+ else:
1107
+ _ = on_progress(progress)
1108
+ yield chunk
1109
+ yield envelope_trailer
1110
+
1111
+ request_headers = dict(headers)
1112
+ request_headers["Content-Type"] = f"multipart/form-data; boundary={boundary}"
1113
+
1114
+ async with httpx.AsyncClient(timeout=timeout or None) as client:
1115
+ response = await client.post(url, content=body_generator(), headers=request_headers)
1116
+ _raise_for_upload_status(response)
1117
+
1118
+
1119
+ def _is_async_source(source: object) -> bool:
1120
+ """A source is "async" if its ``read`` is a coroutine function (e.g. an aiofiles
1121
+ file handle) or if it implements the ``__aiter__`` protocol. Sync ``IOBase`` and
1122
+ bytes/str sources stay on the existing httpx-multipart path."""
1123
+ if hasattr(source, "__aiter__"):
1124
+ return True
1125
+ read = getattr(source, "read", None)
1126
+ return read is not None and inspect.iscoroutinefunction(read)
1127
+
1128
+
1129
+ async def _iter_async_source_chunks(source: object) -> AsyncIterator[bytes]:
1130
+ """Yields bytes from either an async file-like (``async def read``) or an
1131
+ ``AsyncIterable[bytes]``. Both variants are pulled in 64 KiB chunks; the async
1132
+ iterable case forwards whatever sized chunks the producer emits."""
1133
+ read = getattr(source, "read", None)
1134
+ if read is not None and inspect.iscoroutinefunction(read):
1135
+ while True:
1136
+ chunk = cast(bytes, await read(64 * 1024))
1137
+ if not chunk:
1138
+ return
1139
+ yield chunk
1140
+
1141
+ # The dispatch in upload_file_stream guarantees source has either an async
1142
+ # `read` method (handled above) or implements `__aiter__`, so this branch
1143
+ # is reached only with an AsyncIterable[bytes]. The cast lets pyright follow
1144
+ # that invariant.
1145
+ async for chunk in cast(AsyncIterable[bytes], source):
1146
+ yield chunk
1147
+
1148
+
1149
+ _FILENAME_FORBIDDEN_CHARS = str.maketrans({'"': "_", "\\": "_", "\r": "_", "\n": "_"})
1150
+
1151
+
1152
+ def _build_multipart_envelope(boundary: str, remote_path: str) -> tuple[bytes, bytes]:
1153
+ """Returns ``(header, trailer)`` byte strings for a single-file ``files[0]`` part
1154
+ targeting the bulk-upload endpoint. The body of the file part goes between them.
1155
+
1156
+ The Content-Disposition filename is sanitized so a remote path containing quotes,
1157
+ backslashes, or CR/LF can't break out of the header — the daemon doesn't actually
1158
+ use this filename (the destination comes from the ``files[0].path`` text part), so
1159
+ a lossy substitution is fine."""
1160
+ filename = os.path.basename(remote_path).translate(_FILENAME_FORBIDDEN_CHARS) or "upload"
1161
+ header = (
1162
+ f"--{boundary}\r\n"
1163
+ 'Content-Disposition: form-data; name="files[0].path"\r\n\r\n'
1164
+ f"{remote_path}\r\n"
1165
+ f"--{boundary}\r\n"
1166
+ f'Content-Disposition: form-data; name="files[0].file"; filename="{filename}"\r\n'
1167
+ "Content-Type: application/octet-stream\r\n\r\n"
1168
+ ).encode("utf-8")
1169
+ trailer = f"\r\n--{boundary}--\r\n".encode("utf-8")
1170
+ return header, trailer
1171
+
1172
+
1173
+ def _raise_for_upload_status(response: httpx.Response) -> None:
1174
+ if response.is_success:
1175
+ return
1176
+ try:
1177
+ detail = ", ".join(response.json()["errors"])
1178
+ except Exception:
1179
+ detail = response.text
1180
+ raise NorthraysError(
1181
+ f"{response.status_code}: {detail}",
1182
+ status_code=response.status_code,
1183
+ )
1184
+
1185
+
1186
+ def _open_upload_source(stack: ExitStack, source: object) -> io.IOBase:
1187
+ """Coerces ``upload_file_stream`` source variants into a uniform read-ready stream.
1188
+
1189
+ The stack owns closing any file we opened on the caller's behalf; file-like objects passed
1190
+ in by the caller are returned untouched (caller retains ownership and lifecycle).
1191
+ """
1192
+ if isinstance(source, (bytes, bytearray)):
1193
+ return io.BytesIO(bytes(source))
1194
+ if isinstance(source, str):
1195
+ return stack.enter_context(open(source, "rb"))
1196
+ if hasattr(source, "read"):
1197
+ # Caller-supplied IOBase (or duck-typed file-like). httpx will read
1198
+ # from it via .read(); the cast is structural since pyright can't
1199
+ # infer "anything with .read" implies io.IOBase.
1200
+ return cast(io.IOBase, source)
1201
+ raise NorthraysError(f"Unsupported upload source: {type(source).__name__}")
1202
+
1203
+
1204
+ @final
1205
+ class _CountingUploadReader(io.RawIOBase):
1206
+ """File-like wrapper that meters bytes flowing into httpx and honours cancellation
1207
+ between chunks."""
1208
+
1209
+ def __init__(
1210
+ self,
1211
+ source: io.IOBase,
1212
+ on_progress: Callable[[UploadProgress], None] | None,
1213
+ cancel_event: CancelEvent | None,
1214
+ remote_path: str,
1215
+ ) -> None:
1216
+ super().__init__()
1217
+ self._source = source
1218
+ self._on_progress = on_progress
1219
+ self._cancel_event = cancel_event
1220
+ self._remote_path = remote_path
1221
+ self._sent = 0
1222
+
1223
+ @override
1224
+ def readable(self) -> bool:
1225
+ return True
1226
+
1227
+ @override
1228
+ def read(self, size: int = -1) -> bytes:
1229
+ if self._cancel_event is not None and self._cancel_event.is_set():
1230
+ raise NorthraysError(f"Upload cancelled: {self._remote_path}")
1231
+ chunk = self._source.read(size)
1232
+ if chunk:
1233
+ self._sent += len(chunk)
1234
+ if self._on_progress is not None:
1235
+ self._on_progress(UploadProgress(bytes_sent=self._sent))
1236
+ return chunk
1237
+
1238
+ @override
1239
+ def readall(self) -> bytes:
1240
+ return self.read(-1)