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.
- northrays/__init__.py +245 -0
- northrays/_async/__init__.py +2 -0
- northrays/_async/code_interpreter.py +302 -0
- northrays/_async/computer_use.py +930 -0
- northrays/_async/filesystem.py +1240 -0
- northrays/_async/git.py +391 -0
- northrays/_async/lsp_server.py +256 -0
- northrays/_async/northrays.py +819 -0
- northrays/_async/object_storage.py +190 -0
- northrays/_async/process.py +781 -0
- northrays/_async/sandbox.py +904 -0
- northrays/_async/snapshot.py +262 -0
- northrays/_async/volume.py +94 -0
- northrays/_sync/__init__.py +2 -0
- northrays/_sync/code_interpreter.py +271 -0
- northrays/_sync/computer_use.py +929 -0
- northrays/_sync/filesystem.py +1063 -0
- northrays/_sync/git.py +389 -0
- northrays/_sync/lsp_server.py +256 -0
- northrays/_sync/northrays.py +704 -0
- northrays/_sync/object_storage.py +184 -0
- northrays/_sync/process.py +778 -0
- northrays/_sync/sandbox.py +919 -0
- northrays/_sync/snapshot.py +262 -0
- northrays/_sync/volume.py +94 -0
- northrays/_utils/__init__.py +2 -0
- northrays/_utils/deprecation.py +95 -0
- northrays/_utils/docs_ignore.py +11 -0
- northrays/_utils/enum.py +27 -0
- northrays/_utils/env.py +38 -0
- northrays/_utils/environment.py +23 -0
- northrays/_utils/errors.py +298 -0
- northrays/_utils/otel_decorator.py +331 -0
- northrays/_utils/stream.py +368 -0
- northrays/_utils/timeout.py +484 -0
- northrays/_utils/types.py +16 -0
- northrays/common/__init__.py +2 -0
- northrays/common/charts.py +118 -0
- northrays/common/code_interpreter.py +44 -0
- northrays/common/computer_use.py +44 -0
- northrays/common/errors.py +187 -0
- northrays/common/file_transfer.py +69 -0
- northrays/common/filesystem.py +177 -0
- northrays/common/git.py +13 -0
- northrays/common/image.py +700 -0
- northrays/common/lsp_server.py +45 -0
- northrays/common/northrays.py +202 -0
- northrays/common/process.py +140 -0
- northrays/common/protocols.py +14 -0
- northrays/common/pty.py +65 -0
- northrays/common/sandbox.py +99 -0
- northrays/common/snapshot.py +84 -0
- northrays/common/volume.py +39 -0
- northrays/handle/async_pty_handle.py +323 -0
- northrays/handle/pty_handle.py +341 -0
- northrays/internal/__init__.py +2 -0
- northrays/internal/api_client_proxy.py +22 -0
- northrays/internal/http_client.py +99 -0
- northrays/internal/pool_tracker.py +44 -0
- northrays/internal/shared_session.py +262 -0
- northrays/internal/toolbox_api_client_proxy.py +114 -0
- northrays/internal/urllib3_retry.py +53 -0
- northrays/py.typed +0 -0
- northrays-0.1.0.dist-info/METADATA +211 -0
- northrays-0.1.0.dist-info/RECORD +711 -0
- northrays-0.1.0.dist-info/WHEEL +5 -0
- northrays-0.1.0.dist-info/licenses/LICENSE +191 -0
- northrays-0.1.0.dist-info/licenses/NOTICE +46 -0
- northrays-0.1.0.dist-info/top_level.txt +5 -0
- northrays_api_client/__init__.py +684 -0
- northrays_api_client/api/__init__.py +64 -0
- northrays_api_client/api/admin_api.py +5998 -0
- northrays_api_client/api/api_keys_api.py +1672 -0
- northrays_api_client/api/audit_api.py +402 -0
- northrays_api_client/api/config_api.py +278 -0
- northrays_api_client/api/docker_registry_api.py +1707 -0
- northrays_api_client/api/health_api.py +517 -0
- northrays_api_client/api/jobs_api.py +1185 -0
- northrays_api_client/api/object_storage_api.py +298 -0
- northrays_api_client/api/organizations_api.py +10857 -0
- northrays_api_client/api/preview_api.py +1104 -0
- northrays_api_client/api/regions_api.py +279 -0
- northrays_api_client/api/runners_api.py +2987 -0
- northrays_api_client/api/sandbox_api.py +12813 -0
- northrays_api_client/api/snapshots_api.py +2331 -0
- northrays_api_client/api/toolbox_api.py +20758 -0
- northrays_api_client/api/users_api.py +1304 -0
- northrays_api_client/api/volumes_api.py +1421 -0
- northrays_api_client/api/webhooks_api.py +1135 -0
- northrays_api_client/api_client.py +810 -0
- northrays_api_client/api_response.py +21 -0
- northrays_api_client/configuration.py +607 -0
- northrays_api_client/exceptions.py +219 -0
- northrays_api_client/models/__init__.py +405 -0
- northrays_api_client/models/account_provider.py +105 -0
- northrays_api_client/models/admin_create_runner.py +131 -0
- northrays_api_client/models/admin_get_webhook_status200_response.py +103 -0
- northrays_api_client/models/announcement.py +105 -0
- northrays_api_client/models/api_key_list.py +126 -0
- northrays_api_client/models/api_key_response.py +117 -0
- northrays_api_client/models/audit_log.py +134 -0
- northrays_api_client/models/build_info.py +112 -0
- northrays_api_client/models/command.py +107 -0
- northrays_api_client/models/completion_context.py +105 -0
- northrays_api_client/models/completion_item.py +115 -0
- northrays_api_client/models/completion_list.py +113 -0
- northrays_api_client/models/compressed_screenshot_response.py +107 -0
- northrays_api_client/models/computer_use_start_response.py +105 -0
- northrays_api_client/models/computer_use_status_response.py +103 -0
- northrays_api_client/models/computer_use_stop_response.py +105 -0
- northrays_api_client/models/create_api_key.py +113 -0
- northrays_api_client/models/create_build_info.py +105 -0
- northrays_api_client/models/create_docker_registry.py +111 -0
- northrays_api_client/models/create_linked_account.py +105 -0
- northrays_api_client/models/create_organization.py +105 -0
- northrays_api_client/models/create_organization_invitation.py +110 -0
- northrays_api_client/models/create_organization_quota.py +119 -0
- northrays_api_client/models/create_organization_region_quota.py +169 -0
- northrays_api_client/models/create_organization_role.py +107 -0
- northrays_api_client/models/create_region.py +124 -0
- northrays_api_client/models/create_region_response.py +131 -0
- northrays_api_client/models/create_runner.py +107 -0
- northrays_api_client/models/create_runner_response.py +105 -0
- northrays_api_client/models/create_sandbox.py +156 -0
- northrays_api_client/models/create_sandbox_snapshot.py +105 -0
- northrays_api_client/models/create_session_request.py +103 -0
- northrays_api_client/models/create_snapshot.py +129 -0
- northrays_api_client/models/create_user.py +119 -0
- northrays_api_client/models/create_volume.py +103 -0
- northrays_api_client/models/display_info_response.py +103 -0
- northrays_api_client/models/docker_registry.py +118 -0
- northrays_api_client/models/download_files.py +103 -0
- northrays_api_client/models/execute_request.py +107 -0
- northrays_api_client/models/execute_response.py +105 -0
- northrays_api_client/models/file_info.py +117 -0
- northrays_api_client/models/file_status.py +109 -0
- northrays_api_client/models/fork_sandbox.py +103 -0
- northrays_api_client/models/git_add_request.py +105 -0
- northrays_api_client/models/git_branch_request.py +105 -0
- northrays_api_client/models/git_checkout_request.py +105 -0
- northrays_api_client/models/git_clone_request.py +113 -0
- northrays_api_client/models/git_commit_info.py +111 -0
- northrays_api_client/models/git_commit_request.py +111 -0
- northrays_api_client/models/git_commit_response.py +103 -0
- northrays_api_client/models/git_delete_branch_request.py +105 -0
- northrays_api_client/models/git_repo_request.py +107 -0
- northrays_api_client/models/git_status.py +119 -0
- northrays_api_client/models/gpu_type.py +43 -0
- northrays_api_client/models/health_controller_check200_response.py +156 -0
- northrays_api_client/models/health_controller_check200_response_info_value.py +103 -0
- northrays_api_client/models/health_controller_check503_response.py +156 -0
- northrays_api_client/models/job.py +123 -0
- northrays_api_client/models/job_status.py +45 -0
- northrays_api_client/models/job_type.py +56 -0
- northrays_api_client/models/keyboard_hotkey_request.py +103 -0
- northrays_api_client/models/keyboard_press_request.py +105 -0
- northrays_api_client/models/keyboard_type_request.py +105 -0
- northrays_api_client/models/list_branch_response.py +103 -0
- northrays_api_client/models/list_sandboxes_response.py +118 -0
- northrays_api_client/models/log_entry.py +119 -0
- northrays_api_client/models/lsp_completion_params.py +119 -0
- northrays_api_client/models/lsp_document_request.py +107 -0
- northrays_api_client/models/lsp_location.py +109 -0
- northrays_api_client/models/lsp_server_request.py +105 -0
- northrays_api_client/models/lsp_symbol.py +111 -0
- northrays_api_client/models/match.py +107 -0
- northrays_api_client/models/metric_data_point.py +105 -0
- northrays_api_client/models/metric_series.py +113 -0
- northrays_api_client/models/metrics_response.py +111 -0
- northrays_api_client/models/mouse_click_request.py +109 -0
- northrays_api_client/models/mouse_click_response.py +105 -0
- northrays_api_client/models/mouse_drag_request.py +111 -0
- northrays_api_client/models/mouse_drag_response.py +105 -0
- northrays_api_client/models/mouse_move_request.py +105 -0
- northrays_api_client/models/mouse_move_response.py +105 -0
- northrays_api_client/models/mouse_position.py +105 -0
- northrays_api_client/models/mouse_scroll_request.py +109 -0
- northrays_api_client/models/mouse_scroll_response.py +103 -0
- northrays_api_client/models/northrays_configuration.py +162 -0
- northrays_api_client/models/oidc_config.py +107 -0
- northrays_api_client/models/organization.py +191 -0
- northrays_api_client/models/organization_invitation.py +132 -0
- northrays_api_client/models/organization_role.py +116 -0
- northrays_api_client/models/organization_sandbox_default_limited_network_egress.py +103 -0
- northrays_api_client/models/organization_suspension.py +109 -0
- northrays_api_client/models/organization_usage_overview.py +119 -0
- northrays_api_client/models/organization_user.py +126 -0
- northrays_api_client/models/otel_config.py +110 -0
- northrays_api_client/models/paginated_audit_logs.py +119 -0
- northrays_api_client/models/paginated_jobs.py +117 -0
- northrays_api_client/models/paginated_logs.py +117 -0
- northrays_api_client/models/paginated_sandboxes_deprecated.py +117 -0
- northrays_api_client/models/paginated_snapshots.py +117 -0
- northrays_api_client/models/paginated_traces.py +117 -0
- northrays_api_client/models/poll_jobs_response.py +111 -0
- northrays_api_client/models/port_preview_url.py +107 -0
- northrays_api_client/models/position.py +105 -0
- northrays_api_client/models/posthog_config.py +105 -0
- northrays_api_client/models/process_errors_response.py +105 -0
- northrays_api_client/models/process_logs_response.py +105 -0
- northrays_api_client/models/process_restart_response.py +105 -0
- northrays_api_client/models/process_status_response.py +105 -0
- northrays_api_client/models/project_dir_response.py +103 -0
- northrays_api_client/models/pty_create_request.py +113 -0
- northrays_api_client/models/pty_create_response.py +103 -0
- northrays_api_client/models/pty_list_response.py +111 -0
- northrays_api_client/models/pty_resize_request.py +105 -0
- northrays_api_client/models/pty_session_info.py +117 -0
- northrays_api_client/models/range.py +112 -0
- northrays_api_client/models/rate_limit_config.py +122 -0
- northrays_api_client/models/rate_limit_entry.py +105 -0
- northrays_api_client/models/regenerate_api_key_response.py +103 -0
- northrays_api_client/models/region.py +140 -0
- northrays_api_client/models/region_quota.py +168 -0
- northrays_api_client/models/region_screenshot_response.py +107 -0
- northrays_api_client/models/region_type.py +44 -0
- northrays_api_client/models/region_usage_overview.py +174 -0
- northrays_api_client/models/registry_push_access_dto.py +113 -0
- northrays_api_client/models/replace_request.py +107 -0
- northrays_api_client/models/replace_result.py +107 -0
- northrays_api_client/models/resize_sandbox.py +108 -0
- northrays_api_client/models/runner.py +166 -0
- northrays_api_client/models/runner_class.py +42 -0
- northrays_api_client/models/runner_full.py +171 -0
- northrays_api_client/models/runner_health_metrics.py +129 -0
- northrays_api_client/models/runner_healthcheck.py +125 -0
- northrays_api_client/models/runner_service_health.py +107 -0
- northrays_api_client/models/runner_snapshot_dto.py +107 -0
- northrays_api_client/models/runner_state.py +46 -0
- northrays_api_client/models/sandbox.py +188 -0
- northrays_api_client/models/sandbox_class.py +45 -0
- northrays_api_client/models/sandbox_desired_state.py +47 -0
- northrays_api_client/models/sandbox_labels.py +103 -0
- northrays_api_client/models/sandbox_list_item.py +161 -0
- northrays_api_client/models/sandbox_list_sort_direction.py +43 -0
- northrays_api_client/models/sandbox_list_sort_field.py +47 -0
- northrays_api_client/models/sandbox_state.py +63 -0
- northrays_api_client/models/sandbox_volume.py +107 -0
- northrays_api_client/models/screenshot_response.py +107 -0
- northrays_api_client/models/search_files_response.py +103 -0
- northrays_api_client/models/send_webhook_dto.py +108 -0
- northrays_api_client/models/session.py +118 -0
- northrays_api_client/models/session_execute_request.py +107 -0
- northrays_api_client/models/session_execute_response.py +107 -0
- northrays_api_client/models/set_snapshot_general_status_dto.py +103 -0
- northrays_api_client/models/signed_port_preview_url.py +109 -0
- northrays_api_client/models/snapshot_dto.py +172 -0
- northrays_api_client/models/snapshot_manager_credentials.py +105 -0
- northrays_api_client/models/snapshot_state.py +49 -0
- northrays_api_client/models/ssh_access_dto.py +116 -0
- northrays_api_client/models/ssh_access_validation_dto.py +105 -0
- northrays_api_client/models/storage_access_dto.py +113 -0
- northrays_api_client/models/toolbox_proxy_url.py +103 -0
- northrays_api_client/models/trace_span.py +119 -0
- northrays_api_client/models/trace_summary.py +115 -0
- northrays_api_client/models/update_docker_registry.py +111 -0
- northrays_api_client/models/update_job_status.py +108 -0
- northrays_api_client/models/update_organization_default_region.py +103 -0
- northrays_api_client/models/update_organization_invitation.py +108 -0
- northrays_api_client/models/update_organization_member_access.py +105 -0
- northrays_api_client/models/update_organization_quota.py +192 -0
- northrays_api_client/models/update_organization_region_quota.py +189 -0
- northrays_api_client/models/update_organization_role.py +107 -0
- northrays_api_client/models/update_region.py +122 -0
- northrays_api_client/models/update_sandbox_network_settings.py +107 -0
- northrays_api_client/models/update_sandbox_state_dto.py +107 -0
- northrays_api_client/models/url.py +103 -0
- northrays_api_client/models/user.py +120 -0
- northrays_api_client/models/user_home_dir_response.py +103 -0
- northrays_api_client/models/user_public_key.py +105 -0
- northrays_api_client/models/volume_dto.py +128 -0
- northrays_api_client/models/volume_state.py +48 -0
- northrays_api_client/models/webhook_app_portal_access.py +105 -0
- northrays_api_client/models/webhook_event.py +48 -0
- northrays_api_client/models/webhook_initialization_status.py +123 -0
- northrays_api_client/models/windows_response.py +105 -0
- northrays_api_client/models/work_dir_response.py +103 -0
- northrays_api_client/py.typed +0 -0
- northrays_api_client/rest.py +264 -0
- northrays_api_client_async/__init__.py +684 -0
- northrays_api_client_async/api/__init__.py +64 -0
- northrays_api_client_async/api/admin_api.py +5998 -0
- northrays_api_client_async/api/api_keys_api.py +1672 -0
- northrays_api_client_async/api/audit_api.py +402 -0
- northrays_api_client_async/api/config_api.py +278 -0
- northrays_api_client_async/api/docker_registry_api.py +1707 -0
- northrays_api_client_async/api/health_api.py +517 -0
- northrays_api_client_async/api/jobs_api.py +1185 -0
- northrays_api_client_async/api/object_storage_api.py +298 -0
- northrays_api_client_async/api/organizations_api.py +10857 -0
- northrays_api_client_async/api/preview_api.py +1104 -0
- northrays_api_client_async/api/regions_api.py +279 -0
- northrays_api_client_async/api/runners_api.py +2987 -0
- northrays_api_client_async/api/sandbox_api.py +12813 -0
- northrays_api_client_async/api/snapshots_api.py +2331 -0
- northrays_api_client_async/api/toolbox_api.py +20758 -0
- northrays_api_client_async/api/users_api.py +1304 -0
- northrays_api_client_async/api/volumes_api.py +1421 -0
- northrays_api_client_async/api/webhooks_api.py +1135 -0
- northrays_api_client_async/api_client.py +813 -0
- northrays_api_client_async/api_response.py +21 -0
- northrays_api_client_async/configuration.py +605 -0
- northrays_api_client_async/exceptions.py +219 -0
- northrays_api_client_async/models/__init__.py +405 -0
- northrays_api_client_async/models/account_provider.py +105 -0
- northrays_api_client_async/models/admin_create_runner.py +131 -0
- northrays_api_client_async/models/admin_get_webhook_status200_response.py +103 -0
- northrays_api_client_async/models/announcement.py +105 -0
- northrays_api_client_async/models/api_key_list.py +126 -0
- northrays_api_client_async/models/api_key_response.py +117 -0
- northrays_api_client_async/models/audit_log.py +134 -0
- northrays_api_client_async/models/build_info.py +112 -0
- northrays_api_client_async/models/command.py +107 -0
- northrays_api_client_async/models/completion_context.py +105 -0
- northrays_api_client_async/models/completion_item.py +115 -0
- northrays_api_client_async/models/completion_list.py +113 -0
- northrays_api_client_async/models/compressed_screenshot_response.py +107 -0
- northrays_api_client_async/models/computer_use_start_response.py +105 -0
- northrays_api_client_async/models/computer_use_status_response.py +103 -0
- northrays_api_client_async/models/computer_use_stop_response.py +105 -0
- northrays_api_client_async/models/create_api_key.py +113 -0
- northrays_api_client_async/models/create_build_info.py +105 -0
- northrays_api_client_async/models/create_docker_registry.py +111 -0
- northrays_api_client_async/models/create_linked_account.py +105 -0
- northrays_api_client_async/models/create_organization.py +105 -0
- northrays_api_client_async/models/create_organization_invitation.py +110 -0
- northrays_api_client_async/models/create_organization_quota.py +119 -0
- northrays_api_client_async/models/create_organization_region_quota.py +169 -0
- northrays_api_client_async/models/create_organization_role.py +107 -0
- northrays_api_client_async/models/create_region.py +124 -0
- northrays_api_client_async/models/create_region_response.py +131 -0
- northrays_api_client_async/models/create_runner.py +107 -0
- northrays_api_client_async/models/create_runner_response.py +105 -0
- northrays_api_client_async/models/create_sandbox.py +156 -0
- northrays_api_client_async/models/create_sandbox_snapshot.py +105 -0
- northrays_api_client_async/models/create_session_request.py +103 -0
- northrays_api_client_async/models/create_snapshot.py +129 -0
- northrays_api_client_async/models/create_user.py +119 -0
- northrays_api_client_async/models/create_volume.py +103 -0
- northrays_api_client_async/models/display_info_response.py +103 -0
- northrays_api_client_async/models/docker_registry.py +118 -0
- northrays_api_client_async/models/download_files.py +103 -0
- northrays_api_client_async/models/execute_request.py +107 -0
- northrays_api_client_async/models/execute_response.py +105 -0
- northrays_api_client_async/models/file_info.py +117 -0
- northrays_api_client_async/models/file_status.py +109 -0
- northrays_api_client_async/models/fork_sandbox.py +103 -0
- northrays_api_client_async/models/git_add_request.py +105 -0
- northrays_api_client_async/models/git_branch_request.py +105 -0
- northrays_api_client_async/models/git_checkout_request.py +105 -0
- northrays_api_client_async/models/git_clone_request.py +113 -0
- northrays_api_client_async/models/git_commit_info.py +111 -0
- northrays_api_client_async/models/git_commit_request.py +111 -0
- northrays_api_client_async/models/git_commit_response.py +103 -0
- northrays_api_client_async/models/git_delete_branch_request.py +105 -0
- northrays_api_client_async/models/git_repo_request.py +107 -0
- northrays_api_client_async/models/git_status.py +119 -0
- northrays_api_client_async/models/gpu_type.py +43 -0
- northrays_api_client_async/models/health_controller_check200_response.py +156 -0
- northrays_api_client_async/models/health_controller_check200_response_info_value.py +103 -0
- northrays_api_client_async/models/health_controller_check503_response.py +156 -0
- northrays_api_client_async/models/job.py +123 -0
- northrays_api_client_async/models/job_status.py +45 -0
- northrays_api_client_async/models/job_type.py +56 -0
- northrays_api_client_async/models/keyboard_hotkey_request.py +103 -0
- northrays_api_client_async/models/keyboard_press_request.py +105 -0
- northrays_api_client_async/models/keyboard_type_request.py +105 -0
- northrays_api_client_async/models/list_branch_response.py +103 -0
- northrays_api_client_async/models/list_sandboxes_response.py +118 -0
- northrays_api_client_async/models/log_entry.py +119 -0
- northrays_api_client_async/models/lsp_completion_params.py +119 -0
- northrays_api_client_async/models/lsp_document_request.py +107 -0
- northrays_api_client_async/models/lsp_location.py +109 -0
- northrays_api_client_async/models/lsp_server_request.py +105 -0
- northrays_api_client_async/models/lsp_symbol.py +111 -0
- northrays_api_client_async/models/match.py +107 -0
- northrays_api_client_async/models/metric_data_point.py +105 -0
- northrays_api_client_async/models/metric_series.py +113 -0
- northrays_api_client_async/models/metrics_response.py +111 -0
- northrays_api_client_async/models/mouse_click_request.py +109 -0
- northrays_api_client_async/models/mouse_click_response.py +105 -0
- northrays_api_client_async/models/mouse_drag_request.py +111 -0
- northrays_api_client_async/models/mouse_drag_response.py +105 -0
- northrays_api_client_async/models/mouse_move_request.py +105 -0
- northrays_api_client_async/models/mouse_move_response.py +105 -0
- northrays_api_client_async/models/mouse_position.py +105 -0
- northrays_api_client_async/models/mouse_scroll_request.py +109 -0
- northrays_api_client_async/models/mouse_scroll_response.py +103 -0
- northrays_api_client_async/models/northrays_configuration.py +162 -0
- northrays_api_client_async/models/oidc_config.py +107 -0
- northrays_api_client_async/models/organization.py +191 -0
- northrays_api_client_async/models/organization_invitation.py +132 -0
- northrays_api_client_async/models/organization_role.py +116 -0
- northrays_api_client_async/models/organization_sandbox_default_limited_network_egress.py +103 -0
- northrays_api_client_async/models/organization_suspension.py +109 -0
- northrays_api_client_async/models/organization_usage_overview.py +119 -0
- northrays_api_client_async/models/organization_user.py +126 -0
- northrays_api_client_async/models/otel_config.py +110 -0
- northrays_api_client_async/models/paginated_audit_logs.py +119 -0
- northrays_api_client_async/models/paginated_jobs.py +117 -0
- northrays_api_client_async/models/paginated_logs.py +117 -0
- northrays_api_client_async/models/paginated_sandboxes_deprecated.py +117 -0
- northrays_api_client_async/models/paginated_snapshots.py +117 -0
- northrays_api_client_async/models/paginated_traces.py +117 -0
- northrays_api_client_async/models/poll_jobs_response.py +111 -0
- northrays_api_client_async/models/port_preview_url.py +107 -0
- northrays_api_client_async/models/position.py +105 -0
- northrays_api_client_async/models/posthog_config.py +105 -0
- northrays_api_client_async/models/process_errors_response.py +105 -0
- northrays_api_client_async/models/process_logs_response.py +105 -0
- northrays_api_client_async/models/process_restart_response.py +105 -0
- northrays_api_client_async/models/process_status_response.py +105 -0
- northrays_api_client_async/models/project_dir_response.py +103 -0
- northrays_api_client_async/models/pty_create_request.py +113 -0
- northrays_api_client_async/models/pty_create_response.py +103 -0
- northrays_api_client_async/models/pty_list_response.py +111 -0
- northrays_api_client_async/models/pty_resize_request.py +105 -0
- northrays_api_client_async/models/pty_session_info.py +117 -0
- northrays_api_client_async/models/range.py +112 -0
- northrays_api_client_async/models/rate_limit_config.py +122 -0
- northrays_api_client_async/models/rate_limit_entry.py +105 -0
- northrays_api_client_async/models/regenerate_api_key_response.py +103 -0
- northrays_api_client_async/models/region.py +140 -0
- northrays_api_client_async/models/region_quota.py +168 -0
- northrays_api_client_async/models/region_screenshot_response.py +107 -0
- northrays_api_client_async/models/region_type.py +44 -0
- northrays_api_client_async/models/region_usage_overview.py +174 -0
- northrays_api_client_async/models/registry_push_access_dto.py +113 -0
- northrays_api_client_async/models/replace_request.py +107 -0
- northrays_api_client_async/models/replace_result.py +107 -0
- northrays_api_client_async/models/resize_sandbox.py +108 -0
- northrays_api_client_async/models/runner.py +166 -0
- northrays_api_client_async/models/runner_class.py +42 -0
- northrays_api_client_async/models/runner_full.py +171 -0
- northrays_api_client_async/models/runner_health_metrics.py +129 -0
- northrays_api_client_async/models/runner_healthcheck.py +125 -0
- northrays_api_client_async/models/runner_service_health.py +107 -0
- northrays_api_client_async/models/runner_snapshot_dto.py +107 -0
- northrays_api_client_async/models/runner_state.py +46 -0
- northrays_api_client_async/models/sandbox.py +188 -0
- northrays_api_client_async/models/sandbox_class.py +45 -0
- northrays_api_client_async/models/sandbox_desired_state.py +47 -0
- northrays_api_client_async/models/sandbox_labels.py +103 -0
- northrays_api_client_async/models/sandbox_list_item.py +161 -0
- northrays_api_client_async/models/sandbox_list_sort_direction.py +43 -0
- northrays_api_client_async/models/sandbox_list_sort_field.py +47 -0
- northrays_api_client_async/models/sandbox_state.py +63 -0
- northrays_api_client_async/models/sandbox_volume.py +107 -0
- northrays_api_client_async/models/screenshot_response.py +107 -0
- northrays_api_client_async/models/search_files_response.py +103 -0
- northrays_api_client_async/models/send_webhook_dto.py +108 -0
- northrays_api_client_async/models/session.py +118 -0
- northrays_api_client_async/models/session_execute_request.py +107 -0
- northrays_api_client_async/models/session_execute_response.py +107 -0
- northrays_api_client_async/models/set_snapshot_general_status_dto.py +103 -0
- northrays_api_client_async/models/signed_port_preview_url.py +109 -0
- northrays_api_client_async/models/snapshot_dto.py +172 -0
- northrays_api_client_async/models/snapshot_manager_credentials.py +105 -0
- northrays_api_client_async/models/snapshot_state.py +49 -0
- northrays_api_client_async/models/ssh_access_dto.py +116 -0
- northrays_api_client_async/models/ssh_access_validation_dto.py +105 -0
- northrays_api_client_async/models/storage_access_dto.py +113 -0
- northrays_api_client_async/models/toolbox_proxy_url.py +103 -0
- northrays_api_client_async/models/trace_span.py +119 -0
- northrays_api_client_async/models/trace_summary.py +115 -0
- northrays_api_client_async/models/update_docker_registry.py +111 -0
- northrays_api_client_async/models/update_job_status.py +108 -0
- northrays_api_client_async/models/update_organization_default_region.py +103 -0
- northrays_api_client_async/models/update_organization_invitation.py +108 -0
- northrays_api_client_async/models/update_organization_member_access.py +105 -0
- northrays_api_client_async/models/update_organization_quota.py +192 -0
- northrays_api_client_async/models/update_organization_region_quota.py +189 -0
- northrays_api_client_async/models/update_organization_role.py +107 -0
- northrays_api_client_async/models/update_region.py +122 -0
- northrays_api_client_async/models/update_sandbox_network_settings.py +107 -0
- northrays_api_client_async/models/update_sandbox_state_dto.py +107 -0
- northrays_api_client_async/models/url.py +103 -0
- northrays_api_client_async/models/user.py +120 -0
- northrays_api_client_async/models/user_home_dir_response.py +103 -0
- northrays_api_client_async/models/user_public_key.py +105 -0
- northrays_api_client_async/models/volume_dto.py +128 -0
- northrays_api_client_async/models/volume_state.py +48 -0
- northrays_api_client_async/models/webhook_app_portal_access.py +105 -0
- northrays_api_client_async/models/webhook_event.py +48 -0
- northrays_api_client_async/models/webhook_initialization_status.py +123 -0
- northrays_api_client_async/models/windows_response.py +105 -0
- northrays_api_client_async/models/work_dir_response.py +103 -0
- northrays_api_client_async/py.typed +0 -0
- northrays_api_client_async/rest.py +227 -0
- northrays_toolbox_api_client/__init__.py +386 -0
- northrays_toolbox_api_client/api/__init__.py +46 -0
- northrays_toolbox_api_client/api/computer_use_api.py +9075 -0
- northrays_toolbox_api_client/api/file_system_api.py +3583 -0
- northrays_toolbox_api_client/api/git_api.py +2969 -0
- northrays_toolbox_api_client/api/info_api.py +773 -0
- northrays_toolbox_api_client/api/interpreter_api.py +1075 -0
- northrays_toolbox_api_client/api/lsp_api.py +1971 -0
- northrays_toolbox_api_client/api/port_api.py +543 -0
- northrays_toolbox_api_client/api/process_api.py +4865 -0
- northrays_toolbox_api_client/api/server_api.py +298 -0
- northrays_toolbox_api_client/api_client.py +809 -0
- northrays_toolbox_api_client/api_response.py +21 -0
- northrays_toolbox_api_client/configuration.py +626 -0
- northrays_toolbox_api_client/exceptions.py +218 -0
- northrays_toolbox_api_client/models/__init__.py +224 -0
- northrays_toolbox_api_client/models/accessibility_bounds.py +108 -0
- northrays_toolbox_api_client/models/accessibility_invoke_request.py +104 -0
- northrays_toolbox_api_client/models/accessibility_node_request.py +102 -0
- northrays_toolbox_api_client/models/accessibility_nodes_response.py +112 -0
- northrays_toolbox_api_client/models/accessibility_set_value_request.py +104 -0
- northrays_toolbox_api_client/models/accessibility_tree_response.py +108 -0
- northrays_toolbox_api_client/models/chart.py +132 -0
- northrays_toolbox_api_client/models/chart_element.py +134 -0
- northrays_toolbox_api_client/models/code_run_artifacts.py +110 -0
- northrays_toolbox_api_client/models/code_run_request.py +110 -0
- northrays_toolbox_api_client/models/code_run_response.py +110 -0
- northrays_toolbox_api_client/models/command.py +106 -0
- northrays_toolbox_api_client/models/completion_context.py +104 -0
- northrays_toolbox_api_client/models/completion_item.py +114 -0
- northrays_toolbox_api_client/models/completion_list.py +112 -0
- northrays_toolbox_api_client/models/computer_use_accessibility_node.py +129 -0
- northrays_toolbox_api_client/models/computer_use_start_response.py +117 -0
- northrays_toolbox_api_client/models/computer_use_status_response.py +102 -0
- northrays_toolbox_api_client/models/computer_use_stop_response.py +117 -0
- northrays_toolbox_api_client/models/create_context_request.py +104 -0
- northrays_toolbox_api_client/models/create_session_request.py +102 -0
- northrays_toolbox_api_client/models/display_info.py +112 -0
- northrays_toolbox_api_client/models/display_info_response.py +110 -0
- northrays_toolbox_api_client/models/execute_request.py +108 -0
- northrays_toolbox_api_client/models/execute_response.py +104 -0
- northrays_toolbox_api_client/models/file_info.py +118 -0
- northrays_toolbox_api_client/models/file_status.py +109 -0
- northrays_toolbox_api_client/models/files_download_request.py +102 -0
- northrays_toolbox_api_client/models/find_accessibility_nodes_request.py +114 -0
- northrays_toolbox_api_client/models/git_add_request.py +104 -0
- northrays_toolbox_api_client/models/git_branch_request.py +104 -0
- northrays_toolbox_api_client/models/git_checkout_request.py +104 -0
- northrays_toolbox_api_client/models/git_clone_request.py +114 -0
- northrays_toolbox_api_client/models/git_commit_info.py +110 -0
- northrays_toolbox_api_client/models/git_commit_request.py +110 -0
- northrays_toolbox_api_client/models/git_commit_response.py +102 -0
- northrays_toolbox_api_client/models/git_delete_branch_request.py +104 -0
- northrays_toolbox_api_client/models/git_repo_request.py +106 -0
- northrays_toolbox_api_client/models/git_status.py +118 -0
- northrays_toolbox_api_client/models/initialize_request.py +102 -0
- northrays_toolbox_api_client/models/interpreter_context.py +110 -0
- northrays_toolbox_api_client/models/is_port_in_use_response.py +102 -0
- northrays_toolbox_api_client/models/keyboard_hotkey_request.py +102 -0
- northrays_toolbox_api_client/models/keyboard_press_request.py +104 -0
- northrays_toolbox_api_client/models/keyboard_type_request.py +104 -0
- northrays_toolbox_api_client/models/list_branch_response.py +102 -0
- northrays_toolbox_api_client/models/list_contexts_response.py +110 -0
- northrays_toolbox_api_client/models/list_recordings_response.py +110 -0
- northrays_toolbox_api_client/models/lsp_completion_params.py +118 -0
- northrays_toolbox_api_client/models/lsp_document_request.py +106 -0
- northrays_toolbox_api_client/models/lsp_location.py +108 -0
- northrays_toolbox_api_client/models/lsp_position.py +104 -0
- northrays_toolbox_api_client/models/lsp_range.py +111 -0
- northrays_toolbox_api_client/models/lsp_server_request.py +104 -0
- northrays_toolbox_api_client/models/lsp_symbol.py +110 -0
- northrays_toolbox_api_client/models/match.py +106 -0
- northrays_toolbox_api_client/models/mouse_click_request.py +108 -0
- northrays_toolbox_api_client/models/mouse_click_response.py +104 -0
- northrays_toolbox_api_client/models/mouse_drag_request.py +110 -0
- northrays_toolbox_api_client/models/mouse_drag_response.py +104 -0
- northrays_toolbox_api_client/models/mouse_move_request.py +104 -0
- northrays_toolbox_api_client/models/mouse_position_response.py +104 -0
- northrays_toolbox_api_client/models/mouse_scroll_request.py +109 -0
- northrays_toolbox_api_client/models/port_list.py +102 -0
- northrays_toolbox_api_client/models/position.py +104 -0
- northrays_toolbox_api_client/models/process_errors_response.py +104 -0
- northrays_toolbox_api_client/models/process_logs_response.py +104 -0
- northrays_toolbox_api_client/models/process_restart_response.py +104 -0
- northrays_toolbox_api_client/models/process_status.py +108 -0
- northrays_toolbox_api_client/models/process_status_response.py +104 -0
- northrays_toolbox_api_client/models/pty_create_request.py +112 -0
- northrays_toolbox_api_client/models/pty_create_response.py +102 -0
- northrays_toolbox_api_client/models/pty_list_response.py +110 -0
- northrays_toolbox_api_client/models/pty_resize_request.py +105 -0
- northrays_toolbox_api_client/models/pty_session_info.py +116 -0
- northrays_toolbox_api_client/models/recording.py +116 -0
- northrays_toolbox_api_client/models/replace_request.py +106 -0
- northrays_toolbox_api_client/models/replace_result.py +106 -0
- northrays_toolbox_api_client/models/screenshot_response.py +110 -0
- northrays_toolbox_api_client/models/scroll_response.py +102 -0
- northrays_toolbox_api_client/models/search_files_response.py +102 -0
- northrays_toolbox_api_client/models/session.py +112 -0
- northrays_toolbox_api_client/models/session_command_logs_response.py +106 -0
- northrays_toolbox_api_client/models/session_execute_request.py +108 -0
- northrays_toolbox_api_client/models/session_execute_response.py +110 -0
- northrays_toolbox_api_client/models/session_send_input_request.py +102 -0
- northrays_toolbox_api_client/models/start_recording_request.py +102 -0
- northrays_toolbox_api_client/models/status.py +48 -0
- northrays_toolbox_api_client/models/stop_recording_request.py +102 -0
- northrays_toolbox_api_client/models/user_home_dir_response.py +102 -0
- northrays_toolbox_api_client/models/window_info.py +114 -0
- northrays_toolbox_api_client/models/windows_response.py +110 -0
- northrays_toolbox_api_client/models/work_dir_response.py +102 -0
- northrays_toolbox_api_client/py.typed +0 -0
- northrays_toolbox_api_client/rest.py +263 -0
- northrays_toolbox_api_client_async/__init__.py +386 -0
- northrays_toolbox_api_client_async/api/__init__.py +46 -0
- northrays_toolbox_api_client_async/api/computer_use_api.py +9075 -0
- northrays_toolbox_api_client_async/api/file_system_api.py +3583 -0
- northrays_toolbox_api_client_async/api/git_api.py +2969 -0
- northrays_toolbox_api_client_async/api/info_api.py +773 -0
- northrays_toolbox_api_client_async/api/interpreter_api.py +1075 -0
- northrays_toolbox_api_client_async/api/lsp_api.py +1971 -0
- northrays_toolbox_api_client_async/api/port_api.py +543 -0
- northrays_toolbox_api_client_async/api/process_api.py +4865 -0
- northrays_toolbox_api_client_async/api/server_api.py +298 -0
- northrays_toolbox_api_client_async/api_client.py +812 -0
- northrays_toolbox_api_client_async/api_response.py +21 -0
- northrays_toolbox_api_client_async/configuration.py +624 -0
- northrays_toolbox_api_client_async/exceptions.py +218 -0
- northrays_toolbox_api_client_async/models/__init__.py +224 -0
- northrays_toolbox_api_client_async/models/accessibility_bounds.py +108 -0
- northrays_toolbox_api_client_async/models/accessibility_invoke_request.py +104 -0
- northrays_toolbox_api_client_async/models/accessibility_node_request.py +102 -0
- northrays_toolbox_api_client_async/models/accessibility_nodes_response.py +112 -0
- northrays_toolbox_api_client_async/models/accessibility_set_value_request.py +104 -0
- northrays_toolbox_api_client_async/models/accessibility_tree_response.py +108 -0
- northrays_toolbox_api_client_async/models/chart.py +132 -0
- northrays_toolbox_api_client_async/models/chart_element.py +134 -0
- northrays_toolbox_api_client_async/models/code_run_artifacts.py +110 -0
- northrays_toolbox_api_client_async/models/code_run_request.py +110 -0
- northrays_toolbox_api_client_async/models/code_run_response.py +110 -0
- northrays_toolbox_api_client_async/models/command.py +106 -0
- northrays_toolbox_api_client_async/models/completion_context.py +104 -0
- northrays_toolbox_api_client_async/models/completion_item.py +114 -0
- northrays_toolbox_api_client_async/models/completion_list.py +112 -0
- northrays_toolbox_api_client_async/models/computer_use_accessibility_node.py +129 -0
- northrays_toolbox_api_client_async/models/computer_use_start_response.py +117 -0
- northrays_toolbox_api_client_async/models/computer_use_status_response.py +102 -0
- northrays_toolbox_api_client_async/models/computer_use_stop_response.py +117 -0
- northrays_toolbox_api_client_async/models/create_context_request.py +104 -0
- northrays_toolbox_api_client_async/models/create_session_request.py +102 -0
- northrays_toolbox_api_client_async/models/display_info.py +112 -0
- northrays_toolbox_api_client_async/models/display_info_response.py +110 -0
- northrays_toolbox_api_client_async/models/execute_request.py +108 -0
- northrays_toolbox_api_client_async/models/execute_response.py +104 -0
- northrays_toolbox_api_client_async/models/file_info.py +118 -0
- northrays_toolbox_api_client_async/models/file_status.py +109 -0
- northrays_toolbox_api_client_async/models/files_download_request.py +102 -0
- northrays_toolbox_api_client_async/models/find_accessibility_nodes_request.py +114 -0
- northrays_toolbox_api_client_async/models/git_add_request.py +104 -0
- northrays_toolbox_api_client_async/models/git_branch_request.py +104 -0
- northrays_toolbox_api_client_async/models/git_checkout_request.py +104 -0
- northrays_toolbox_api_client_async/models/git_clone_request.py +114 -0
- northrays_toolbox_api_client_async/models/git_commit_info.py +110 -0
- northrays_toolbox_api_client_async/models/git_commit_request.py +110 -0
- northrays_toolbox_api_client_async/models/git_commit_response.py +102 -0
- northrays_toolbox_api_client_async/models/git_delete_branch_request.py +104 -0
- northrays_toolbox_api_client_async/models/git_repo_request.py +106 -0
- northrays_toolbox_api_client_async/models/git_status.py +118 -0
- northrays_toolbox_api_client_async/models/initialize_request.py +102 -0
- northrays_toolbox_api_client_async/models/interpreter_context.py +110 -0
- northrays_toolbox_api_client_async/models/is_port_in_use_response.py +102 -0
- northrays_toolbox_api_client_async/models/keyboard_hotkey_request.py +102 -0
- northrays_toolbox_api_client_async/models/keyboard_press_request.py +104 -0
- northrays_toolbox_api_client_async/models/keyboard_type_request.py +104 -0
- northrays_toolbox_api_client_async/models/list_branch_response.py +102 -0
- northrays_toolbox_api_client_async/models/list_contexts_response.py +110 -0
- northrays_toolbox_api_client_async/models/list_recordings_response.py +110 -0
- northrays_toolbox_api_client_async/models/lsp_completion_params.py +118 -0
- northrays_toolbox_api_client_async/models/lsp_document_request.py +106 -0
- northrays_toolbox_api_client_async/models/lsp_location.py +108 -0
- northrays_toolbox_api_client_async/models/lsp_position.py +104 -0
- northrays_toolbox_api_client_async/models/lsp_range.py +111 -0
- northrays_toolbox_api_client_async/models/lsp_server_request.py +104 -0
- northrays_toolbox_api_client_async/models/lsp_symbol.py +110 -0
- northrays_toolbox_api_client_async/models/match.py +106 -0
- northrays_toolbox_api_client_async/models/mouse_click_request.py +108 -0
- northrays_toolbox_api_client_async/models/mouse_click_response.py +104 -0
- northrays_toolbox_api_client_async/models/mouse_drag_request.py +110 -0
- northrays_toolbox_api_client_async/models/mouse_drag_response.py +104 -0
- northrays_toolbox_api_client_async/models/mouse_move_request.py +104 -0
- northrays_toolbox_api_client_async/models/mouse_position_response.py +104 -0
- northrays_toolbox_api_client_async/models/mouse_scroll_request.py +109 -0
- northrays_toolbox_api_client_async/models/port_list.py +102 -0
- northrays_toolbox_api_client_async/models/position.py +104 -0
- northrays_toolbox_api_client_async/models/process_errors_response.py +104 -0
- northrays_toolbox_api_client_async/models/process_logs_response.py +104 -0
- northrays_toolbox_api_client_async/models/process_restart_response.py +104 -0
- northrays_toolbox_api_client_async/models/process_status.py +108 -0
- northrays_toolbox_api_client_async/models/process_status_response.py +104 -0
- northrays_toolbox_api_client_async/models/pty_create_request.py +112 -0
- northrays_toolbox_api_client_async/models/pty_create_response.py +102 -0
- northrays_toolbox_api_client_async/models/pty_list_response.py +110 -0
- northrays_toolbox_api_client_async/models/pty_resize_request.py +105 -0
- northrays_toolbox_api_client_async/models/pty_session_info.py +116 -0
- northrays_toolbox_api_client_async/models/recording.py +116 -0
- northrays_toolbox_api_client_async/models/replace_request.py +106 -0
- northrays_toolbox_api_client_async/models/replace_result.py +106 -0
- northrays_toolbox_api_client_async/models/screenshot_response.py +110 -0
- northrays_toolbox_api_client_async/models/scroll_response.py +102 -0
- northrays_toolbox_api_client_async/models/search_files_response.py +102 -0
- northrays_toolbox_api_client_async/models/session.py +112 -0
- northrays_toolbox_api_client_async/models/session_command_logs_response.py +106 -0
- northrays_toolbox_api_client_async/models/session_execute_request.py +108 -0
- northrays_toolbox_api_client_async/models/session_execute_response.py +110 -0
- northrays_toolbox_api_client_async/models/session_send_input_request.py +102 -0
- northrays_toolbox_api_client_async/models/start_recording_request.py +102 -0
- northrays_toolbox_api_client_async/models/status.py +48 -0
- northrays_toolbox_api_client_async/models/stop_recording_request.py +102 -0
- northrays_toolbox_api_client_async/models/user_home_dir_response.py +102 -0
- northrays_toolbox_api_client_async/models/window_info.py +114 -0
- northrays_toolbox_api_client_async/models/windows_response.py +110 -0
- northrays_toolbox_api_client_async/models/work_dir_response.py +102 -0
- northrays_toolbox_api_client_async/py.typed +0 -0
- northrays_toolbox_api_client_async/rest.py +226 -0
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
# Copyright 2025 Daytona Platforms Inc.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from collections.abc import Awaitable, Callable
|
|
7
|
+
|
|
8
|
+
import aiohttp
|
|
9
|
+
|
|
10
|
+
from northrays_toolbox_api_client_async import (
|
|
11
|
+
CodeRunRequest,
|
|
12
|
+
Command,
|
|
13
|
+
CreateSessionRequest,
|
|
14
|
+
ExecuteRequest,
|
|
15
|
+
ProcessApi,
|
|
16
|
+
PtyCreateRequest,
|
|
17
|
+
PtyResizeRequest,
|
|
18
|
+
PtySessionInfo,
|
|
19
|
+
Session,
|
|
20
|
+
SessionSendInputRequest,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
from .._utils.errors import intercept_errors
|
|
24
|
+
from .._utils.otel_decorator import with_instrumentation
|
|
25
|
+
from .._utils.stream import std_demux_stream_aio
|
|
26
|
+
from .._utils.timeout import http_timeout
|
|
27
|
+
from ..common.charts import parse_chart
|
|
28
|
+
from ..common.process import (
|
|
29
|
+
CodeRunParams,
|
|
30
|
+
ExecuteResponse,
|
|
31
|
+
ExecutionArtifacts,
|
|
32
|
+
OutputHandler,
|
|
33
|
+
SessionCommandLogsResponse,
|
|
34
|
+
SessionExecuteRequest,
|
|
35
|
+
SessionExecuteResponse,
|
|
36
|
+
)
|
|
37
|
+
from ..common.pty import PtySize
|
|
38
|
+
from ..handle.async_pty_handle import AsyncPtyHandle
|
|
39
|
+
from ..internal.shared_session import http_session_of
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class AsyncProcess:
|
|
43
|
+
"""Handles process and code execution within a Sandbox."""
|
|
44
|
+
|
|
45
|
+
def __init__(
|
|
46
|
+
self,
|
|
47
|
+
language: str,
|
|
48
|
+
api_client: ProcessApi,
|
|
49
|
+
):
|
|
50
|
+
"""Initialize a new Process instance.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
api_client (ProcessApi): API client for process operations.
|
|
54
|
+
"""
|
|
55
|
+
self._language: str = language
|
|
56
|
+
self._api_client: ProcessApi = api_client
|
|
57
|
+
|
|
58
|
+
async def _open_ws(
|
|
59
|
+
self,
|
|
60
|
+
url: str,
|
|
61
|
+
headers: dict[str, str],
|
|
62
|
+
) -> aiohttp.ClientWebSocketResponse:
|
|
63
|
+
return await http_session_of(self._api_client.api_client).ws_connect(url, headers=headers)
|
|
64
|
+
|
|
65
|
+
async def _consume_log_websocket(
|
|
66
|
+
self,
|
|
67
|
+
url: str,
|
|
68
|
+
headers: dict[str, str],
|
|
69
|
+
on_stdout: OutputHandler[str],
|
|
70
|
+
on_stderr: OutputHandler[str],
|
|
71
|
+
) -> None:
|
|
72
|
+
"""Open a log-streaming WebSocket, demultiplex stdout/stderr until EOF, then close."""
|
|
73
|
+
ws = await self._open_ws(url, headers)
|
|
74
|
+
try:
|
|
75
|
+
await std_demux_stream_aio(ws, on_stdout, on_stderr)
|
|
76
|
+
finally:
|
|
77
|
+
if not ws.closed:
|
|
78
|
+
_ = await ws.close()
|
|
79
|
+
|
|
80
|
+
@intercept_errors(message_prefix="Failed to execute command: ")
|
|
81
|
+
@with_instrumentation()
|
|
82
|
+
async def exec(
|
|
83
|
+
self,
|
|
84
|
+
command: str,
|
|
85
|
+
cwd: str | None = None,
|
|
86
|
+
env: dict[str, str] | None = None,
|
|
87
|
+
timeout: int | None = None,
|
|
88
|
+
) -> ExecuteResponse:
|
|
89
|
+
"""Execute a shell command in the Sandbox.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
command (str): Shell command to execute.
|
|
93
|
+
cwd (str | None): Working directory for command execution. If not
|
|
94
|
+
specified, uses the sandbox working directory.
|
|
95
|
+
env (dict[str, str] | None): Environment variables to set for the command.
|
|
96
|
+
timeout (int | None): Maximum time in seconds to wait for the command
|
|
97
|
+
to complete.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
ExecuteResponse: Command execution results containing:
|
|
101
|
+
- exit_code: The command's exit status
|
|
102
|
+
- result: Standard output from the command
|
|
103
|
+
- artifacts: ExecutionArtifacts object containing `stdout` (same as result)
|
|
104
|
+
and `charts` (matplotlib charts metadata)
|
|
105
|
+
|
|
106
|
+
Example:
|
|
107
|
+
```python
|
|
108
|
+
# Simple command
|
|
109
|
+
response = await sandbox.process.exec("echo 'Hello'")
|
|
110
|
+
print(response.artifacts.stdout) # Prints: Hello
|
|
111
|
+
|
|
112
|
+
# Command with working directory
|
|
113
|
+
result = await sandbox.process.exec("ls", cwd="workspace/src")
|
|
114
|
+
|
|
115
|
+
# Command with timeout
|
|
116
|
+
result = await sandbox.process.exec("sleep 10", timeout=5)
|
|
117
|
+
```
|
|
118
|
+
"""
|
|
119
|
+
execute_request = ExecuteRequest(command=command, cwd=cwd, timeout=timeout, envs=env)
|
|
120
|
+
|
|
121
|
+
response = await self._api_client.execute_command(
|
|
122
|
+
request=execute_request,
|
|
123
|
+
_request_timeout=http_timeout(timeout + 5 if timeout else None),
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
result = response.result or ""
|
|
127
|
+
artifacts = ExecutionArtifacts(stdout=result, charts=[])
|
|
128
|
+
|
|
129
|
+
# TODO: Remove model_construct once everything is migrated to pydantic # pylint: disable=fixme
|
|
130
|
+
return ExecuteResponse.model_construct(
|
|
131
|
+
exit_code=(
|
|
132
|
+
response.exit_code if response.exit_code is not None else response.additional_properties.get("code")
|
|
133
|
+
),
|
|
134
|
+
result=result,
|
|
135
|
+
artifacts=artifacts,
|
|
136
|
+
additional_properties=response.additional_properties,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
@with_instrumentation()
|
|
140
|
+
async def code_run(
|
|
141
|
+
self,
|
|
142
|
+
code: str,
|
|
143
|
+
params: CodeRunParams | None = None,
|
|
144
|
+
timeout: int | None = None,
|
|
145
|
+
) -> ExecuteResponse:
|
|
146
|
+
"""Executes code in the Sandbox using the appropriate language runtime.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
code (str): Code to execute.
|
|
150
|
+
params (CodeRunParams | None): Parameters for code execution.
|
|
151
|
+
timeout (int | None): Maximum time in seconds to wait for the code
|
|
152
|
+
to complete.
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
ExecuteResponse: Code execution result containing:
|
|
156
|
+
- exit_code: The execution's exit status
|
|
157
|
+
- result: Standard output from the code
|
|
158
|
+
- artifacts: ExecutionArtifacts object containing `stdout` (same as result)
|
|
159
|
+
and `charts` (matplotlib charts metadata)
|
|
160
|
+
|
|
161
|
+
Example:
|
|
162
|
+
```python
|
|
163
|
+
# Run Python code
|
|
164
|
+
response = await sandbox.process.code_run('''
|
|
165
|
+
x = 10
|
|
166
|
+
y = 20
|
|
167
|
+
print(f"Sum: {x + y}")
|
|
168
|
+
''')
|
|
169
|
+
print(response.artifacts.stdout) # Prints: Sum: 30
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Matplotlib charts are automatically detected and returned in the `charts` field
|
|
173
|
+
of the `ExecutionArtifacts` object.
|
|
174
|
+
```python
|
|
175
|
+
code = '''
|
|
176
|
+
import matplotlib.pyplot as plt
|
|
177
|
+
import numpy as np
|
|
178
|
+
|
|
179
|
+
x = np.linspace(0, 10, 30)
|
|
180
|
+
y = np.sin(x)
|
|
181
|
+
|
|
182
|
+
plt.figure(figsize=(8, 5))
|
|
183
|
+
plt.plot(x, y, 'b-', linewidth=2)
|
|
184
|
+
plt.title('Line Chart')
|
|
185
|
+
plt.xlabel('X-axis (seconds)')
|
|
186
|
+
plt.ylabel('Y-axis (amplitude)')
|
|
187
|
+
plt.grid(True)
|
|
188
|
+
plt.show()
|
|
189
|
+
'''
|
|
190
|
+
|
|
191
|
+
response = await sandbox.process.code_run(code)
|
|
192
|
+
chart = response.artifacts.charts[0]
|
|
193
|
+
|
|
194
|
+
print(f"Type: {chart.type}")
|
|
195
|
+
print(f"Title: {chart.title}")
|
|
196
|
+
if chart.type == ChartType.LINE and isinstance(chart, LineChart):
|
|
197
|
+
print(f"X Label: {chart.x_label}")
|
|
198
|
+
print(f"Y Label: {chart.y_label}")
|
|
199
|
+
print(f"X Ticks: {chart.x_ticks}")
|
|
200
|
+
print(f"X Tick Labels: {chart.x_tick_labels}")
|
|
201
|
+
print(f"X Scale: {chart.x_scale}")
|
|
202
|
+
print(f"Y Ticks: {chart.y_ticks}")
|
|
203
|
+
print(f"Y Tick Labels: {chart.y_tick_labels}")
|
|
204
|
+
print(f"Y Scale: {chart.y_scale}")
|
|
205
|
+
print("Elements:")
|
|
206
|
+
for element in chart.elements:
|
|
207
|
+
print(f"Label: {element.label}")
|
|
208
|
+
print(f"Points: {element.points}")
|
|
209
|
+
```
|
|
210
|
+
"""
|
|
211
|
+
code_run_params = params or CodeRunParams()
|
|
212
|
+
code_run_request = CodeRunRequest(
|
|
213
|
+
code=code,
|
|
214
|
+
language=self._language,
|
|
215
|
+
argv=code_run_params.argv,
|
|
216
|
+
envs=code_run_params.env,
|
|
217
|
+
timeout=timeout,
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
response = await self._api_client.code_run(
|
|
221
|
+
request=code_run_request,
|
|
222
|
+
_request_timeout=http_timeout(timeout + 5 if timeout else None),
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
stdout = response.result or ""
|
|
226
|
+
charts = []
|
|
227
|
+
if response.artifacts and response.artifacts.charts:
|
|
228
|
+
charts = [parse_chart(chart) for chart in response.artifacts.charts]
|
|
229
|
+
artifacts = ExecutionArtifacts(stdout=stdout, charts=charts)
|
|
230
|
+
|
|
231
|
+
# TODO: Remove model_construct once everything is migrated to pydantic # pylint: disable=fixme
|
|
232
|
+
return ExecuteResponse.model_construct(
|
|
233
|
+
exit_code=(
|
|
234
|
+
response.exit_code if response.exit_code is not None else response.additional_properties.get("code")
|
|
235
|
+
),
|
|
236
|
+
result=stdout,
|
|
237
|
+
artifacts=artifacts,
|
|
238
|
+
additional_properties=response.additional_properties,
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
@intercept_errors(message_prefix="Failed to create session: ")
|
|
242
|
+
@with_instrumentation()
|
|
243
|
+
async def create_session(self, session_id: str) -> None:
|
|
244
|
+
"""Creates a new long-running background session in the Sandbox.
|
|
245
|
+
|
|
246
|
+
Sessions are background processes that maintain state between commands, making them ideal for
|
|
247
|
+
scenarios requiring multiple related commands or persistent environment setup. You can run
|
|
248
|
+
long-running commands and monitor process status.
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
session_id (str): Unique identifier for the new session.
|
|
252
|
+
|
|
253
|
+
Example:
|
|
254
|
+
```python
|
|
255
|
+
# Create a new session
|
|
256
|
+
session_id = "my-session"
|
|
257
|
+
await sandbox.process.create_session(session_id)
|
|
258
|
+
session = await sandbox.process.get_session(session_id)
|
|
259
|
+
# Do work...
|
|
260
|
+
await sandbox.process.delete_session(session_id)
|
|
261
|
+
```
|
|
262
|
+
"""
|
|
263
|
+
request = CreateSessionRequest(session_id=session_id)
|
|
264
|
+
await self._api_client.create_session(request=request)
|
|
265
|
+
|
|
266
|
+
@intercept_errors(message_prefix="Failed to get session: ")
|
|
267
|
+
async def get_session(self, session_id: str) -> Session:
|
|
268
|
+
"""Gets a session in the Sandbox.
|
|
269
|
+
|
|
270
|
+
Args:
|
|
271
|
+
session_id (str): Unique identifier of the session to retrieve.
|
|
272
|
+
|
|
273
|
+
Returns:
|
|
274
|
+
Session: Session information including:
|
|
275
|
+
- session_id: The session's unique identifier
|
|
276
|
+
- commands: List of commands executed in the session
|
|
277
|
+
|
|
278
|
+
Example:
|
|
279
|
+
```python
|
|
280
|
+
session = await sandbox.process.get_session("my-session")
|
|
281
|
+
for cmd in session.commands:
|
|
282
|
+
print(f"Command: {cmd.command}")
|
|
283
|
+
```
|
|
284
|
+
"""
|
|
285
|
+
return await self._api_client.get_session(session_id=session_id)
|
|
286
|
+
|
|
287
|
+
@intercept_errors(message_prefix="Failed to get sandbox entrypoint session: ")
|
|
288
|
+
async def get_entrypoint_session(self) -> Session:
|
|
289
|
+
"""Gets the sandbox entrypoint session.
|
|
290
|
+
|
|
291
|
+
Returns:
|
|
292
|
+
Session: Entrypoint session information including:
|
|
293
|
+
- session_id: The entrypoint session's unique identifier
|
|
294
|
+
- commands: List of commands executed in the entrypoint session
|
|
295
|
+
|
|
296
|
+
Example:
|
|
297
|
+
```python
|
|
298
|
+
session = await sandbox.process.get_entrypoint_session()
|
|
299
|
+
for cmd in session.commands:
|
|
300
|
+
print(f"Command: {cmd.command}")
|
|
301
|
+
```
|
|
302
|
+
"""
|
|
303
|
+
return await self._api_client.get_entrypoint_session()
|
|
304
|
+
|
|
305
|
+
@intercept_errors(message_prefix="Failed to get session command: ")
|
|
306
|
+
@with_instrumentation()
|
|
307
|
+
async def get_session_command(self, session_id: str, command_id: str) -> Command:
|
|
308
|
+
"""Gets information about a specific command executed in a session.
|
|
309
|
+
|
|
310
|
+
Args:
|
|
311
|
+
session_id (str): Unique identifier of the session.
|
|
312
|
+
command_id (str): Unique identifier of the command.
|
|
313
|
+
|
|
314
|
+
Returns:
|
|
315
|
+
Command: Command information including:
|
|
316
|
+
- id: The command's unique identifier
|
|
317
|
+
- command: The executed command string
|
|
318
|
+
- exit_code: Command's exit status (if completed)
|
|
319
|
+
|
|
320
|
+
Example:
|
|
321
|
+
```python
|
|
322
|
+
cmd = await sandbox.process.get_session_command("my-session", "cmd-123")
|
|
323
|
+
if cmd.exit_code == 0:
|
|
324
|
+
print(f"Command {cmd.command} completed successfully")
|
|
325
|
+
```
|
|
326
|
+
"""
|
|
327
|
+
return await self._api_client.get_session_command(session_id=session_id, command_id=command_id)
|
|
328
|
+
|
|
329
|
+
@intercept_errors(message_prefix="Failed to execute session command: ")
|
|
330
|
+
@with_instrumentation()
|
|
331
|
+
async def execute_session_command(
|
|
332
|
+
self,
|
|
333
|
+
session_id: str,
|
|
334
|
+
req: SessionExecuteRequest,
|
|
335
|
+
timeout: int | None = None,
|
|
336
|
+
) -> SessionExecuteResponse:
|
|
337
|
+
"""Executes a command in the session.
|
|
338
|
+
|
|
339
|
+
Args:
|
|
340
|
+
session_id (str): Unique identifier of the session to use.
|
|
341
|
+
req (SessionExecuteRequest): Command execution request containing:
|
|
342
|
+
- command: The command to execute
|
|
343
|
+
- run_async: Whether to execute asynchronously
|
|
344
|
+
|
|
345
|
+
Returns:
|
|
346
|
+
SessionExecuteResponse: Command execution results containing:
|
|
347
|
+
- cmd_id: Unique identifier for the executed command
|
|
348
|
+
- output: Combined command output (stdout and stderr) (if synchronous execution)
|
|
349
|
+
- stdout: Standard output from the command
|
|
350
|
+
- stderr: Standard error from the command
|
|
351
|
+
- exit_code: Command exit status (if synchronous execution)
|
|
352
|
+
|
|
353
|
+
Example:
|
|
354
|
+
```python
|
|
355
|
+
# Execute commands in sequence, maintaining state
|
|
356
|
+
session_id = "my-session"
|
|
357
|
+
|
|
358
|
+
# Change directory
|
|
359
|
+
req = SessionExecuteRequest(command="cd /workspace")
|
|
360
|
+
await sandbox.process.execute_session_command(session_id, req)
|
|
361
|
+
|
|
362
|
+
# Create a file
|
|
363
|
+
req = SessionExecuteRequest(command="echo 'Hello' > test.txt")
|
|
364
|
+
await sandbox.process.execute_session_command(session_id, req)
|
|
365
|
+
|
|
366
|
+
# Read the file
|
|
367
|
+
req = SessionExecuteRequest(command="cat test.txt")
|
|
368
|
+
result = await sandbox.process.execute_session_command(session_id, req)
|
|
369
|
+
print(f"Command stdout: {result.stdout}")
|
|
370
|
+
print(f"Command stderr: {result.stderr}")
|
|
371
|
+
```
|
|
372
|
+
"""
|
|
373
|
+
response = await self._api_client.session_execute_command(
|
|
374
|
+
session_id=session_id,
|
|
375
|
+
request=req,
|
|
376
|
+
_request_timeout=http_timeout(timeout + 5 if timeout else None),
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
return SessionExecuteResponse.model_construct(
|
|
380
|
+
cmd_id=response.cmd_id,
|
|
381
|
+
output=response.output,
|
|
382
|
+
stdout=response.stdout or "",
|
|
383
|
+
stderr=response.stderr or "",
|
|
384
|
+
exit_code=response.exit_code,
|
|
385
|
+
additional_properties=response.additional_properties,
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
@intercept_errors(message_prefix="Failed to get session command logs: ")
|
|
389
|
+
@with_instrumentation()
|
|
390
|
+
async def get_session_command_logs(self, session_id: str, command_id: str) -> SessionCommandLogsResponse:
|
|
391
|
+
"""Get the logs for a command executed in a session.
|
|
392
|
+
|
|
393
|
+
Args:
|
|
394
|
+
session_id (str): Unique identifier of the session.
|
|
395
|
+
command_id (str): Unique identifier of the command.
|
|
396
|
+
|
|
397
|
+
Returns:
|
|
398
|
+
SessionCommandLogsResponse: Command logs including:
|
|
399
|
+
- output: Combined command output (stdout and stderr)
|
|
400
|
+
- stdout: Standard output from the command
|
|
401
|
+
- stderr: Standard error from the command
|
|
402
|
+
|
|
403
|
+
Example:
|
|
404
|
+
```python
|
|
405
|
+
logs = await sandbox.process.get_session_command_logs(
|
|
406
|
+
"my-session",
|
|
407
|
+
"cmd-123"
|
|
408
|
+
)
|
|
409
|
+
print(f"Command stdout: {logs.stdout}")
|
|
410
|
+
print(f"Command stderr: {logs.stderr}")
|
|
411
|
+
```
|
|
412
|
+
"""
|
|
413
|
+
response = await self._api_client.get_session_command_logs(session_id=session_id, command_id=command_id)
|
|
414
|
+
|
|
415
|
+
return SessionCommandLogsResponse(output=response.output, stdout=response.stdout, stderr=response.stderr)
|
|
416
|
+
|
|
417
|
+
@intercept_errors(message_prefix="Failed to get session command logs: ")
|
|
418
|
+
async def get_session_command_logs_async(
|
|
419
|
+
self, session_id: str, command_id: str, on_stdout: OutputHandler[str], on_stderr: OutputHandler[str]
|
|
420
|
+
) -> None:
|
|
421
|
+
"""Asynchronously retrieves and processes the logs for a command executed in a session as they become available.
|
|
422
|
+
|
|
423
|
+
Accepts both sync and async callbacks. Async callbacks are awaited.
|
|
424
|
+
Blocking synchronous operations inside callbacks may cause WebSocket
|
|
425
|
+
disconnections — use async callbacks and async libraries to avoid this.
|
|
426
|
+
|
|
427
|
+
Args:
|
|
428
|
+
session_id (str): Unique identifier of the session.
|
|
429
|
+
command_id (str): Unique identifier of the command.
|
|
430
|
+
on_stdout (OutputHandler[str]): Callback function to handle stdout log chunks as they arrive.
|
|
431
|
+
on_stderr (OutputHandler[str]): Callback function to handle stderr log chunks as they arrive.
|
|
432
|
+
|
|
433
|
+
Example:
|
|
434
|
+
```python
|
|
435
|
+
await sandbox.process.get_session_command_logs_async(
|
|
436
|
+
"my-session",
|
|
437
|
+
"cmd-123",
|
|
438
|
+
lambda log: print(f"[STDOUT]: {log}"),
|
|
439
|
+
lambda log: print(f"[STDERR]: {log}"),
|
|
440
|
+
)
|
|
441
|
+
```
|
|
442
|
+
"""
|
|
443
|
+
_, url, headers, *_ = self._api_client._get_session_command_logs_serialize(
|
|
444
|
+
session_id=session_id,
|
|
445
|
+
command_id=command_id,
|
|
446
|
+
follow=True,
|
|
447
|
+
_request_auth=None,
|
|
448
|
+
_content_type=None,
|
|
449
|
+
_headers=None,
|
|
450
|
+
_host_index=None,
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
url = re.sub(r"^http", "ws", url)
|
|
454
|
+
|
|
455
|
+
await self._consume_log_websocket(url, headers, on_stdout, on_stderr)
|
|
456
|
+
|
|
457
|
+
@intercept_errors(message_prefix="Failed to get entrypoint logs: ")
|
|
458
|
+
@with_instrumentation()
|
|
459
|
+
async def get_entrypoint_logs(self) -> SessionCommandLogsResponse:
|
|
460
|
+
"""Get the logs for the entrypoint session.
|
|
461
|
+
|
|
462
|
+
Returns:
|
|
463
|
+
SessionCommandLogsResponse: Command logs including:
|
|
464
|
+
- output: Combined command output (stdout and stderr)
|
|
465
|
+
- stdout: Standard output from the command
|
|
466
|
+
- stderr: Standard error from the command
|
|
467
|
+
|
|
468
|
+
Example:
|
|
469
|
+
```python
|
|
470
|
+
logs = await sandbox.process.get_entrypoint_logs()
|
|
471
|
+
print(f"Command stdout: {logs.stdout}")
|
|
472
|
+
print(f"Command stderr: {logs.stderr}")
|
|
473
|
+
```
|
|
474
|
+
"""
|
|
475
|
+
response = await self._api_client.get_entrypoint_logs()
|
|
476
|
+
|
|
477
|
+
return SessionCommandLogsResponse(output=response.output, stdout=response.stdout, stderr=response.stderr)
|
|
478
|
+
|
|
479
|
+
@intercept_errors(message_prefix="Failed to get entrypoint logs: ")
|
|
480
|
+
async def get_entrypoint_logs_async(self, on_stdout: OutputHandler[str], on_stderr: OutputHandler[str]) -> None:
|
|
481
|
+
"""Asynchronously retrieves and processes the logs for the entrypoint session as they become available.
|
|
482
|
+
|
|
483
|
+
Args:
|
|
484
|
+
on_stdout OutputHandler[str]: Callback function to handle stdout log chunks as they arrive.
|
|
485
|
+
on_stderr OutputHandler[str]: Callback function to handle stderr log chunks as they arrive.
|
|
486
|
+
|
|
487
|
+
Example:
|
|
488
|
+
```python
|
|
489
|
+
await sandbox.process.get_entrypoint_logs_async(
|
|
490
|
+
lambda log: print(f"[STDOUT]: {log}"),
|
|
491
|
+
lambda log: print(f"[STDERR]: {log}"),
|
|
492
|
+
)
|
|
493
|
+
```
|
|
494
|
+
"""
|
|
495
|
+
|
|
496
|
+
_, url, headers, *_ = self._api_client._get_entrypoint_logs_serialize(
|
|
497
|
+
follow=True,
|
|
498
|
+
_request_auth=None,
|
|
499
|
+
_content_type=None,
|
|
500
|
+
_headers=None,
|
|
501
|
+
_host_index=None,
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
url = re.sub(r"^http", "ws", url)
|
|
505
|
+
|
|
506
|
+
await self._consume_log_websocket(url, headers, on_stdout, on_stderr)
|
|
507
|
+
|
|
508
|
+
@intercept_errors(message_prefix="Failed to send session command input: ")
|
|
509
|
+
async def send_session_command_input(self, session_id: str, command_id: str, data: str) -> None:
|
|
510
|
+
"""Sends input data to a command executed in a session.
|
|
511
|
+
|
|
512
|
+
Args:
|
|
513
|
+
session_id (str): Unique identifier of the session.
|
|
514
|
+
command_id (str): Unique identifier of the command.
|
|
515
|
+
data (str): Input data to send.
|
|
516
|
+
"""
|
|
517
|
+
await self._api_client.send_input(
|
|
518
|
+
session_id=session_id, command_id=command_id, request=SessionSendInputRequest(data=data)
|
|
519
|
+
)
|
|
520
|
+
|
|
521
|
+
@intercept_errors(message_prefix="Failed to list sessions: ")
|
|
522
|
+
@with_instrumentation()
|
|
523
|
+
async def list_sessions(self) -> list[Session]:
|
|
524
|
+
"""Lists all sessions in the Sandbox.
|
|
525
|
+
|
|
526
|
+
Returns:
|
|
527
|
+
list[Session]: List of all sessions in the Sandbox.
|
|
528
|
+
|
|
529
|
+
Example:
|
|
530
|
+
```python
|
|
531
|
+
sessions = await sandbox.process.list_sessions()
|
|
532
|
+
for session in sessions:
|
|
533
|
+
print(f"Session {session.session_id}:")
|
|
534
|
+
print(f" Commands: {len(session.commands)}")
|
|
535
|
+
```
|
|
536
|
+
"""
|
|
537
|
+
return await self._api_client.list_sessions()
|
|
538
|
+
|
|
539
|
+
@intercept_errors(message_prefix="Failed to delete session: ")
|
|
540
|
+
@with_instrumentation()
|
|
541
|
+
async def delete_session(self, session_id: str) -> None:
|
|
542
|
+
"""Terminates and removes a session from the Sandbox, cleaning up any resources
|
|
543
|
+
associated with it.
|
|
544
|
+
|
|
545
|
+
Args:
|
|
546
|
+
session_id (str): Unique identifier of the session to delete.
|
|
547
|
+
|
|
548
|
+
Example:
|
|
549
|
+
```python
|
|
550
|
+
# Create and use a session
|
|
551
|
+
await sandbox.process.create_session("temp-session")
|
|
552
|
+
# ... use the session ...
|
|
553
|
+
|
|
554
|
+
# Clean up when done
|
|
555
|
+
await sandbox.process.delete_session("temp-session")
|
|
556
|
+
```
|
|
557
|
+
"""
|
|
558
|
+
await self._api_client.delete_session(session_id=session_id)
|
|
559
|
+
|
|
560
|
+
@intercept_errors(message_prefix="Failed to create PTY session: ")
|
|
561
|
+
@with_instrumentation()
|
|
562
|
+
async def create_pty_session(
|
|
563
|
+
self,
|
|
564
|
+
id: str,
|
|
565
|
+
on_data: Callable[[bytes], None] | Callable[[bytes], Awaitable[None]],
|
|
566
|
+
cwd: str | None = None,
|
|
567
|
+
envs: dict[str, str] | None = None,
|
|
568
|
+
pty_size: PtySize | None = None,
|
|
569
|
+
) -> AsyncPtyHandle:
|
|
570
|
+
"""Creates a new PTY (pseudo-terminal) session in the Sandbox.
|
|
571
|
+
|
|
572
|
+
Creates an interactive terminal session that can execute commands and handle user input.
|
|
573
|
+
The PTY session behaves like a real terminal, supporting features like command history.
|
|
574
|
+
|
|
575
|
+
Args:
|
|
576
|
+
id: Unique identifier for the PTY session. Must be unique within the Sandbox.
|
|
577
|
+
on_data (Callable[[bytes], None] | Callable[[bytes], Awaitable[None]]):
|
|
578
|
+
Callback function to handle PTY output data.
|
|
579
|
+
cwd: Working directory for the PTY session. Defaults to the sandbox's working directory.
|
|
580
|
+
env: Environment variables to set in the PTY session. These will be merged with
|
|
581
|
+
the Sandbox's default environment variables.
|
|
582
|
+
pty_size: Terminal size configuration. Defaults to 80x24 if not specified.
|
|
583
|
+
|
|
584
|
+
Returns:
|
|
585
|
+
AsyncPtyHandle: Handle for managing the created PTY session. Use this to send input,
|
|
586
|
+
receive output, resize the terminal, and manage the session lifecycle.
|
|
587
|
+
|
|
588
|
+
Raises:
|
|
589
|
+
NorthraysError: If the PTY session creation fails or the session ID is already in use.
|
|
590
|
+
"""
|
|
591
|
+
response = await self._api_client.create_pty_session(
|
|
592
|
+
request=PtyCreateRequest(
|
|
593
|
+
id=id,
|
|
594
|
+
cwd=cwd,
|
|
595
|
+
envs=envs,
|
|
596
|
+
cols=pty_size.cols if pty_size else None,
|
|
597
|
+
rows=pty_size.rows if pty_size else None,
|
|
598
|
+
lazy_start=True,
|
|
599
|
+
),
|
|
600
|
+
)
|
|
601
|
+
|
|
602
|
+
return await self.connect_pty_session(
|
|
603
|
+
response.session_id,
|
|
604
|
+
on_data,
|
|
605
|
+
)
|
|
606
|
+
|
|
607
|
+
@intercept_errors(message_prefix="Failed to connect PTY session: ")
|
|
608
|
+
@with_instrumentation()
|
|
609
|
+
async def connect_pty_session(
|
|
610
|
+
self,
|
|
611
|
+
session_id: str,
|
|
612
|
+
on_data: Callable[[bytes], None] | Callable[[bytes], Awaitable[None]],
|
|
613
|
+
) -> AsyncPtyHandle:
|
|
614
|
+
"""Connects to an existing PTY session in the Sandbox.
|
|
615
|
+
|
|
616
|
+
Establishes a WebSocket connection to an existing PTY session, allowing you to
|
|
617
|
+
interact with a previously created terminal session.
|
|
618
|
+
|
|
619
|
+
Args:
|
|
620
|
+
session_id: Unique identifier of the PTY session to connect to.
|
|
621
|
+
|
|
622
|
+
Returns:
|
|
623
|
+
AsyncPtyHandle: Handle for managing the connected PTY session.
|
|
624
|
+
|
|
625
|
+
Raises:
|
|
626
|
+
NorthraysError: If the PTY session doesn't exist or connection fails.
|
|
627
|
+
"""
|
|
628
|
+
_, url, headers, *_ = self._api_client._connect_pty_session_serialize(
|
|
629
|
+
session_id=session_id,
|
|
630
|
+
_request_auth=None,
|
|
631
|
+
_content_type=None,
|
|
632
|
+
_headers=None,
|
|
633
|
+
_host_index=None,
|
|
634
|
+
)
|
|
635
|
+
url = re.sub(r"^http", "ws", url)
|
|
636
|
+
|
|
637
|
+
ws = await self._open_ws(url, headers)
|
|
638
|
+
|
|
639
|
+
async def resize_handler(pty_size: PtySize) -> PtySessionInfo:
|
|
640
|
+
return await self.resize_pty_session(session_id, pty_size)
|
|
641
|
+
|
|
642
|
+
async def kill_handler() -> None:
|
|
643
|
+
await self.kill_pty_session(session_id)
|
|
644
|
+
|
|
645
|
+
handle = AsyncPtyHandle(
|
|
646
|
+
ws,
|
|
647
|
+
on_data,
|
|
648
|
+
session_id=session_id,
|
|
649
|
+
handle_resize=resize_handler,
|
|
650
|
+
handle_kill=kill_handler,
|
|
651
|
+
)
|
|
652
|
+
# If wait_for_connection() raises (handshake timeout / server-side error / cancel),
|
|
653
|
+
# the caller never sees the handle and cannot call disconnect(), so we MUST close
|
|
654
|
+
# the websocket and the per-call session ourselves before propagating the error.
|
|
655
|
+
try:
|
|
656
|
+
await handle.wait_for_connection()
|
|
657
|
+
except BaseException:
|
|
658
|
+
await handle.disconnect()
|
|
659
|
+
raise
|
|
660
|
+
return handle
|
|
661
|
+
|
|
662
|
+
@intercept_errors(message_prefix="Failed to list PTY sessions: ")
|
|
663
|
+
@with_instrumentation()
|
|
664
|
+
async def list_pty_sessions(self) -> list[PtySessionInfo]:
|
|
665
|
+
"""Lists all PTY sessions in the Sandbox.
|
|
666
|
+
|
|
667
|
+
Retrieves information about all PTY sessions in this Sandbox.
|
|
668
|
+
|
|
669
|
+
Returns:
|
|
670
|
+
list[PtySessionInfo]: List of PTY session information objects containing
|
|
671
|
+
details about each session's state, creation time, and configuration.
|
|
672
|
+
|
|
673
|
+
Example:
|
|
674
|
+
```python
|
|
675
|
+
# List all PTY sessions
|
|
676
|
+
sessions = await sandbox.process.list_pty_sessions()
|
|
677
|
+
|
|
678
|
+
for session in sessions:
|
|
679
|
+
print(f"Session ID: {session.id}")
|
|
680
|
+
print(f"Active: {session.active}")
|
|
681
|
+
print(f"Created: {session.created_at}")
|
|
682
|
+
```
|
|
683
|
+
"""
|
|
684
|
+
return (await self._api_client.list_pty_sessions()).sessions
|
|
685
|
+
|
|
686
|
+
@intercept_errors(message_prefix="Failed to get PTY session info: ")
|
|
687
|
+
@with_instrumentation()
|
|
688
|
+
async def get_pty_session_info(self, session_id: str) -> PtySessionInfo:
|
|
689
|
+
"""Gets detailed information about a specific PTY session.
|
|
690
|
+
|
|
691
|
+
Retrieves comprehensive information about a PTY session including its current state,
|
|
692
|
+
configuration, and metadata.
|
|
693
|
+
|
|
694
|
+
Args:
|
|
695
|
+
session_id: Unique identifier of the PTY session to retrieve information for.
|
|
696
|
+
|
|
697
|
+
Returns:
|
|
698
|
+
PtySessionInfo: Detailed information about the PTY session including ID, state,
|
|
699
|
+
creation time, working directory, environment variables, and more.
|
|
700
|
+
|
|
701
|
+
Raises:
|
|
702
|
+
NorthraysError: If the PTY session doesn't exist.
|
|
703
|
+
|
|
704
|
+
Example:
|
|
705
|
+
```python
|
|
706
|
+
# Get details about a specific PTY session
|
|
707
|
+
session_info = await sandbox.process.get_pty_session_info("my-session")
|
|
708
|
+
|
|
709
|
+
print(f"Session ID: {session_info.id}")
|
|
710
|
+
print(f"Active: {session_info.active}")
|
|
711
|
+
print(f"Working Directory: {session_info.cwd}")
|
|
712
|
+
print(f"Terminal Size: {session_info.cols}x{session_info.rows}")
|
|
713
|
+
```
|
|
714
|
+
"""
|
|
715
|
+
return await self._api_client.get_pty_session(session_id=session_id)
|
|
716
|
+
|
|
717
|
+
@intercept_errors(message_prefix="Failed to kill PTY session: ")
|
|
718
|
+
@with_instrumentation()
|
|
719
|
+
async def kill_pty_session(self, session_id: str) -> None:
|
|
720
|
+
"""Kills a PTY session and terminates its associated process.
|
|
721
|
+
|
|
722
|
+
Forcefully terminates the PTY session and cleans up all associated resources.
|
|
723
|
+
This will close any active connections and kill the underlying shell process.
|
|
724
|
+
This operation is irreversible. Any unsaved work in the terminal session will be lost.
|
|
725
|
+
|
|
726
|
+
Args:
|
|
727
|
+
session_id: Unique identifier of the PTY session to kill.
|
|
728
|
+
|
|
729
|
+
Raises:
|
|
730
|
+
NorthraysError: If the PTY session doesn't exist or cannot be killed.
|
|
731
|
+
|
|
732
|
+
Example:
|
|
733
|
+
```python
|
|
734
|
+
# Kill a specific PTY session
|
|
735
|
+
await sandbox.process.kill_pty_session("my-session")
|
|
736
|
+
|
|
737
|
+
# Verify the session no longer exists
|
|
738
|
+
pty_sessions = await sandbox.process.list_pty_sessions()
|
|
739
|
+
for pty_session in pty_sessions:
|
|
740
|
+
print(f"PTY session: {pty_session.id}")
|
|
741
|
+
```
|
|
742
|
+
"""
|
|
743
|
+
_ = await self._api_client.delete_pty_session(session_id=session_id)
|
|
744
|
+
|
|
745
|
+
@intercept_errors(message_prefix="Failed to resize PTY session: ")
|
|
746
|
+
@with_instrumentation()
|
|
747
|
+
async def resize_pty_session(self, session_id: str, pty_size: PtySize) -> PtySessionInfo:
|
|
748
|
+
"""Resizes a PTY session's terminal dimensions.
|
|
749
|
+
|
|
750
|
+
Changes the terminal size of an active PTY session. This is useful when the
|
|
751
|
+
client terminal is resized or when you need to adjust the display for different
|
|
752
|
+
output requirements.
|
|
753
|
+
|
|
754
|
+
Args:
|
|
755
|
+
session_id: Unique identifier of the PTY session to resize.
|
|
756
|
+
pty_size: New terminal dimensions containing the desired columns and rows.
|
|
757
|
+
|
|
758
|
+
Returns:
|
|
759
|
+
PtySessionInfo: Updated session information reflecting the new terminal size.
|
|
760
|
+
|
|
761
|
+
Raises:
|
|
762
|
+
NorthraysError: If the PTY session doesn't exist or resize operation fails.
|
|
763
|
+
|
|
764
|
+
Example:
|
|
765
|
+
```python
|
|
766
|
+
from northrays.common.pty import PtySize
|
|
767
|
+
|
|
768
|
+
# Resize a PTY session to a larger terminal
|
|
769
|
+
new_size = PtySize(rows=40, cols=150)
|
|
770
|
+
updated_info = await sandbox.process.resize_pty_session("my-session", new_size)
|
|
771
|
+
|
|
772
|
+
print(f"Terminal resized to {updated_info.cols}x{updated_info.rows}")
|
|
773
|
+
|
|
774
|
+
# You can also use the AsyncPtyHandle's resize method
|
|
775
|
+
await pty_handle.resize(new_size)
|
|
776
|
+
```
|
|
777
|
+
"""
|
|
778
|
+
return await self._api_client.resize_pty_session(
|
|
779
|
+
session_id=session_id,
|
|
780
|
+
request=PtyResizeRequest(cols=pty_size.cols, rows=pty_size.rows),
|
|
781
|
+
)
|