Secure, Fast, and Extensible Sandbox runtime for AI agents.
chore(egress): address PR review nits
高然f6c64d37f3a4
diff --git a/components/egress/mitmscripts/system.py b/components/egress/mitmscripts/system.pyindex 8ce39a86c..30b5d4ff0 100644--- a/components/egress/mitmscripts/system.py+++ b/components/egress/mitmscripts/system.py@@ -72,7 +72,7 @@ import osimport reimport socketfrom contextlib import suppress-from typing import TYPE_CHECKING, Any, NoReturn+from typing import TYPE_CHECKING, Any, Awaitable, NoReturnfrom urllib.parse import quote, quote_plus, unquotefrom mitmproxy import ctx, http@@ -1867,7 +1867,7 @@ def _observe_tls_shadow(ctx.log.warn("credential proxy: tls-shadow observer_error")-def _requestheaders_pull(flow: http.HTTPFlow) -> Any | None:+def _requestheaders_pull(flow: http.HTTPFlow) -> Awaitable[None] | None:"""Pull-mode processing; returns an awaitable only when an exchangebinding defers its resolve I/O to the caller."""try:@@ -2069,7 +2069,7 @@ def _reject_ambiguous_binding_path(def _apply_vault_binding(flow: http.HTTPFlow, vault: ActiveVault, live: Any | None = None-) -> Any | None:+) -> Awaitable[None] | None:"""Shared binding selection, ambiguity checks and credential injection.Returns an awaitable only for pull-mode exchange bindings (their resolve@@ -2126,6 +2126,7 @@ def _apply_vault_binding(f"{binding.get('name')} revision={vault.revision} "f"host={_request_host(flow)} method={flow.request.method}")+ return Nonedef _apply_exchange_binding(@@ -2133,7 +2134,7 @@ def _apply_exchange_binding(vault: ActiveVault,binding: dict[str, Any],live: Any | None,-) -> Any | None:+) -> Awaitable[None] | None:"""Gate one exchange binding, then defer its resolve I/O.Live snapshots never carry exchange (the egress admission gate rejectsdiff --git a/components/egress/tests/test_system_resolve.py b/components/egress/tests/test_system_resolve.pyindex 2a2b81571..760ffd369 100644--- a/components/egress/tests/test_system_resolve.py+++ b/components/egress/tests/test_system_resolve.py@@ -31,10 +31,10 @@ import sysimport threadingimport timeimport types-import unittest+import unittest.mock as mockfrom pathlib import Pathfrom typing import Any-from unittest import mock+from unittest import TestCase, mainfrom urllib.parse import quote, quote_plusMITMSCRIPTS = Path(__file__).resolve().parents[1] / "mitmscripts"@@ -243,7 +243,7 @@ class _ScriptedResponse:return None-class ExchangeResolveTest(unittest.TestCase):+class ExchangeResolveTest(TestCase):def setUp(self) -> None:self.system = _load_system_module()self.log: _Log = self.system.ctx.log@@ -832,4 +832,4 @@ class ExchangeResolveTest(unittest.TestCase):if __name__ == "__main__":- unittest.main()+ main()