agentenv-framework-protocol 0.1.532__tar.gz → 0.1.536__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/PKG-INFO +28 -5
  2. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/README.md +23 -4
  3. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/pyproject.toml +5 -1
  4. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/operations.py +3 -1
  5. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/results.py +2 -0
  6. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/tools.py +2 -1
  7. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website_browser/__init__.py +8 -7
  8. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website_browser/cdp.py +61 -8
  9. agentenv_framework_protocol-0.1.536/src/agentenv_protocol/website_browser/contexts.py +241 -0
  10. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website_browser/control.py +242 -108
  11. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website_browser/data.py +23 -8
  12. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website_browser/environment.py +180 -53
  13. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website_browser/log.py +4 -4
  14. agentenv_framework_protocol-0.1.536/src/agentenv_protocol/website_browser/network.py +373 -0
  15. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website_browser/recording.py +9 -1
  16. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website_browser/shapes.py +37 -5
  17. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_browser_cdp.py +63 -6
  18. agentenv_framework_protocol-0.1.536/tests/test_browser_contexts.py +387 -0
  19. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_browser_data.py +63 -8
  20. agentenv_framework_protocol-0.1.536/tests/test_browser_network.py +347 -0
  21. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_browser_recording.py +84 -0
  22. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_browser_state.py +1 -1
  23. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/.gitignore +0 -0
  24. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/LICENSE +0 -0
  25. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/NOTICE +0 -0
  26. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/THIRD_PARTY_NOTICES.md +0 -0
  27. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/__init__.py +0 -0
  28. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/advanced_agent.py +0 -0
  29. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/basic_agent.py +0 -0
  30. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/custom_extensions_agent.py +0 -0
  31. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/multimodal_agent.py +0 -0
  32. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/reference_model.py +0 -0
  33. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/streaming_agent.py +0 -0
  34. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/.gitignore +0 -0
  35. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/Dockerfile +0 -0
  36. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/Dockerfile.dockerignore +0 -0
  37. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/README.md +0 -0
  38. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/data/seed.json +0 -0
  39. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/env.toml +0 -0
  40. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/site.py +0 -0
  41. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/web/index.html +0 -0
  42. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/web/package-lock.json +0 -0
  43. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/web/package.json +0 -0
  44. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/web/src/main.js +0 -0
  45. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/web/src/style.css +0 -0
  46. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/examples/website/notes/web/vite.config.js +0 -0
  47. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/__init__.py +0 -0
  48. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/__init__.py +0 -0
  49. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/_trajectory_log.py +0 -0
  50. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/_triggers.py +0 -0
  51. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/extensions.py +0 -0
  52. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/framework.py +0 -0
  53. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/peer_agents.py +0 -0
  54. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/proxy.py +0 -0
  55. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/registry.py +0 -0
  56. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/staging.py +0 -0
  57. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/tasks/__init__.py +0 -0
  58. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/a2a_agent/tasks/v1.py +0 -0
  59. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/agent_env_environment.py +0 -0
  60. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/client.py +0 -0
  61. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/__init__.py +0 -0
  62. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_declare.py +0 -0
  63. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_desktop.py +0 -0
  64. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_job.py +0 -0
  65. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_linux.py +0 -0
  66. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_load.py +0 -0
  67. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_macos.py +0 -0
  68. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_reaping.py +0 -0
  69. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_session_posix.py +0 -0
  70. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_session_windows.py +0 -0
  71. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_windows.py +0 -0
  72. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_with_fds.py +0 -0
  73. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/_x11.py +0 -0
  74. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/app.py +0 -0
  75. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/app_data.py +0 -0
  76. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/app_runtime.py +0 -0
  77. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/apps.py +0 -0
  78. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/card.py +0 -0
  79. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/checks.py +0 -0
  80. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/conformance/__init__.py +0 -0
  81. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/conformance/__main__.py +0 -0
  82. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/conformance/checks.py +0 -0
  83. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/conformance/client.py +0 -0
  84. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/conformance/desk.py +0 -0
  85. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/conformance/fixture.py +0 -0
  86. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/conformance/mp4.py +0 -0
  87. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/conformance/page_fixture.py +0 -0
  88. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/conformance/report.py +0 -0
  89. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/conformance/wayland_fixture.py +0 -0
  90. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/dataplane.py +0 -0
  91. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/driver.py +0 -0
  92. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/errors.py +0 -0
  93. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/extensions.py +0 -0
  94. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/frames.py +0 -0
  95. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/keys.py +0 -0
  96. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/launch.py +0 -0
  97. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/manifest.py +0 -0
  98. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/platform.py +0 -0
  99. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/prefix.py +0 -0
  100. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/queue.py +0 -0
  101. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/recording.py +0 -0
  102. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/run_install_step.py +0 -0
  103. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/runtime.py +0 -0
  104. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/seed.py +0 -0
  105. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/serve.py +0 -0
  106. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/serve_app.py +0 -0
  107. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/served.py +0 -0
  108. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/session.py +0 -0
  109. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/settings.py +0 -0
  110. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/skill.py +0 -0
  111. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/spaces.py +0 -0
  112. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/computer/svc.py +0 -0
  113. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/errors.py +0 -0
  114. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/manifest.py +0 -0
  115. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/preflight.py +0 -0
  116. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/tool_access.py +0 -0
  117. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/tool_client.py +0 -0
  118. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/tool_context.py +0 -0
  119. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/transfers.py +0 -0
  120. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/types.py +0 -0
  121. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website/__init__.py +0 -0
  122. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website/clock.py +0 -0
  123. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website/conformance.py +0 -0
  124. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website/environment.py +0 -0
  125. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website/errors.py +0 -0
  126. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website/readiness.py +0 -0
  127. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website/routes.py +0 -0
  128. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website/session.py +0 -0
  129. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/src/agentenv_protocol/website_browser/devtools.py +0 -0
  130. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/computer_fake.py +0 -0
  131. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/probe_fake.py +0 -0
  132. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_a2a_agent.py +0 -0
  133. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_a2a_agent_examples.py +0 -0
  134. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_a2a_cdp_config.py +0 -0
  135. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_a2a_object_transfers.py +0 -0
  136. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_a2a_peer_agents.py +0 -0
  137. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_a2a_proxy.py +0 -0
  138. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_a2a_staging.py +0 -0
  139. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_a2a_trajectory_log.py +0 -0
  140. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_agent_env_environment.py +0 -0
  141. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_browser_log.py +0 -0
  142. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_client.py +0 -0
  143. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_app_data.py +0 -0
  144. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_app_server.py +0 -0
  145. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_conformance.py +0 -0
  146. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_conformance_checks.py +0 -0
  147. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_conformance_page.py +0 -0
  148. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_conformance_recording.py +0 -0
  149. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_dataplane.py +0 -0
  150. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_declare.py +0 -0
  151. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_driver.py +0 -0
  152. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_driver_keys.py +0 -0
  153. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_extensions.py +0 -0
  154. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_frames.py +0 -0
  155. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_macos.py +0 -0
  156. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_page.py +0 -0
  157. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_queue.py +0 -0
  158. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_recording.py +0 -0
  159. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_seed.py +0 -0
  160. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_serve.py +0 -0
  161. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_served.py +0 -0
  162. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_session_windows.py +0 -0
  163. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_spaces.py +0 -0
  164. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_svc_forward.py +0 -0
  165. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_tool_prefix.py +0 -0
  166. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_computer_windows_driver.py +0 -0
  167. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_control_token.py +0 -0
  168. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_data_objects.py +0 -0
  169. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_devtools_pipe.py +0 -0
  170. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_errors.py +0 -0
  171. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_extension_methods.py +0 -0
  172. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_intake.py +0 -0
  173. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_manifest.py +0 -0
  174. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_preflight.py +0 -0
  175. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_tool_access.py +0 -0
  176. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_tool_annotations.py +0 -0
  177. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_tool_client.py +0 -0
  178. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_tool_context.py +0 -0
  179. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_tool_context_fastmcp.py +0 -0
  180. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_tool_context_injection.py +0 -0
  181. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_website_api.py +0 -0
  182. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_website_browser.py +0 -0
  183. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_website_conformance.py +0 -0
  184. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_website_environment.py +0 -0
  185. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_website_live.py +0 -0
  186. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_website_mcp.py +0 -0
  187. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_website_notes_example.py +0 -0
  188. {agentenv_framework_protocol-0.1.532 → agentenv_framework_protocol-0.1.536}/tests/test_website_readiness.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: agentenv-framework-protocol
