agentenv-framework-protocol 0.1.541__tar.gz → 0.1.544__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.
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/PKG-INFO +1 -1
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/pyproject.toml +1 -1
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/dataplane.py +3 -2
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/serve.py +4 -1
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/serve_app.py +5 -1
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/svc.py +10 -3
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/transfers.py +25 -3
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/cdp.py +124 -32
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/contexts.py +13 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/control.py +12 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/environment.py +33 -6
- agentenv_framework_protocol-0.1.544/src/agentenv_protocol/website_browser/scope.py +155 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_a2a_object_transfers.py +57 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_browser_cdp.py +261 -4
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_browser_contexts.py +48 -1
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_svc_forward.py +5 -5
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/.gitignore +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/LICENSE +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/NOTICE +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/README.md +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/THIRD_PARTY_NOTICES.md +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/advanced_agent.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/basic_agent.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/custom_extensions_agent.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/multimodal_agent.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/reference_model.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/streaming_agent.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/.gitignore +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/Dockerfile +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/Dockerfile.dockerignore +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/README.md +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/data/seed.json +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/env.toml +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/site.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/web/index.html +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/web/package-lock.json +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/web/package.json +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/web/src/main.js +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/web/src/style.css +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/examples/website/notes/web/vite.config.js +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/_trajectory_log.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/_triggers.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/extensions.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/framework.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/peer_agents.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/proxy.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/registry.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/staging.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/tasks/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/a2a_agent/tasks/v1.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/agent_env_environment.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/client.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_declare.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_desktop.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_job.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_linux.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_load.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_macos.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_reaping.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_session_posix.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_session_windows.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_windows.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_with_fds.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/_x11.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/app.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/app_data.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/app_runtime.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/apps.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/card.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/checks.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/clock.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/conformance/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/conformance/__main__.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/conformance/checks.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/conformance/client.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/conformance/desk.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/conformance/fixture.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/conformance/mp4.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/conformance/page_fixture.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/conformance/report.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/conformance/wayland_fixture.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/driver.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/errors.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/extensions.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/frames.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/keys.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/launch.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/manifest.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/operations.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/platform.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/prefix.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/queue.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/recording.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/results.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/run_install_step.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/runtime.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/seed.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/served.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/session.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/settings.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/skill.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/spaces.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/computer/tools.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/errors.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/manifest.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/preflight.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/tool_access.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/tool_client.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/tool_context.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/types.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website/clock.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website/conformance.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website/environment.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website/errors.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website/readiness.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website/routes.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website/session.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/data.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/devtools.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/log.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/network.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/recording.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/src/agentenv_protocol/website_browser/shapes.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/computer_fake.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/probe_fake.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_a2a_agent.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_a2a_agent_examples.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_a2a_cdp_config.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_a2a_peer_agents.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_a2a_proxy.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_a2a_staging.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_a2a_trajectory_log.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_agent_env_environment.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_browser_data.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_browser_log.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_browser_network.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_browser_recording.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_browser_state.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_client.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_app_data.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_app_server.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_clock.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_conformance.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_conformance_checks.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_conformance_page.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_conformance_recording.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_dataplane.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_declare.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_driver.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_driver_keys.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_extensions.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_frames.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_macos.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_page.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_queue.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_recording.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_seed.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_serve.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_served.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_session_windows.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_spaces.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_tool_prefix.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_computer_windows_driver.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_control_token.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_data_objects.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_devtools_pipe.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_errors.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_extension_methods.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_intake.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_manifest.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_preflight.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_tool_access.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_tool_annotations.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_tool_client.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_tool_context.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_tool_context_fastmcp.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_tool_context_injection.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_website_api.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_website_browser.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_website_conformance.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_website_environment.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_website_live.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_website_mcp.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/tests/test_website_notes_example.py +0 -0
- {agentenv_framework_protocol-0.1.541 → agentenv_framework_protocol-0.1.544}/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.
|
|
3
|
+
Version: 0.1.544
|
|
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
|
|
@@ -15,7 +15,8 @@ import httpx
|
|
|
15
15
|
from pydantic import TypeAdapter, ValidationError
|
|
16
16
|
|
|
17
17
|
from ..agent_env_environment import add_data, get_data
|
|
18
|
-
from ..transfers import NamespaceUploader, ReadObject, RelativePath, TransferError, WriteNamespaceGrant,
|
|
18
|
+
from ..transfers import (NamespaceUploader, ReadObject, RelativePath, TransferError, WriteNamespaceGrant, client_options,
|
|
19
|
+
download)
|
|
19
20
|
from ..types import DATA_OBJECTS_EXTENSION_URI, FilePart, FileWithBytes, FileWithUri, uploaded_file_part, uploaded_object_path
|
|
20
21
|
|
|
21
22
|
if TYPE_CHECKING:
|
|
@@ -115,7 +116,7 @@ async def _get_url(file: FileWithUri) -> bytes:
|
|
|
115
116
|
if not file.uri.startswith("https://"):
|
|
116
117
|
raise ValueError("a file part's uri is an https URL")
|
|
117
118
|
data = bytearray()
|
|
118
|
-
async with httpx.AsyncClient(follow_redirects=True, timeout=60) as client:
|
|
119
|
+
async with httpx.AsyncClient(follow_redirects=True, timeout=60, **client_options()) as client:
|
|
119
120
|
async with client.stream("GET", file.uri) as response:
|
|
120
121
|
response.raise_for_status()
|
|
121
122
|
async for chunk in response.aiter_bytes():
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"""Serve a computer driver from its file, as a composed computer's program starts it:
|
|
2
2
|
``python -m agentenv_protocol.computer.serve <file>:<Class>``, run in the driver's folder, serves the class on
|
|
3
|
-
``MCP_PORT``. The file's folder is importable, so it may import its own modules.
|
|
3
|
+
``MCP_PORT``. The file's folder is importable, so it may import its own modules. The driver runs on real time, so its
|
|
4
|
+
own transfers reach the object store directly, not through the computer's egress proxy (``transfers.direct``)."""
|
|
4
5
|
from __future__ import annotations
|
|
5
6
|
|
|
6
7
|
import sys
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
|
|
10
|
+
from .. import transfers
|
|
9
11
|
from ._load import load_class
|
|
10
12
|
from .driver import ComputerDriverEnvironment
|
|
11
13
|
|
|
@@ -16,6 +18,7 @@ def main(argv: list[str]) -> None:
|
|
|
16
18
|
if len(argv) != 1 or ":" not in argv[0]:
|
|
17
19
|
raise SystemExit(USAGE)
|
|
18
20
|
file, _, name = argv[0].partition(":")
|
|
21
|
+
transfers.direct()
|
|
19
22
|
driver_class(Path(file), name)().serve()
|
|
20
23
|
|
|
21
24
|
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
(``CONTROL_TOKEN_ENV``): the driver checks it in front of the app. Before it serves, it keeps a copy of
|
|
6
6
|
the app's data paths as installed, which a reset puts back; once it serves, it adds the app's launcher and launches a
|
|
7
7
|
boot app (``AppRuntime.start``). A server that can't start, or whose start fails once it serves, writes why to
|
|
8
|
-
``.agentenv/server.failure``, which its computer's driver reports, and exits.
|
|
8
|
+
``.agentenv/server.failure``, which its computer's driver reports, and exits. It runs on real time, so its own
|
|
9
|
+
transfers reach the object store directly, not through the computer's egress proxy (``transfers.direct``). Needs the
|
|
10
|
+
``app`` extra."""
|
|
9
11
|
from __future__ import annotations
|
|
10
12
|
|
|
11
13
|
import asyncio
|
|
@@ -17,6 +19,7 @@ from pathlib import Path
|
|
|
17
19
|
|
|
18
20
|
import uvicorn
|
|
19
21
|
|
|
22
|
+
from .. import transfers
|
|
20
23
|
from ..types import CONTROL_TOKEN_ENV
|
|
21
24
|
from ._load import load_class
|
|
22
25
|
from .app import FAILURE, ComputerAppEnvironment
|
|
@@ -27,6 +30,7 @@ USAGE = "usage: python -m agentenv_protocol.computer.serve_app <file>:<Class>"
|
|
|
27
30
|
|
|
28
31
|
def main(argv: list[str]) -> None:
|
|
29
32
|
FAILURE.unlink(missing_ok=True)
|
|
33
|
+
transfers.direct()
|
|
30
34
|
try:
|
|
31
35
|
_serve(argv)
|
|
32
36
|
except (Exception, SystemExit) as e:
|
|
@@ -188,13 +188,17 @@ def _utf8(value: str) -> str:
|
|
|
188
188
|
|
|
189
189
|
|
|
190
190
|
async def _both_ways(client: WebSocket, app: ClientConnection) -> None:
|
|
191
|
-
"""Each message from either side sent to the other until one side closes, then the other closed with its code
|
|
191
|
+
"""Each message from either side sent to the other until one side closes, then the other closed with its code and
|
|
192
|
+
reason."""
|
|
192
193
|
async def inbound() -> None:
|
|
193
194
|
while True:
|
|
194
195
|
message = await client.receive()
|
|
195
196
|
if message["type"] == "websocket.disconnect":
|
|
196
197
|
code = message.get("code") or 1000
|
|
197
|
-
|
|
198
|
+
if code in UNSENDABLE_CLOSES:
|
|
199
|
+
await app.close(1000)
|
|
200
|
+
else:
|
|
201
|
+
await app.close(code, message.get("reason") or "")
|
|
198
202
|
return
|
|
199
203
|
await app.send(message["text"] if message.get("text") is not None else message["bytes"])
|
|
200
204
|
|
|
@@ -207,7 +211,10 @@ async def _both_ways(client: WebSocket, app: ClientConnection) -> None:
|
|
|
207
211
|
await client.send_bytes(message)
|
|
208
212
|
code = app.close_code or 1000
|
|
209
213
|
with contextlib.suppress(RuntimeError, WebSocketDisconnect):
|
|
210
|
-
|
|
214
|
+
if code in UNSENDABLE_CLOSES:
|
|
215
|
+
await client.close(1000)
|
|
216
|
+
else:
|
|
217
|
+
await client.close(code, app.close_reason or "")
|
|
211
218
|
|
|
212
219
|
tasks = [asyncio.ensure_future(inbound()), asyncio.ensure_future(outbound())]
|
|
213
220
|
try:
|
|
@@ -46,6 +46,28 @@ _TRANSFER_TIMEOUT = httpx.Timeout(
|
|
|
46
46
|
write=TRANSFER_IDLE_TIMEOUT_SECONDS,
|
|
47
47
|
pool=_CONNECT_TIMEOUT_SECONDS,
|
|
48
48
|
)
|
|
49
|
+
#: Whether this process's transfers take a proxy from the environment's settings. A computer's own servers turn it
|
|
50
|
+
#: off (``direct``): they run on real time and reach the object store directly, while the programs they start keep
|
|
51
|
+
#: the settings that send them through the computer's egress proxy.
|
|
52
|
+
_proxy_from_environment = True
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def direct() -> None:
|
|
56
|
+
"""Have this process's transfers reach their objects directly, whatever proxy the environment names; the
|
|
57
|
+
environment, and so every process this one starts, keeps it."""
|
|
58
|
+
global _proxy_from_environment
|
|
59
|
+
_proxy_from_environment = False
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def client_options() -> dict:
|
|
63
|
+
"""The options a transfer's HTTP client takes: none, or for a ``direct`` process, no proxy from the environment
|
|
64
|
+
but still its certificates (``SSL_CERT_FILE``, ``SSL_CERT_DIR``), since httpx takes both from it or neither and a
|
|
65
|
+
local store's CA is trusted through them."""
|
|
66
|
+
if _proxy_from_environment:
|
|
67
|
+
return {}
|
|
68
|
+
return {"trust_env": False, "verify": httpx.create_ssl_context(trust_env=True)}
|
|
69
|
+
|
|
70
|
+
|
|
49
71
|
# The longest the helpers take to give up on a transfer whose every connection stalls.
|
|
50
72
|
TRANSFER_STALL_BUDGET_SECONDS = TRANSFER_ATTEMPTS * (
|
|
51
73
|
_CONNECT_TIMEOUT_SECONDS + TRANSFER_IDLE_TIMEOUT_SECONDS
|
|
@@ -483,7 +505,7 @@ async def upload(target: WriteObject, source: Path | bytes) -> Uploaded:
|
|
|
483
505
|
async def put() -> Uploaded:
|
|
484
506
|
with _transfer_request(target.write.expires_at):
|
|
485
507
|
async with httpx.AsyncClient(
|
|
486
|
-
follow_redirects=False, timeout=_TRANSFER_TIMEOUT
|
|
508
|
+
follow_redirects=False, timeout=_TRANSFER_TIMEOUT, **client_options()
|
|
487
509
|
) as client:
|
|
488
510
|
|
|
489
511
|
async def to(url: str) -> Uploaded:
|
|
@@ -519,7 +541,7 @@ async def download(source: ReadObject, destination: Path) -> None:
|
|
|
519
541
|
digest = hashlib.sha256()
|
|
520
542
|
with _transfer_request(source.read.expires_at):
|
|
521
543
|
async with httpx.AsyncClient(
|
|
522
|
-
follow_redirects=False, timeout=_TRANSFER_TIMEOUT
|
|
544
|
+
follow_redirects=False, timeout=_TRANSFER_TIMEOUT, **client_options()
|
|
523
545
|
) as client:
|
|
524
546
|
response = await _send_to_first_listening(
|
|
525
547
|
urls,
|
|
@@ -571,7 +593,7 @@ def _post_to_namespace(
|
|
|
571
593
|
fields.setdefault("Content-Type", "application/octet-stream")
|
|
572
594
|
with (
|
|
573
595
|
_transfer_request(target.expires_at),
|
|
574
|
-
httpx.Client(follow_redirects=False, timeout=_TRANSFER_TIMEOUT) as client,
|
|
596
|
+
httpx.Client(follow_redirects=False, timeout=_TRANSFER_TIMEOUT, **client_options()) as client,
|
|
575
597
|
):
|
|
576
598
|
|
|
577
599
|
def to(url: str) -> Uploaded:
|
|
@@ -18,8 +18,10 @@ from typing import TYPE_CHECKING, Any, Literal, Optional
|
|
|
18
18
|
from starlette.requests import Request
|
|
19
19
|
from starlette.websockets import WebSocket, WebSocketDisconnect
|
|
20
20
|
|
|
21
|
+
from .devtools import DevToolsError
|
|
21
22
|
from .log import (ERROR_CHARS, KEY_FIELDS, TYPING_METHODS, BrowserLog, acts, redact_text, redacted_args,
|
|
22
23
|
redacted_params)
|
|
24
|
+
from .scope import ENDS_CONTEXT, MAKES_CONTEXT, WITH_INFO, Scope, Targets
|
|
23
25
|
|
|
24
26
|
if TYPE_CHECKING:
|
|
25
27
|
from .contexts import Contexts
|
|
@@ -34,6 +36,8 @@ TOKEN_BYTES = 32
|
|
|
34
36
|
ROUTE = "/cdp/"
|
|
35
37
|
#: The close code and reason a connection gets when its browser goes away, which a client may connect again after.
|
|
36
38
|
RELAUNCHED = (1012, "the browser relaunched: connect again")
|
|
39
|
+
#: The close code and reason a connection scoped to a lease gets when the lease ends, which its address ends with.
|
|
40
|
+
LEASE_ENDED = (1001, "the lease ended: ask for an address again")
|
|
37
41
|
#: The close code and reason a connection gets when its client falls behind by more than ``OUTBOX_LIMIT_BYTES``.
|
|
38
42
|
TOO_SLOW = (1013, "the client fell too far behind: connect again")
|
|
39
43
|
#: How much a connection's client may have waiting to be sent to it before it is closed; a single answer bigger than
|
|
@@ -52,8 +56,6 @@ MALFORMED = {"code": -32600, "message": "a command is an object with a string me
|
|
|
52
56
|
ENDS_BROWSER = frozenset({"Browser.close", "Browser.crash", "Browser.crashGpuProcess"})
|
|
53
57
|
#: The commands that set how and where downloads are saved, which agentenv keeps as its own.
|
|
54
58
|
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"
|
|
57
59
|
#: The schemes of the browser's own files, settings and tools, which an agent's navigation or new tab may not open.
|
|
58
60
|
OWN_SCHEMES = frozenset({"file", "chrome", "chrome-extension", "chrome-untrusted", "view-source", "devtools"})
|
|
59
61
|
#: The ``about:`` pages that aren't the browser's own under another name.
|
|
@@ -77,6 +79,8 @@ class Address:
|
|
|
77
79
|
http_url: str
|
|
78
80
|
ws_url: str
|
|
79
81
|
named: bool = False
|
|
82
|
+
#: The label of the lease it's scoped to, None for the browser's default context.
|
|
83
|
+
context: Optional[str] = None
|
|
80
84
|
|
|
81
85
|
|
|
82
86
|
def reached(request: Request) -> str:
|
|
@@ -102,19 +106,22 @@ def _hash(token: str) -> str:
|
|
|
102
106
|
return hashlib.sha256(token.encode()).hexdigest()
|
|
103
107
|
|
|
104
108
|
|
|
105
|
-
def _address(user: str, base: str, named: bool, token: str) -> Address:
|
|
109
|
+
def _address(user: str, base: str, named: bool, token: str, context: Optional[str] = None) -> Address:
|
|
106
110
|
root = f"{base}{ROUTE}{token}"
|
|
107
|
-
return Address(user, f"{root}/", f"{websocket_form(root)}/devtools/browser", named)
|
|
111
|
+
return Address(user, f"{root}/", f"{websocket_form(root)}/devtools/browser", named, context)
|
|
108
112
|
|
|
109
113
|
|
|
110
114
|
class Tokens:
|
|
111
115
|
"""The tokens minted, one per user: in memory, so asking twice gives the same address, and in ``path`` only by
|
|
112
116
|
hash, with the user, the base address and whether its caller named it, so an address still works after the server
|
|
113
|
-
restarts while the computer's session, which can read the file, can't use one.
|
|
117
|
+
restarts while the computer's session, which can read the file, can't use one. A token scoped to a lease is one per
|
|
118
|
+
user and lease, in memory only, as no lease outlives the server; the lease's end revokes it."""
|
|
114
119
|
|
|
115
120
|
def __init__(self, path: Path) -> None:
|
|
116
121
|
self.path = path
|
|
117
122
|
self._minted: dict[str, Address] = {}
|
|
123
|
+
self._scoped: dict[tuple[str, str], Address] = {}
|
|
124
|
+
self._scoped_known: dict[str, tuple[str, str, bool, str]] = {}
|
|
118
125
|
try:
|
|
119
126
|
stored = json.loads(path.read_text())
|
|
120
127
|
self._known = {digest: (entry["user"], entry["base"], entry["named"])
|
|
@@ -122,9 +129,15 @@ class Tokens:
|
|
|
122
129
|
except (OSError, ValueError, TypeError, KeyError):
|
|
123
130
|
self._known = {}
|
|
124
131
|
|
|
125
|
-
def mint(self, user: str, base: str, *, named: bool = False) -> Address:
|
|
126
|
-
"""``user``'s address under ``base``, ``named`` when its caller named where its agent reaches the env
|
|
127
|
-
minted before, else a new one."""
|
|
132
|
+
def mint(self, user: str, base: str, *, named: bool = False, context: Optional[str] = None) -> Address:
|
|
133
|
+
"""``user``'s address under ``base``, ``named`` when its caller named where its agent reaches the env, scoped
|
|
134
|
+
to the lease ``context`` when it names one: the one minted before, else a new one."""
|
|
135
|
+
if context is not None:
|
|
136
|
+
if (user, context) not in self._scoped:
|
|
137
|
+
token = secrets.token_urlsafe(TOKEN_BYTES)
|
|
138
|
+
self._scoped[(user, context)] = _address(user, base, named, token, context)
|
|
139
|
+
self._scoped_known[_hash(token)] = (user, base, named, context)
|
|
140
|
+
return self._scoped[(user, context)]
|
|
128
141
|
if user not in self._minted:
|
|
129
142
|
token = secrets.token_urlsafe(TOKEN_BYTES)
|
|
130
143
|
self._minted[user] = _address(user, base, named, token)
|
|
@@ -134,13 +147,22 @@ class Tokens:
|
|
|
134
147
|
|
|
135
148
|
def revoke_all(self) -> None:
|
|
136
149
|
"""Every address minted so far ended, as a reset ends them."""
|
|
137
|
-
self._minted, self._known = {}, {}
|
|
150
|
+
self._minted, self._known, self._scoped, self._scoped_known = {}, {}, {}, {}
|
|
138
151
|
self._save()
|
|
139
152
|
|
|
153
|
+
def revoke(self, context: str) -> None:
|
|
154
|
+
"""Every address scoped to the lease ``context`` ended, as the lease has."""
|
|
155
|
+
self._scoped = {key: address for key, address in self._scoped.items() if key[1] != context}
|
|
156
|
+
self._scoped_known = {digest: known for digest, known in self._scoped_known.items() if known[3] != context}
|
|
157
|
+
|
|
140
158
|
def address(self, token: str) -> Optional[Address]:
|
|
141
|
-
"""The address ``token`` was minted for, or None for one that wasn't."""
|
|
142
|
-
|
|
143
|
-
|
|
159
|
+
"""The address ``token`` was minted for, or None for one that wasn't, or whose lease has ended."""
|
|
160
|
+
digest = _hash(token)
|
|
161
|
+
if (known := self._known.get(digest)) is not None:
|
|
162
|
+
return _address(*known, token)
|
|
163
|
+
if (scoped := self._scoped_known.get(digest)) is not None:
|
|
164
|
+
return _address(*scoped[:3], token, scoped[3])
|
|
165
|
+
return None
|
|
144
166
|
|
|
145
167
|
def _save(self) -> None:
|
|
146
168
|
self.path.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -159,6 +181,8 @@ class Verdict:
|
|
|
159
181
|
params: dict
|
|
160
182
|
reason: str = ""
|
|
161
183
|
changed: bool = False
|
|
184
|
+
#: The error a refusal answers with in place of agentenv's own, as for a target the connection doesn't see.
|
|
185
|
+
error: Optional[dict] = None
|
|
162
186
|
|
|
163
187
|
|
|
164
188
|
def guard(method: str, params: dict, *, dialogs_answered: bool, download_path: Optional[str] = None) -> Verdict:
|
|
@@ -204,11 +228,14 @@ class _Connection:
|
|
|
204
228
|
"""One client's WebSocket, its sessions over the pipe (its browser-level one and those it attached), its unanswered
|
|
205
229
|
commands, what waits to be sent to it, and its entry in the record."""
|
|
206
230
|
|
|
207
|
-
def __init__(self, websocket: WebSocket, user: str, session: str, record: dict, number: int
|
|
231
|
+
def __init__(self, websocket: WebSocket, user: str, session: str, record: dict, number: int,
|
|
232
|
+
scope: Optional[Scope] = None) -> None:
|
|
208
233
|
self.websocket, self.user, self.session, self.record, self.number = websocket, user, session, record, number
|
|
234
|
+
#: What it sees and acts in, a lease or the default context; None where the relay keeps no contexts.
|
|
235
|
+
self.scope = scope
|
|
209
236
|
self.sessions = {session}
|
|
210
237
|
#: The tab each session it attached is on.
|
|
211
|
-
self.
|
|
238
|
+
self.session_tabs: dict[str, str] = {}
|
|
212
239
|
#: Held by each of its commands from when it arrives until it's sent, so they're sent in the order they came,
|
|
213
240
|
#: whatever one waits on before it's sent.
|
|
214
241
|
self.order = asyncio.Lock()
|
|
@@ -251,12 +278,16 @@ class Relay:
|
|
|
251
278
|
causes the tab events a command brings. An agent's tool call a driver serves through a CDP user's connections,
|
|
252
279
|
such as Playwright MCP's, is an entry too, which that user's commands are credited to while it's open. With
|
|
253
280
|
``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.
|
|
281
|
+
downloads stay in its folder. A connection is scoped to a lease or to the default context, and sees only its scope
|
|
282
|
+
and the contexts its user made (``scope``)."""
|
|
255
283
|
|
|
256
284
|
def __init__(self, devtools: DevToolsPipe, *, dialogs_answered: bool = False, log: Optional[BrowserLog] = None,
|
|
257
285
|
control: Optional[BrowserControl] = None, contexts: Optional[Contexts] = None) -> None:
|
|
258
286
|
self.devtools, self.dialogs_answered, self.log, self.control = devtools, dialogs_answered, log, control
|
|
259
287
|
self.contexts = contexts
|
|
288
|
+
#: Each target's context, as Chromium reports it.
|
|
289
|
+
self.target_contexts = Targets()
|
|
290
|
+
self._tasks: set[asyncio.Future] = set()
|
|
260
291
|
self.connections: list[dict] = []
|
|
261
292
|
self._by_session: dict[str, _Connection] = {}
|
|
262
293
|
self._open: set[_Connection] = set()
|
|
@@ -291,15 +322,32 @@ class Relay:
|
|
|
291
322
|
self.log.finish(call.begun, **fields)
|
|
292
323
|
return True
|
|
293
324
|
|
|
294
|
-
async def serve(self, websocket: WebSocket, user: str) -> None:
|
|
295
|
-
"""``websocket``, a client of ``user``'s, relayed over a browser-level session of its own until either ends
|
|
325
|
+
async def serve(self, websocket: WebSocket, user: str, context: Optional[str] = None) -> None:
|
|
326
|
+
"""``websocket``, a client of ``user``'s, relayed over a browser-level session of its own until either ends,
|
|
327
|
+
scoped to the lease ``context`` when it names one."""
|
|
328
|
+
lease_id = None
|
|
329
|
+
if context is not None:
|
|
330
|
+
lease = self.contexts.get(context) if self.contexts is not None else None
|
|
331
|
+
if lease is None:
|
|
332
|
+
await websocket.accept()
|
|
333
|
+
await websocket.close(code=LEASE_ENDED[0], reason=LEASE_ENDED[1])
|
|
334
|
+
return
|
|
335
|
+
lease_id = lease.id
|
|
296
336
|
try:
|
|
297
337
|
session = (await self.devtools.call("Target.attachToBrowserTarget"))["sessionId"]
|
|
298
338
|
except Exception as e:
|
|
299
339
|
await websocket.close(code=1013, reason=f"the browser isn't answering: {type(e).__name__}")
|
|
300
340
|
return
|
|
301
|
-
|
|
302
|
-
|
|
341
|
+
if context is not None and ((lease := self.contexts.get(context)) is None or lease.id != lease_id):
|
|
342
|
+
with contextlib.suppress(Exception):
|
|
343
|
+
await self.devtools.call("Target.detachFromTarget", {"sessionId": session})
|
|
344
|
+
await websocket.accept()
|
|
345
|
+
await websocket.close(code=LEASE_ENDED[0], reason=LEASE_ENDED[1])
|
|
346
|
+
return
|
|
347
|
+
record = {"user": user, "opened_at": _now(), "guarded": [], **({"context": context} if context else {})}
|
|
348
|
+
scope = Scope(self.contexts, self.target_contexts, user, lease_id, self._frame_context) \
|
|
349
|
+
if self.contexts is not None else None
|
|
350
|
+
connection = _Connection(websocket, user, session, record, len(self.connections) + 1, scope)
|
|
303
351
|
self._by_session[session] = connection
|
|
304
352
|
self._open.add(connection)
|
|
305
353
|
self.connections.append(record)
|
|
@@ -331,6 +379,14 @@ class Relay:
|
|
|
331
379
|
"""The browser has gone: every connection is closed with a reason a client may connect again after."""
|
|
332
380
|
for connection in list(self._open):
|
|
333
381
|
self._close(connection, RELAUNCHED)
|
|
382
|
+
self.target_contexts.forget()
|
|
383
|
+
|
|
384
|
+
def lease_ended(self, context_id: str) -> None:
|
|
385
|
+
"""The lease the browser knows as ``context_id`` has ended: each connection scoped to it is closed, saying
|
|
386
|
+
so."""
|
|
387
|
+
for connection in list(self._open):
|
|
388
|
+
if connection.scope is not None and connection.scope.lease == context_id:
|
|
389
|
+
self._close(connection, LEASE_ENDED)
|
|
334
390
|
|
|
335
391
|
async def _command(self, connection: _Connection, message: Any) -> None:
|
|
336
392
|
if connection.closing:
|
|
@@ -351,6 +407,8 @@ class Relay:
|
|
|
351
407
|
replied = True
|
|
352
408
|
if sending is not None and isinstance(answer.get("result"), dict):
|
|
353
409
|
self._answered(connection, method, params, answer["result"])
|
|
410
|
+
if connection.scope is not None:
|
|
411
|
+
answer = {**answer, "result": connection.scope.answer(method, answer["result"])}
|
|
354
412
|
self._put(connection, _reply(message, answer))
|
|
355
413
|
|
|
356
414
|
try:
|
|
@@ -360,8 +418,8 @@ class Relay:
|
|
|
360
418
|
if session not in connection.sessions:
|
|
361
419
|
verdict, answer = None, {"error": NO_SESSION}
|
|
362
420
|
elif verdict.action == "refuse":
|
|
363
|
-
answer = {"error": {"code": SERVER_ERROR,
|
|
364
|
-
|
|
421
|
+
answer = {"error": verdict.error or {"code": SERVER_ERROR,
|
|
422
|
+
"message": f"agentenv refuses {method}: {verdict.reason}"}}
|
|
365
423
|
elif verdict.action != "send":
|
|
366
424
|
answer = {"result": {}}
|
|
367
425
|
else:
|
|
@@ -387,24 +445,28 @@ class Relay:
|
|
|
387
445
|
logged.finish(answer, guarded)
|
|
388
446
|
|
|
389
447
|
def _verdict(self, connection: _Connection, session: str, method: str, params: dict) -> Verdict:
|
|
390
|
-
"""The guard's verdict on ``connection``'s command,
|
|
391
|
-
|
|
392
|
-
if
|
|
448
|
+
"""The guard's verdict on ``connection``'s command, after its scope's (``Scope.verdict``), and with where a
|
|
449
|
+
lease's downloads go."""
|
|
450
|
+
if connection.scope is None:
|
|
393
451
|
return guard(method, params, dialogs_answered=self.dialogs_answered)
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
return Verdict("refuse", params,
|
|
452
|
+
ruling = connection.scope.verdict(method, params, on_browser_session=session == connection.session)
|
|
453
|
+
if ruling.refused:
|
|
454
|
+
return Verdict("refuse", params, ruling.refused, error=ruling.error)
|
|
455
|
+
params = ruling.params
|
|
397
456
|
download_path = None
|
|
398
457
|
if method in SETS_DOWNLOADS:
|
|
399
458
|
connection.set_downloads = True
|
|
400
459
|
context = params.get("browserContextId") if method.startswith("Browser.") else \
|
|
401
|
-
self._context_of(connection.
|
|
460
|
+
self._context_of(connection.session_tabs.get(session))
|
|
402
461
|
download_path = self.contexts.download_path(context)
|
|
403
462
|
return guard(method, params, dialogs_answered=self.dialogs_answered, download_path=download_path)
|
|
404
463
|
|
|
405
464
|
def _context_of(self, target: Optional[str]) -> Optional[str]:
|
|
406
465
|
return self.control.tabs.get(target, {}).get("context_id") if self.control is not None and target else None
|
|
407
466
|
|
|
467
|
+
def _frame_context(self, frame: object) -> Optional[str]:
|
|
468
|
+
return self.control.context_of_frame(frame) if self.control is not None else None
|
|
469
|
+
|
|
408
470
|
def _answered(self, connection: _Connection, method: str, params: dict, result: dict) -> None:
|
|
409
471
|
"""A context ``connection`` made leased to its user before it hears the answer, and one it disposed ended."""
|
|
410
472
|
if self.contexts is None:
|
|
@@ -432,7 +494,7 @@ class Relay:
|
|
|
432
494
|
control."""
|
|
433
495
|
if self.log is None:
|
|
434
496
|
return None
|
|
435
|
-
target = connection.
|
|
497
|
+
target = connection.session_tabs.get(session) if session != connection.session else None
|
|
436
498
|
if target is None and isinstance(params.get("targetId"), str):
|
|
437
499
|
target = params["targetId"]
|
|
438
500
|
acting = acts(method)
|
|
@@ -451,23 +513,53 @@ class Relay:
|
|
|
451
513
|
guarded.append({"method": method, "did": GUARDED[verdict.action], "at": _now()})
|
|
452
514
|
|
|
453
515
|
def _event(self, message: dict) -> None:
|
|
516
|
+
params = message.get("params") or {}
|
|
517
|
+
if message.get("method") in WITH_INFO:
|
|
518
|
+
self.target_contexts.saw(params.get("targetInfo"))
|
|
454
519
|
connection = self._by_session.get(message.get("sessionId"))
|
|
455
520
|
if connection is None:
|
|
456
521
|
return
|
|
457
|
-
|
|
522
|
+
if message.get("sessionId") == connection.session and not self._hears(connection, message):
|
|
523
|
+
return
|
|
458
524
|
if message.get("method") == "Target.attachedToTarget" and params.get("sessionId"):
|
|
459
525
|
connection.sessions.add(params["sessionId"])
|
|
460
526
|
self._by_session[params["sessionId"]] = connection
|
|
461
527
|
if isinstance(target := (params.get("targetInfo") or {}).get("targetId"), str):
|
|
462
|
-
connection.
|
|
528
|
+
connection.session_tabs[params["sessionId"]] = target
|
|
463
529
|
elif message.get("method") == "Target.detachedFromTarget" and params.get("sessionId"):
|
|
464
530
|
connection.sessions.discard(params["sessionId"])
|
|
465
|
-
connection.
|
|
531
|
+
connection.session_tabs.pop(params["sessionId"], None)
|
|
466
532
|
self._by_session.pop(params["sessionId"], None)
|
|
467
533
|
if message["sessionId"] == connection.session:
|
|
468
534
|
message = {key: value for key, value in message.items() if key != "sessionId"}
|
|
469
535
|
self._put(connection, message)
|
|
470
536
|
|
|
537
|
+
def _hears(self, connection: _Connection, message: dict) -> bool:
|
|
538
|
+
"""Whether ``connection`` hears an event on its browser session, as its scope says: never one about a session it
|
|
539
|
+
doesn't have, and a target it doesn't see that auto-attached to it let go."""
|
|
540
|
+
if connection.scope is None:
|
|
541
|
+
return True
|
|
542
|
+
method, params = message.get("method"), message.get("params") or {}
|
|
543
|
+
if method == "Target.detachedFromTarget":
|
|
544
|
+
return params.get("sessionId") in connection.sessions
|
|
545
|
+
heard, let_go = connection.scope.hears(method, params)
|
|
546
|
+
if let_go is not None:
|
|
547
|
+
self._spawn(self._let_go(connection.session, let_go, params.get("waitingForDebugger")))
|
|
548
|
+
return heard
|
|
549
|
+
|
|
550
|
+
async def _let_go(self, owner: str, session: str, waiting: object) -> None:
|
|
551
|
+
"""A target auto-attached to the browser session ``owner`` as ``session`` that its connection doesn't see: told
|
|
552
|
+
to run when it waits for its debugger, so it isn't held, and detached."""
|
|
553
|
+
with contextlib.suppress(ConnectionError, DevToolsError):
|
|
554
|
+
if waiting:
|
|
555
|
+
await self.devtools.call("Runtime.runIfWaitingForDebugger", session_id=session)
|
|
556
|
+
await self.devtools.call("Target.detachFromTarget", {"sessionId": session}, session_id=owner)
|
|
557
|
+
|
|
558
|
+
def _spawn(self, work) -> None:
|
|
559
|
+
task = asyncio.ensure_future(work)
|
|
560
|
+
self._tasks.add(task)
|
|
561
|
+
task.add_done_callback(self._tasks.discard)
|
|
562
|
+
|
|
471
563
|
def _put(self, connection: _Connection, message: dict) -> None:
|
|
472
564
|
"""``message`` waiting to be sent to ``connection``'s client, which is closed instead, with what waited dropped,
|
|
473
565
|
once it has fallen too far behind."""
|
|
@@ -79,6 +79,8 @@ class Contexts:
|
|
|
79
79
|
home: Callable[[], Path] = Path.home) -> None:
|
|
80
80
|
self.devtools, self.control, self.home = devtools, control, home
|
|
81
81
|
self.leases: dict[str, Lease] = {}
|
|
82
|
+
#: What hears of each lease's end, whatever ends it: its release, its disposal or the browser's.
|
|
83
|
+
self.on_end: list[Callable[[Lease], None]] = []
|
|
82
84
|
self._made: dict[str, int] = {}
|
|
83
85
|
self._tasks: set[asyncio.Future] = set()
|
|
84
86
|
self._lock = asyncio.Lock()
|
|
@@ -135,6 +137,7 @@ class Contexts:
|
|
|
135
137
|
if (lease := self.leases.pop(label, None)) is None:
|
|
136
138
|
return False
|
|
137
139
|
self.control.closing_context(lease.id)
|
|
140
|
+
self._ended(lease)
|
|
138
141
|
with contextlib.suppress(DevToolsError):
|
|
139
142
|
await self.devtools.call("Target.disposeBrowserContext", {"browserContextId": lease.id})
|
|
140
143
|
await asyncio.to_thread(shutil.rmtree, lease.folder(self.home()), True)
|
|
@@ -177,6 +180,7 @@ class Contexts:
|
|
|
177
180
|
deleted, so a lease of its label after has a folder of its own."""
|
|
178
181
|
if (lease := self.of(context_id)) is not None:
|
|
179
182
|
self.leases.pop(lease.label, None)
|
|
183
|
+
self._ended(lease)
|
|
180
184
|
folder, gone = lease.folder(self.home()), self.home() / CONTEXTS / f".gone-{lease.id}"
|
|
181
185
|
with contextlib.suppress(OSError):
|
|
182
186
|
folder.rename(gone)
|
|
@@ -202,10 +206,19 @@ class Contexts:
|
|
|
202
206
|
|
|
203
207
|
def ended(self) -> None:
|
|
204
208
|
"""The browser has gone, and every context with it: no lease is left, and their folders are deleted."""
|
|
209
|
+
for lease in list(self.leases.values()):
|
|
210
|
+
self._ended(lease)
|
|
205
211
|
self.leases.clear()
|
|
206
212
|
self._made.clear()
|
|
207
213
|
shutil.rmtree(self.home() / CONTEXTS, ignore_errors=True)
|
|
208
214
|
|
|
215
|
+
def _ended(self, lease: Lease) -> None:
|
|
216
|
+
for hook in self.on_end:
|
|
217
|
+
try:
|
|
218
|
+
hook(lease)
|
|
219
|
+
except Exception as e:
|
|
220
|
+
logger.warning(f"the end of the lease {lease.label!r}: {type(e).__name__}: {e}")
|
|
221
|
+
|
|
209
222
|
def _record(self, lease: Lease) -> Lease:
|
|
210
223
|
self.leases[lease.label] = lease
|
|
211
224
|
self.control.other_contexts[lease.id] = lease.label
|
|
@@ -260,6 +260,12 @@ class BrowserControl:
|
|
|
260
260
|
return [OpenTab(**tab, active=tab["id"] == active, context=self.label_of(tab)).model_dump()
|
|
261
261
|
for tab in self.tabs.values() if self.in_context(tab.get("context_id"), context)]
|
|
262
262
|
|
|
263
|
+
def context_of_frame(self, frame: object) -> Optional[str]:
|
|
264
|
+
"""The context of the tab the frame ``frame`` is in, a tab's own frame among them; None for one it hasn't
|
|
265
|
+
seen."""
|
|
266
|
+
tab = self._frame_tabs.get(frame, frame) if isinstance(frame, str) else None
|
|
267
|
+
return self.tabs.get(tab, {}).get("context_id") if tab is not None else None
|
|
268
|
+
|
|
263
269
|
def label_of(self, entry: dict) -> Optional[str]:
|
|
264
270
|
"""The label of the lease a tab or download was in, None for the default context."""
|
|
265
271
|
return self.other_contexts.get(entry.get("context_id"))
|
|
@@ -937,6 +943,12 @@ class BrowserControl:
|
|
|
937
943
|
load.commits.append(frame["loaderId"])
|
|
938
944
|
load.check()
|
|
939
945
|
|
|
946
|
+
def _on_Page_frameAttached(self, params: dict, session: Optional[str]) -> None:
|
|
947
|
+
"""A frame attached to a page of one of its tabs, kept as that tab's: a cross-origin one goes on in a process
|
|
948
|
+
of its own, whose navigations its tab's page doesn't hear of."""
|
|
949
|
+
if session in self._sessions and isinstance(frame := params.get("frameId"), str):
|
|
950
|
+
self._frame_tabs[frame] = self._sessions[session]
|
|
951
|
+
|
|
940
952
|
def _on_Page_navigatedWithinDocument(self, params: dict, session: Optional[str]) -> None:
|
|
941
953
|
"""A tab's page moving to another URL of its document, a fragment or its history API: a command's, when one
|
|
942
954
|
asked for it, else its page's."""
|