3
- Version: 0.1.532
3
+ Version: 0.1.536
4
4
  Summary: Open data-plane protocol and server SDK for agent environments.
5
5
  Project-URL: Homepage, https://www.agentenvframework.com
6
6
  Project-URL: Documentation, https://www.agentenvframework.com/docs
@@ -35,9 +35,11 @@ Requires-Dist: python-multipart>=0.0.13; extra == 'agent'
35
35
  Requires-Dist: regex>=2023.12.25; extra == 'agent'
36
36
  Requires-Dist: uvicorn>=0.30; extra == 'agent'
37
37
  Provides-Extra: app
38
+ Requires-Dist: brotli>=1.2; extra == 'app'
38
39
  Requires-Dist: mcp<2,>=1.25; extra == 'app'
39
40
  Requires-Dist: uvicorn>=0.30; extra == 'app'
40
41
  Requires-Dist: websockets>=13; extra == 'app'
42
+ Requires-Dist: zstandard>=0.23; extra == 'app'
41
43
  Provides-Extra: computer
42
44
  Requires-Dist: av>=17; extra == 'computer'
43
45
  Requires-Dist: mcp<2,>=1.25; extra == 'computer'
@@ -47,6 +49,7 @@ Requires-Dist: websockets>=13; extra == 'computer'
47
49
  Provides-Extra: dev
48
50
  Requires-Dist: a2a-sdk[http-server]<0.4,>=0.3.26; extra == 'dev'
49
51
  Requires-Dist: av>=17; extra == 'dev'
52
+ Requires-Dist: brotli>=1.2; extra == 'dev'
50
53
  Requires-Dist: fastmcp<4,>=3.4; extra == 'dev'
51
54
  Requires-Dist: mcp<2,>=1.25; extra == 'dev'
52
55
  Requires-Dist: pillow>=10.4; extra == 'dev'
@@ -55,6 +58,7 @@ Requires-Dist: pytest>=9.0; extra == 'dev'
55
58
  Requires-Dist: python-multipart>=0.0.13; extra == 'dev'
56
59
  Requires-Dist: regex>=2023.12.25; extra == 'dev'
57
60
  Requires-Dist: websockets>=13; extra == 'dev'
61
+ Requires-Dist: zstandard>=0.23; extra == 'dev'
58
62
  Provides-Extra: macos
59
63
  Requires-Dist: pyobjc-framework-quartz>=11; (sys_platform == 'darwin') and extra == 'macos'
60
64
  Requires-Dist: pyobjc-framework-screencapturekit>=11; (sys_platform == 'darwin') and extra == 'macos'
@@ -1027,7 +1031,8 @@ are the profile's template. The base class adds:
1027
1031
  `notifications`, `deny` (the default), which answers a page's prompt for it, or `ask`; and `dialogs`, who
1028
1032
  answers a page's JavaScript dialogs: `agent` (the default), or agentenv, accepting (`accept`, a `prompt()`
1029
1033
  with its default text) or dismissing (`dismiss`) each. Either way agentenv leaves a page that asks before
1030
- it's left (`beforeunload`), so none of its answers blocks a navigation.
1034
+ it's left (`beforeunload`), so none of its answers blocks a navigation. And `network`, on by default, whether
1035
+ `data/get` exports its network log and `browser/v1` `network` reads it.
1031
1036
  - **The flags agentenv owns**, after the subclass's command and before `about:blank`, the one tab its command line
1032
1037
  opens: its profile, its
1033
1038
  HTTP cache under `~/.cache` (`--disk-cache-dir`), `--remote-debugging-pipe`, `--no-first-run`,
@@ -1099,10 +1104,28 @@ are the profile's template. The base class adds:
1099
1104
  - A driver passes an agent's tool call to the browser in the `AgentEnv-Tool-Call` header (`tool_call_header`), with
1100
1105
  the caller's `AgentEnv-Role`; the page driver sends it on every call it makes for a tool. `data/get` writes the log
1101
1106
  beside `browser-state.json` as `browser-log.jsonl`, which `data/add` passes over.
1107
+ - **Its network log** is the one the proxy it goes out through keeps, in the file `AGENTENV_NETWORK_LOG` names
1108
+ (`website_browser.network`): on a browser alone routing sites, the shared site proxy's,
1109
+ `/etc/agentenv/sites/network.jsonl`, which root keeps and the session user reads; else the base's stand-in's,
1110
+ `/var/log/agentenv/network.jsonl`. One JSON object a line, numbered (`seq`) and timed (`at`) as it's written, a
1111
+ proxy started again numbering after the file's last: an `open` line once a request has gone upstream or a tunnel
1112
+ has opened, and an `end` line, naming the same `id`, once it's answered and done or has failed. The shared site
1113
+ proxy keeps each exchange whole: the request as the browser sent it, its headers, the values of the sign-in headers
1114
+ a site declares as `<removed>`, and its body up to 10 MB; the answer as the browser got it, its status, its headers
1115
+ and, for text, JSON, forms, XML and scripts, its body up to 1 MB, as it came, in base64, any other type's size and
1116
+ sha256 alone; a WebSocket's messages and bytes each way; and each tunnel to a live host, refusal and failure. The
1117
+ stand-in, which decrypts nothing, keeps each connection: its host, port, address and bytes each way, and a plain
1118
+ request's method and URL. A browser on a computer with a desktop has none, since no proxy logs for it and nothing
1119
+ names one. When it has one and its `network` setting is on, `data/get` writes it as HAR 1.2, `network.har`,
1120
+ which `data/add` passes over: an entry
1121
+ for each request and tunnel in the order they started, one still going marked `_open`, bodies decoded from gzip and
1122
+ deflate, and br and zstd with the `app` extra's `brotli` and `zstandard`, up to 1 MB, and agentenv's own fields
1123
+ named with `_`: `_tunnel`, `_websocket`, `_failed`, `_refused`, `_truncated`, `_sha256`.
1102
1124
  - **`browser/v1`** on its card: `chromium` (its `version`), `clock: "real"` and, alone, `window`; `log {after}`
1103
- (GET), framework-only, its log's lines after `after`; `calls/begin {user, acts?, within_s?}`, framework-only,
1104
- sent with the tool-call header, which begins the entry of an agent's tool call that `user`'s CDP connections
1105
- serve and answers its `entry`, and `calls/end {entry, ok, error?}`, which ends it, a call not ended within
1125
+ (GET), framework-only, its log's lines after `after`; `network {after}` (GET), framework-only, its network log's
1126
+ lines after `after`, 500 at most and `more` when a read left some; `calls/begin {user, acts?, within_s?}`,
1127
+ framework-only, sent with the tool-call header, which begins the entry of an agent's tool call that `user`'s CDP
1128
+ connections serve and answers its `entry`, and `calls/end {entry, ok, error?}`, which ends it, a call not ended within
1106
1129
  `within_s` (600 s by default) written as never said to have ended; and
1107
1130
  `record` (GET), framework-only, which returns that record with `launches`, the app server's log of each
1108
1131
  launch (with its cause: `boot`, `server_restart`, `launch`, `data/add` or `data/reset`), each stop it made
@@ -960,7 +960,8 @@ are the profile's template. The base class adds:
960
960
  `notifications`, `deny` (the default), which answers a page's prompt for it, or `ask`; and `dialogs`, who
961
961
  answers a page's JavaScript dialogs: `agent` (the default), or agentenv, accepting (`accept`, a `prompt()`
962
962
  with its default text) or dismissing (`dismiss`) each. Either way agentenv leaves a page that asks before
963
- it's left (`beforeunload`), so none of its answers blocks a navigation.
963
+ it's left (`beforeunload`), so none of its answers blocks a navigation. And `network`, on by default, whether
964
+ `data/get` exports its network log and `browser/v1` `network` reads it.
964
965
  - **The flags agentenv owns**, after the subclass's command and before `about:blank`, the one tab its command line
965
966
  opens: its profile, its
966
967
  HTTP cache under `~/.cache` (`--disk-cache-dir`), `--remote-debugging-pipe`, `--no-first-run`,
@@ -1032,10 +1033,28 @@ are the profile's template. The base class adds:
1032
1033
  - A driver passes an agent's tool call to the browser in the `AgentEnv-Tool-Call` header (`tool_call_header`), with
1033
1034
  the caller's `AgentEnv-Role`; the page driver sends it on every call it makes for a tool. `data/get` writes the log
1034
1035
  beside `browser-state.json` as `browser-log.jsonl`, which `data/add` passes over.
1036
+ - **Its network log** is the one the proxy it goes out through keeps, in the file `AGENTENV_NETWORK_LOG` names
1037
+ (`website_browser.network`): on a browser alone routing sites, the shared site proxy's,
1038
+ `/etc/agentenv/sites/network.jsonl`, which root keeps and the session user reads; else the base's stand-in's,
1039
+ `/var/log/agentenv/network.jsonl`. One JSON object a line, numbered (`seq`) and timed (`at`) as it's written, a
1040
+ proxy started again numbering after the file's last: an `open` line once a request has gone upstream or a tunnel
1041
+ has opened, and an `end` line, naming the same `id`, once it's answered and done or has failed. The shared site
1042
+ proxy keeps each exchange whole: the request as the browser sent it, its headers, the values of the sign-in headers
1043
+ a site declares as `<removed>`, and its body up to 10 MB; the answer as the browser got it, its status, its headers
1044
+ and, for text, JSON, forms, XML and scripts, its body up to 1 MB, as it came, in base64, any other type's size and
1045
+ sha256 alone; a WebSocket's messages and bytes each way; and each tunnel to a live host, refusal and failure. The
1046
+ stand-in, which decrypts nothing, keeps each connection: its host, port, address and bytes each way, and a plain
1047
+ request's method and URL. A browser on a computer with a desktop has none, since no proxy logs for it and nothing
1048
+ names one. When it has one and its `network` setting is on, `data/get` writes it as HAR 1.2, `network.har`,
1049
+ which `data/add` passes over: an entry
1050
+ for each request and tunnel in the order they started, one still going marked `_open`, bodies decoded from gzip and
1051
+ deflate, and br and zstd with the `app` extra's `brotli` and `zstandard`, up to 1 MB, and agentenv's own fields
1052
+ named with `_`: `_tunnel`, `_websocket`, `_failed`, `_refused`, `_truncated`, `_sha256`.
1035
1053
  - **`browser/v1`** on its card: `chromium` (its `version`), `clock: "real"` and, alone, `window`; `log {after}`
1036
- (GET), framework-only, its log's lines after `after`; `calls/begin {user, acts?, within_s?}`, framework-only,
1037
- sent with the tool-call header, which begins the entry of an agent's tool call that `user`'s CDP connections
1038
- serve and answers its `entry`, and `calls/end {entry, ok, error?}`, which ends it, a call not ended within
1054
+ (GET), framework-only, its log's lines after `after`; `network {after}` (GET), framework-only, its network log's
1055
+ lines after `after`, 500 at most and `more` when a read left some; `calls/begin {user, acts?, within_s?}`,
1056
+ framework-only, sent with the tool-call header, which begins the entry of an agent's tool call that `user`'s CDP
1057
+ connections serve and answers its `entry`, and `calls/end {entry, ok, error?}`, which ends it, a call not ended within
1039
1058
  `within_s` (600 s by default) written as never said to have ended; and
1040
1059
  `record` (GET), framework-only, which returns that record with `launches`, the app server's log of each
1041
1060
  launch (with its cause: `boot`, `server_restart`, `launch`, `data/add` or `data/reset`), each stop it made
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agentenv-framework-protocol"
3
- version = "0.1.532"
3
+ version = "0.1.536"
4
4
  description = "Open data-plane protocol and server SDK for agent environments."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -38,9 +38,11 @@ agent = [
38
38
  # A computer app's own server: ComputerAppEnvironment serves its card and computer-app/v1 over mcp's FastMCP, on a Unix
39
39
  # socket through uvicorn, and a website browser's CDP relay over WebSockets.
40
40
  app = [
41
+ "brotli>=1.2", # a website browser's network log: br answer bodies, decoded for network.har
41
42
  "mcp>=1.25,<2",
42
43
  "uvicorn>=0.30",
43
44
  "websockets>=13",
45
+ "zstandard>=0.23", # and zstd ones
44
46
  ]
45
47
  # A computer driver: ComputerDriverEnvironment serves its tools over mcp's FastMCP, crops and encodes frames, records
46
48
  # the display as H.264 with PyAV (computer-recording/v1), and relays WebSockets to its apps on /svc/<app>/.
@@ -76,6 +78,8 @@ dev = [
76
78
  "Pillow>=10.4", # the computer extra's frame crops and encodings
77
79
  "av>=17", # the computer extra's encoder, and the tests' decoder
78
80
  "websockets>=13", # the computer extra's /svc/<app>/ relay
81
+ "brotli>=1.2", # the app extra's network.har decoding
82
+ "zstandard>=0.23",
79
83
  ]
80
84
  [project.urls]
81
85
  Homepage = "https://www.agentenvframework.com"
@@ -76,11 +76,13 @@ class Effect:
76
76
 
77
77
  @dataclass(frozen=True)
78
78
  class Tab:
79
- """A tab of a website browser: its id, the browser's own, and its page's URL and title."""
79
+ """A tab of a website browser: its id, the browser's own, its page's URL and title, and the label of the lease
80
+ it's in, None for the browser's default context."""
80
81
  id: str
81
82
  url: str
82
83
  title: str
83
84
  active: bool = False
85
+ context: str | None = None
84
86
 
85
87
 
86
88
  @dataclass(frozen=True)
@@ -78,6 +78,8 @@ class TabData(BaseModel):
78
78
  url: str
79
79
  title: str
80
80
  active: bool
81
+ #: The label of the lease it's in, None for the browser's default context.
82
+ context: Optional[str] = None
81
83
 
82
84
 
83
85
  class TabsResult(InputResult):
@@ -405,7 +405,8 @@ class Tools:
405
405
  "switch": f"Switched to tab {tab}", "close": f"Closed tab {tab}"}[action]
406
406
 
407
407
  def listed(result: InputResult, tabs: Any) -> TabsResult:
408
- rows = [TabData(tab=t.id, url=t.url, title=t.title, active=t.active) for t in tabs or []]
408
+ rows = [TabData(tab=t.id, url=t.url, title=t.title, active=t.active, context=t.context)
409
+ for t in tabs or []]
409
410
  active = next((row for row in rows if row.active), None)
410
411
  shown = f', the active one "{active.title}" ({active.url})' if active is not None else ""
411
412
  return TabsResult(**{**result.model_dump(), "summary": f"{verb}; {len(rows)} open{shown}"
@@ -12,17 +12,18 @@ from .devtools import MAX_MESSAGE_BYTES, PIPE_IN, PIPE_OUT, DevToolsError, DevTo
12
12
  from .environment import (ALONE_BYPASS, BLOCK, BROWSER, COMPUTER_BYPASS, OWNED_FLAGS, POLICIES, READY_POLL_S,
13
13
  SHM_MIN_BYTES, SITE_PROXY_ENV, SITES, SKILL, BrowserSettings, WebsiteBrowserEnvironment,
14
14
  Window, start_tab_why)
15
+ from .network import DEFAULT_NETWORK_LOG, HAR_FILE, NETWORK_LOG_ENV, NetworkLog, har
15
16
  from .recording import BROWSER_RECORDING, BrowserRecordingManifest, BrowserRecordings, RecordedFrame
16
17
  from .shapes import (BrowserRecord, ClosedTab, Cookie, CookieToSet, Dialog, Download, LaunchEntry, OpenTab,
17
18
  OriginStorage, PartitionKey, SiteNames, StartTab, StartTabsLaunch, StorageItem, origin_of)
18
19
 
19
20
  __all__ = ["ACTIVE_CHECK_TIMEOUT_S", "AGENT", "AGENTENV", "ALONE_BYPASS", "BLOCK", "BROWSER", "BROWSER_RECORDING",
20
- "CAPTURE_TIMEOUT_S",
21
- "COMPUTER_BYPASS", "DOWNLOADS", "EXIT", "FAILED", "HASH_CHUNK_BYTES", "LIVE_START_TAB_TIMEOUT_S", "LOADED",
22
- "MAX_MESSAGE_BYTES", "OWNED_FLAGS", "PAGE_INPUT", "PAGES", "PIN_TIMEOUT_S", "PIPE_IN", "PIPE_OUT",
21
+ "CAPTURE_TIMEOUT_S", "COMPUTER_BYPASS", "DEFAULT_NETWORK_LOG", "DOWNLOADS", "EXIT", "FAILED", "HAR_FILE",
22
+ "HASH_CHUNK_BYTES", "LIVE_START_TAB_TIMEOUT_S", "LOADED", "MAX_MESSAGE_BYTES", "NETWORK_LOG_ENV",
23
+ "OWNED_FLAGS", "PAGE_INPUT", "PAGES", "PIN_TIMEOUT_S", "PIPE_IN", "PIPE_OUT",
23
24
  "POLICIES", "READY_POLL_S", "SHM_MIN_BYTES", "SITE_PROXY_ENV", "SITES", "SKILL", "STOP", "TIMED_OUT",
24
25
  "UNKNOWN", "UNNAVIGATED_CAPTURE_TIMEOUT_S", "UPLOADS", "BrowserControl", "BrowserSettings", "DevToolsError",
25
- "DevToolsPipe", "WebsiteBrowserEnvironment", "Window", "BrowserRecord", "ClosedTab", "Cookie", "CookieToSet",
26
- "Dialog", "Download", "LaunchEntry", "OpenTab", "OriginStorage", "PartitionKey", "SiteNames", "StartTab",
27
- "StartTabsLaunch", "StorageItem", "origin_of", "start_tab_why", "BrowserRecordingManifest", "BrowserRecordings",
28
- "RecordedFrame"]
26
+ "DevToolsPipe", "NetworkLog", "WebsiteBrowserEnvironment", "Window", "BrowserRecord", "ClosedTab", "Cookie",
27
+ "CookieToSet", "Dialog", "Download", "LaunchEntry", "OpenTab", "OriginStorage", "PartitionKey", "SiteNames",
28
+ "StartTab", "StartTabsLaunch", "StorageItem", "har", "origin_of", "start_tab_why",
29
+ "BrowserRecordingManifest", "BrowserRecordings", "RecordedFrame"]
@@ -22,6 +22,7 @@ from .log import (ERROR_CHARS, KEY_FIELDS, TYPING_METHODS, BrowserLog, acts, red
22
22
  redacted_params)
23
23
 
24
24
  if TYPE_CHECKING:
25
+ from .contexts import Contexts
25
26
  from .control import BrowserControl
26
27
  from .devtools import DevToolsPipe
27
28
 
@@ -51,6 +52,8 @@ MALFORMED = {"code": -32600, "message": "a command is an object with a string me
51
52
  ENDS_BROWSER = frozenset({"Browser.close", "Browser.crash", "Browser.crashGpuProcess"})
52
53
  #: The commands that set how and where downloads are saved, which agentenv keeps as its own.
53
54
  SETS_DOWNLOADS = frozenset({"Browser.setDownloadBehavior", "Page.setDownloadBehavior"})
55
+ #: The commands that make and end a browser context, which agentenv records as leases.
56
+ MAKES_CONTEXT, ENDS_CONTEXT = "Target.createBrowserContext", "Target.disposeBrowserContext"
54
57
  #: The schemes of the browser's own files, settings and tools, which an agent's navigation or new tab may not open.
55
58
  OWN_SCHEMES = frozenset({"file", "chrome", "chrome-extension", "chrome-untrusted", "view-source", "devtools"})
56
59
  #: The ``about:`` pages that aren't the browser's own under another name.
@@ -158,10 +161,11 @@ class Verdict:
158
161
  changed: bool = False
159
162
 
160
163
 
161
- def guard(method: str, params: dict, *, dialogs_answered: bool) -> Verdict:
164
+ def guard(method: str, params: dict, *, dialogs_answered: bool, download_path: Optional[str] = None) -> Verdict:
162
165
  """What the relay does with an agent's ``method``, so it can't end the browser others share, route around the site
163
- proxy, save downloads elsewhere, open the browser's own pages or race the dialogs agentenv answers when
164
- ``dialogs_answered``: a guardrail, since the sandbox's network is the boundary."""
166
+ proxy, save downloads elsewhere than its context's folder, ``download_path`` for a lease's, open the browser's own
167
+ pages or race the dialogs agentenv answers when ``dialogs_answered``: a guardrail, since the sandbox's network is
168
+ the boundary."""
165
169
  if method in ENDS_BROWSER:
166
170
  return Verdict("close", params)
167
171
  if method == "Target.exposeDevToolsProtocol":
@@ -173,8 +177,8 @@ def guard(method: str, params: dict, *, dialogs_answered: bool) -> Verdict:
173
177
  if method in ("Page.navigate", "Target.createTarget") and (scheme := _own_scheme(params.get("url"))):
174
178
  return Verdict("refuse", params, f"{scheme}: URLs open the browser's own files, settings and tools")
175
179
  if method in SETS_DOWNLOADS:
176
- pinned = {"behavior": "default",
177
- **{key: params[key] for key in ("browserContextId", "eventsEnabled") if key in params}}
180
+ pinned = {"behavior": "default"} if download_path is None else {"behavior": "allow", "downloadPath": download_path}
181
+ pinned.update({key: params[key] for key in ("browserContextId", "eventsEnabled") if key in params})
178
182
  return Verdict("send", pinned, changed=pinned != params)
179
183
  if method == "Page.handleJavaScriptDialog" and dialogs_answered:
180
184
  return Verdict("answer", params)
@@ -212,6 +216,9 @@ class _Connection:
212
216
  self.outbox: asyncio.Queue[str | tuple[int, str]] = asyncio.Queue()
213
217
  self.waiting_bytes = 0
214
218
  self.closing = False
219
+ #: Whether it set how downloads are saved, and the contexts it made that end as it detaches.
220
+ self.set_downloads = False
221
+ self.ends_on_detach: set[str] = set()
215
222
 
216
223
 
217
224
  class _Call:
@@ -242,11 +249,14 @@ class Relay:
242
249
  browser's dialogs itself. With a ``log``, each command is an entry in it, on the tab its session is on, and
243
250
  ``control``, agentenv's own connection, tells its tab's URL, whether a password field has focus there, and what
244
251
  causes the tab events a command brings. An agent's tool call a driver serves through a CDP user's connections,
245
- such as Playwright MCP's, is an entry too, which that user's commands are credited to while it's open."""
252
+ such as Playwright MCP's, is an entry too, which that user's commands are credited to while it's open. With
253
+ ``contexts``, a context a connection makes is leased to its user, only one it made may it dispose, and a lease's
254
+ downloads stay in its folder."""
246
255
 
247
256
  def __init__(self, devtools: DevToolsPipe, *, dialogs_answered: bool = False, log: Optional[BrowserLog] = None,
248
- control: Optional[BrowserControl] = None) -> None:
257
+ control: Optional[BrowserControl] = None, contexts: Optional[Contexts] = None) -> None:
249
258
  self.devtools, self.dialogs_answered, self.log, self.control = devtools, dialogs_answered, log, control
259
+ self.contexts = contexts
250
260
  self.connections: list[dict] = []
251
261
  self._by_session: dict[str, _Connection] = {}
252
262
  self._open: set[_Connection] = set()
@@ -315,6 +325,7 @@ class Relay:
315
325
  await asyncio.gather(*connection.commands, sending, return_exceptions=True)
316
326
  with contextlib.suppress(Exception):
317
327
  await self.devtools.call("Target.detachFromTarget", {"sessionId": session})
328
+ self._detached(connection)
318
329
 
319
330
  def ended(self) -> None:
320
331
  """The browser has gone: every connection is closed with a reason a client may connect again after."""
@@ -329,7 +340,7 @@ class Relay:
329
340
  return
330
341
  method, params = message["method"], message.get("params") or {}
331
342
  session = message.get("sessionId") or connection.session
332
- verdict = guard(method, params, dialogs_answered=self.dialogs_answered)
343
+ verdict = self._verdict(connection, session, method, params)
333
344
  logged = self._begin(connection, session, method, params)
334
345
  answer, guarded = {"error": {"code": SERVER_ERROR, "message": ENDED_UNANSWERED}}, None
335
346
  sending: Optional[asyncio.Future] = None
@@ -338,6 +349,8 @@ class Relay:
338
349
  def reply(answer: dict) -> None:
339
350
  nonlocal replied
340
351
  replied = True
352
+ if sending is not None and isinstance(answer.get("result"), dict):
353
+ self._answered(connection, method, params, answer["result"])
341
354
  self._put(connection, _reply(message, answer))
342
355
 
343
356
  try:
@@ -373,6 +386,46 @@ class Relay:
373
386
  if logged is not None:
374
387
  logged.finish(answer, guarded)
375
388
 
389
+ def _verdict(self, connection: _Connection, session: str, method: str, params: dict) -> Verdict:
390
+ """The guard's verdict on ``connection``'s command, with what its contexts say: where a lease's downloads
391
+ go, and that only a context it made may it dispose."""
392
+ if self.contexts is None:
393
+ return guard(method, params, dialogs_answered=self.dialogs_answered)
394
+ if method == ENDS_CONTEXT and (reason := self.contexts.may_dispose(connection.user,
395
+ params.get("browserContextId"))):
396
+ return Verdict("refuse", params, reason)
397
+ download_path = None
398
+ if method in SETS_DOWNLOADS:
399
+ connection.set_downloads = True
400
+ context = params.get("browserContextId") if method.startswith("Browser.") else \
401
+ self._context_of(connection.targets.get(session))
402
+ download_path = self.contexts.download_path(context)
403
+ return guard(method, params, dialogs_answered=self.dialogs_answered, download_path=download_path)
404
+
405
+ def _context_of(self, target: Optional[str]) -> Optional[str]:
406
+ return self.control.tabs.get(target, {}).get("context_id") if self.control is not None and target else None
407
+
408
+ def _answered(self, connection: _Connection, method: str, params: dict, result: dict) -> None:
409
+ """A context ``connection`` made leased to its user before it hears the answer, and one it disposed ended."""
410
+ if self.contexts is None:
411
+ return
412
+ if method == MAKES_CONTEXT and isinstance(made := result.get("browserContextId"), str):
413
+ self.contexts.made_by_agent(connection.user, made)
414
+ if params.get("disposeOnDetach"):
415
+ connection.ends_on_detach.add(made)
416
+ elif method == ENDS_CONTEXT:
417
+ self.contexts.disposed(params.get("browserContextId"))
418
+
419
+ def _detached(self, connection: _Connection) -> None:
420
+ """``connection`` gone: the contexts it made to end as it detached ended, and the leases' downloads sent to
421
+ their folders again if it set downloads, which its session's end may set otherwise."""
422
+ if self.contexts is None:
423
+ return
424
+ for context in connection.ends_on_detach:
425
+ self.contexts.disposed(context)
426
+ if connection.set_downloads:
427
+ self.contexts.resend_downloads()
428
+
376
429
  def _begin(self, connection: _Connection, session: str, method: str, params: dict) -> Optional[_Logged]:
377
430
  """``connection``'s command, begun in the log, if there is one, on the tab ``session`` is on, or for a browser
378
431
  command the tab it names, ``for`` the tool calls of its user's open now; what it causes made known to the
@@ -0,0 +1,241 @@
1
+ """The contexts a website browser leases beside its default one: each a browser context with its own cookies, local
2
+ storage, tabs and downloads folder, named by a label, granted to the agents a task or the relay names, and ended by its
3
+ release, a reset or the browser's relaunch, which no context outlives. A context an agent makes over CDP is leased to
4
+ that agent as ``agent-<user>-<n>``; one made unseen, ``agent-unknown-<n>``, to nobody. Grants are recorded, not
5
+ enforced: the CDP addresses agents hold still see every context."""
6
+ from __future__ import annotations
7
+
8
+ import asyncio
9
+ import contextlib
10
+ import logging
11
+ import re
12
+ import shutil
13
+ from dataclasses import dataclass, field
14
+ from pathlib import Path
15
+ from typing import TYPE_CHECKING, Callable, Optional
16
+
17
+ from ..computer.errors import InvalidArgument, TargetUnavailable
18
+ from .control import DOWNLOADS
19
+ from .devtools import DevToolsError
20
+
21
+ if TYPE_CHECKING:
22
+ from .control import BrowserControl
23
+ from .devtools import DevToolsPipe
24
+
25
+ logger = logging.getLogger(__name__)
26
+
27
+ #: Where each lease's files are under the session user's home, a folder per label.
28
+ CONTEXTS = "Contexts"
29
+ #: Who made a lease: the task, through ``contexts/lease``; else the agent that made it over CDP, by its user, or
30
+ #: ``UNKNOWN`` for one made where the relay didn't see.
31
+ TASK, UNKNOWN = "task", "unknown"
32
+ #: How the labels of contexts agents make start, which a task's labels may not.
33
+ AGENT_PREFIX = "agent-"
34
+ #: The longest label, so ``chromium-<label>`` stays a short name.
35
+ LABEL_CHARS = 40
36
+ _LABEL = re.compile(r"[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")
37
+
38
+
39
+ def label_problem(label: object, *, by_task: bool = True) -> Optional[str]:
40
+ """Why ``label`` can't name a lease, or None: lowercase letters, digits and ``-``, not at either end, at most
41
+ ``LABEL_CHARS`` of them; a task's may not start ``agent-``, which names the contexts agents make."""
42
+ if not isinstance(label, str) or len(label) > LABEL_CHARS or not _LABEL.fullmatch(label):
43
+ return (f"a context's label is lowercase letters, digits and '-', not at either end, at most {LABEL_CHARS} "
44
+ f"characters, not {label!r}")
45
+ if by_task and label.startswith(AGENT_PREFIX):
46
+ return f"a label starting {AGENT_PREFIX!r} names a context an agent made, so a task's can't: {label!r}"
47
+ return None
48
+
49
+
50
+ @dataclass
51
+ class Lease:
52
+ """A leased context: its ``label``, the browser's ``id`` for it, who made it and the agents it's granted to."""
53
+
54
+ label: str
55
+ id: str
56
+ made_by: str = TASK
57
+ grants: list[str] = field(default_factory=list)
58
+
59
+ def folder(self, home: Path) -> Path:
60
+ return home / CONTEXTS / self.label
61
+
62
+ def under(self) -> str:
63
+ """Its downloads folder's path under the home."""
64
+ return f"{CONTEXTS}/{self.label}/{DOWNLOADS}"
65
+
66
+ def downloads(self, home: Path) -> Path:
67
+ return home / self.under()
68
+
69
+ def record(self) -> dict:
70
+ return {"context": self.label, "id": self.id, "made_by": self.made_by, "grants": list(self.grants)}
71
+
72
+
73
+ class Contexts:
74
+ """A browser's leases by label, in memory, since a server that restarts relaunches the browser and so ends them
75
+ all, and what leasing, releasing and recording them does over its pipe ``devtools``. ``control`` follows each
76
+ context's tabs, storage and downloads; ``home`` is the session user's home."""
77
+
78
+ def __init__(self, devtools: DevToolsPipe, control: BrowserControl,
79
+ home: Callable[[], Path] = Path.home) -> None:
80
+ self.devtools, self.control, self.home = devtools, control, home
81
+ self.leases: dict[str, Lease] = {}
82
+ self._made: dict[str, int] = {}
83
+ self._tasks: set[asyncio.Future] = set()
84
+ self._lock = asyncio.Lock()
85
+
86
+ def __iter__(self):
87
+ return iter(list(self.leases.values()))
88
+
89
+ def get(self, label: str) -> Optional[Lease]:
90
+ return self.leases.get(label)
91
+
92
+ def of(self, context_id: Optional[str]) -> Optional[Lease]:
93
+ return next((lease for lease in self.leases.values() if lease.id == context_id), None) \
94
+ if context_id else None
95
+
96
+ def id_of(self, label: Optional[str]) -> Optional[str]:
97
+ """The browser's id for the lease ``label``, None for the default context; TargetUnavailable for a label that
98
+ isn't leased."""
99
+ if label is None:
100
+ return None
101
+ if (lease := self.leases.get(label)) is None:
102
+ raise TargetUnavailable(f"no context {label!r} is leased; contexts/list names the leased ones")
103
+ return lease.id
104
+
105
+ async def lease(self, label: str, *, made_by: str = TASK, grants: tuple[str, ...] = ()) -> Lease:
106
+ """The lease ``label``: the one leased under it before, as a retried step finds it, else a new context, its
107
+ downloads going to its own folder. A task's label is checked; one ``made_by`` an agent may start ``agent-``,
108
+ as a load of a snapshot restores such leases."""
109
+ async with self._lock:
110
+ if (lease := self.leases.get(label)) is None:
111
+ if problem := label_problem(label, by_task=made_by == TASK):
112
+ raise InvalidArgument(problem)
113
+ context_id = (await self.devtools.call("Target.createBrowserContext", {"disposeOnDetach": False}))[
114
+ "browserContextId"]
115
+ lease = self._record(Lease(label, context_id, made_by))
116
+ await self._send_downloads(lease)
117
+ for user in grants:
118
+ self.grant(label, user)
119
+ return lease
120
+
121
+ def grant(self, label: str, user: str) -> Lease:
122
+ """The lease ``label`` granted to ``user`` too, recorded; granting a user twice changes nothing."""
123
+ if not isinstance(user, str) or not user:
124
+ raise InvalidArgument("a grant names the agent's user, a non-empty string")
125
+ if (lease := self.leases.get(label)) is None:
126
+ raise TargetUnavailable(f"no context {label!r} is leased; contexts/list names the leased ones")
127
+ if user not in lease.grants:
128
+ lease.grants.append(user)
129
+ return lease
130
+
131
+ async def release(self, label: str) -> bool:
132
+ """The lease ``label`` ended: its context disposed, which closes its tabs, and its folder deleted. Whether
133
+ there was one: releasing a label that isn't leased does nothing, so a retried step is harmless."""
134
+ async with self._lock:
135
+ if (lease := self.leases.pop(label, None)) is None:
136
+ return False
137
+ self.control.closing_context(lease.id)
138
+ with contextlib.suppress(DevToolsError):
139
+ await self.devtools.call("Target.disposeBrowserContext", {"browserContextId": lease.id})
140
+ await asyncio.to_thread(shutil.rmtree, lease.folder(self.home()), True)
141
+ return True
142
+
143
+ def made_by_agent(self, user: str, context_id: str) -> Lease:
144
+ """The context ``context_id`` an agent made over CDP as ``user``, leased to it as ``agent-<user>-<n>``,
145
+ starting empty, its downloads sent to its own folder."""
146
+ if (known := self.of(context_id)) is not None:
147
+ return known
148
+ lease = self._record(Lease(self._agent_label(user), context_id, user, [user]))
149
+ self._spawn(self._send_downloads(lease))
150
+ return lease
151
+
152
+ async def find_unseen(self) -> list[Lease]:
153
+ """Each context the browser has that no lease names, made where the relay didn't see, leased to nobody as
154
+ ``agent-unknown-<n>``; the leases it made."""
155
+ try:
156
+ ids = (await self.devtools.call("Target.getBrowserContexts"))["browserContextIds"]
157
+ except (ConnectionError, DevToolsError, KeyError):
158
+ return []
159
+ found = []
160
+ for context_id in ids:
161
+ if self.of(context_id) is None:
162
+ found.append(self._record(Lease(self._agent_label(UNKNOWN), context_id, UNKNOWN)))
163
+ await self._send_downloads(found[-1])
164
+ return found
165
+
166
+ def may_dispose(self, user: str, context_id: Optional[str]) -> Optional[str]:
167
+ """Why an agent ``user`` may not dispose the context ``context_id``, or None: only a context it made ends
168
+ that way; a task's lease ends by its release, and another agent's isn't its to end."""
169
+ lease = self.of(context_id)
170
+ if lease is None or lease.made_by == user:
171
+ return None
172
+ return (f"the context {lease.label!r} is the task's, which ends by its release" if lease.made_by == TASK else
173
+ f"the context {lease.label!r} is another agent's")
174
+
175
+ def disposed(self, context_id: Optional[str]) -> None:
176
+ """The context ``context_id`` an agent disposed: its lease ended and its folder moved aside at once, then
177
+ deleted, so a lease of its label after has a folder of its own."""
178
+ if (lease := self.of(context_id)) is not None:
179
+ self.leases.pop(lease.label, None)
180
+ folder, gone = lease.folder(self.home()), self.home() / CONTEXTS / f".gone-{lease.id}"
181
+ with contextlib.suppress(OSError):
182
+ folder.rename(gone)
183
+ self._spawn(asyncio.to_thread(shutil.rmtree, gone, True))
184
+
185
+ def download_path(self, context_id: Optional[str]) -> Optional[str]:
186
+ """Where the lease of the context ``context_id`` saves downloads, None for the default context or one that
187
+ isn't leased."""
188
+ lease = self.of(context_id)
189
+ return str(lease.downloads(self.home())) if lease is not None else None
190
+
191
+ def holding(self, path: str) -> Optional[str]:
192
+ """The browser's id for the lease whose downloads folder holds ``path``, None for any other path."""
193
+ home = self.home()
194
+ return next((lease.id for lease in self.leases.values() if Path(path).is_relative_to(lease.downloads(home))),
195
+ None)
196
+
197
+ def resend_downloads(self) -> None:
198
+ """Each lease's downloads sent to its own folder again, as an agent's session that set them may leave them
199
+ set otherwise as it ends."""
200
+ for lease in self:
201
+ self._spawn(self._send_downloads(lease))
202
+
203
+ def ended(self) -> None:
204
+ """The browser has gone, and every context with it: no lease is left, and their folders are deleted."""
205
+ self.leases.clear()
206
+ self._made.clear()
207
+ shutil.rmtree(self.home() / CONTEXTS, ignore_errors=True)
208
+
209
+ def _record(self, lease: Lease) -> Lease:
210
+ self.leases[lease.label] = lease
211
+ self.control.other_contexts[lease.id] = lease.label
212
+ lease.downloads(self.home()).mkdir(parents=True, exist_ok=True)
213
+ return lease
214
+
215
+ def _agent_label(self, user: str) -> str:
216
+ """The label of the next context ``user`` makes: ``agent-<user>-<n>``, its user lowercased, each run of
217
+ other characters a ``-``, and cut to fit."""
218
+ name = re.sub(r"[^a-z0-9]+", "-", user.lower()).strip("-") or UNKNOWN
219
+ while True:
220
+ self._made[name] = self._made.get(name, 0) + 1
221
+ tail = f"-{self._made[name]}"
222
+ label = f"{AGENT_PREFIX}{name[:LABEL_CHARS - len(AGENT_PREFIX) - len(tail)].rstrip('-')}{tail}"
223
+ if label not in self.leases:
224
+ return label
225
+
226
+ async def _send_downloads(self, lease: Lease) -> None:
227
+ """The lease's downloads sent to its own folder, which reports them on agentenv's connection."""
228
+ with contextlib.suppress(ConnectionError, DevToolsError):
229
+ await self.devtools.call("Browser.setDownloadBehavior", {
230
+ "behavior": "allow", "browserContextId": lease.id, "downloadPath": str(lease.downloads(self.home())),
231
+ "eventsEnabled": True})
232
+
233
+ def _spawn(self, work) -> None:
234
+ task = asyncio.ensure_future(work)
235
+ self._tasks.add(task)
236
+ task.add_done_callback(self._finished)
237
+
238
+ def _finished(self, task: asyncio.Future) -> None:
239
+ self._tasks.discard(task)
240
+ if not task.cancelled() and (error := task.exception()) is not None:
241
+ logger.warning(f"the browser's contexts: {type(error).__name__}: {error}")