agentenv-framework-protocol 0.1.614__tar.gz → 0.1.615__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.614 → agentenv_framework_protocol-0.1.615}/PKG-INFO +15 -1
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/README.md +14 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/pyproject.toml +1 -1
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/__init__.py +4 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/_atif_copy.py +3 -2
- agentenv_framework_protocol-0.1.615/src/agentenv_protocol/a2a_agent/_media_spool.py +148 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/_secrets.py +4 -2
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/_trajectory_log.py +7 -1
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/extensions.py +51 -1
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/framework.py +18 -7
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/registry.py +3 -1
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/PROFILE.md +4 -1
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/__init__.py +3 -3
- agentenv_framework_protocol-0.1.615/src/agentenv_protocol/atif/_image_size.py +75 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/builder.py +3 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/reader.py +25 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/validator.py +1 -2
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/transfers.py +13 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/__init__.py +2 -1
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/control.py +3 -8
- agentenv_framework_protocol-0.1.615/tests/test_a2a_atif_media.py +409 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/.gitignore +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/LICENSE +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/NOTICE +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/THIRD_PARTY_NOTICES.md +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/advanced_agent.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/basic_agent.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/custom_extensions_agent.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/multimodal_agent.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/reference_model.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/streaming_agent.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/.gitignore +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/Dockerfile +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/Dockerfile.dockerignore +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/README.md +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/data/seed.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/env.toml +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/site.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/web/index.html +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/web/package-lock.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/web/package.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/web/src/main.js +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/web/src/style.css +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/examples/website/notes/web/vite.config.js +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/_snapshot_state.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/_triggers.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/_turn_index.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/clock.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/control_token.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/peer_agents.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/proxy.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/staging.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/tasks/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/a2a_agent/tasks/v1.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/agent_env_environment.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/__main__.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/adapter.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/coding.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/coding.stripped.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/computer_use.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/late_result.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/media/482405b002a62efa8516c36709a7a100637507670576fa73a20ad5420d55c66f.png +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/media/55c64d0fcd6f9d5f7c828093857e3fdfda68478bb4e9bd24d481ef391c7804e8.heic +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/media/67905ad3cc2dd52b1f5f6a6d2814de0396618b29b4238b9af5207aeb69936e6d.mp4 +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/media/69a8aa01fe5537076d023dd5e9cc4275b39fc0434aa6483a9f58b66ef2f3c896.png +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/media/82e60066a2de261b6653bcdda90d1cb9a7af2f474cecd82e8d371e8384d72315.png +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/media/845e91831319e89c4d656bdb80c278ac09a7230d61e5dfd2e1b1fbb436ac8917.pdf +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/multi_agent.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/odd_parts.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/subagent.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/fixtures/two_turns.json +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/kit.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/LICENSE +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/VENDORED.md +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/agent.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/content.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/final_metrics.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/metrics.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/observation.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/observation_result.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/step.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/subagent_trajectory_ref.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/tool_call.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/models/trajectory.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/profile.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/runner.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/atif/served.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/client.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_declare.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_desktop.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_job.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_linux.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_load.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_macos.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_reaping.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_session_posix.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_session_windows.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_windows.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_with_fds.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/_x11.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/annotate.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/app.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/app_data.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/app_runtime.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/apps.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/card.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/checks.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/clock.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/conformance/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/conformance/__main__.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/conformance/checks.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/conformance/client.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/conformance/desk.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/conformance/fixture.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/conformance/mp4.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/conformance/page_fixture.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/conformance/report.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/conformance/wayland_fixture.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/dataplane.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/driver.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/errors.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/extensions.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/frames.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/keys.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/launch.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/manifest.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/operations.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/platform.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/prefix.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/queue.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/recording.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/results.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/run_install_step.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/runtime.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/seed.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/serve.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/serve_app.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/served.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/session.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/settings.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/skill.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/spaces.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/svc.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/computer/tools.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/errors.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/manifest.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/passthrough.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/preflight.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/tool_access.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/tool_client.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/tool_context.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/types.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website/clock.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website/conformance.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website/environment.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website/errors.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website/forwarding.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website/readiness.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website/routes.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website/session.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/cdp.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/contexts.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/data.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/devtools.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/environment.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/log.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/network.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/recording.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/scope.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/shapes.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/src/agentenv_protocol/website_browser/stream.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/atif_cases.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/computer_fake.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/conftest.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/probe_fake.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_agent.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_agent_clock.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_agent_examples.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_atif_scrubbing.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_atif_serving.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_atif_turns.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_cdp_config.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_object_transfers.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_peer_agents.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_proxy.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_staging.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_a2a_trajectory_log.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_agent_env_environment.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_atif_builder.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_atif_fixtures.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_atif_kit.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_atif_profile.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_atif_reader.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_atif_validator.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_atif_vendored.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_browser_cdp.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_browser_contexts.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_browser_data.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_browser_log.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_browser_network.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_browser_recording.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_browser_state.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_client.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_app_data.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_app_server.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_clock.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_conformance.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_conformance_attempts.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_conformance_checks.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_conformance_page.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_conformance_recording.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_dataplane.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_declare.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_driver.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_driver_keys.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_extensions.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_frames.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_macos.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_page.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_queue.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_recording.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_recording_annotate.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_seed.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_serve.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_served.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_session_windows.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_spaces.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_svc_forward.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_tool_prefix.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_computer_windows_driver.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_control_token.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_data_objects.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_devtools_pipe.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_errors.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_extension_methods.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_intake.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_manifest.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_preflight.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_tool_access.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_tool_annotations.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_tool_client.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_tool_context.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_tool_context_fastmcp.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_tool_context_injection.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_usage.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_website_api.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_website_browser.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_website_conformance.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_website_environment.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_website_forwarding.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_website_live.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_website_mcp.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/tests/test_website_notes_example.py +0 -0
- {agentenv_framework_protocol-0.1.614 → agentenv_framework_protocol-0.1.615}/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.615
|
|
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
|
|
@@ -1783,6 +1783,20 @@ first, and a read scrubs as it serves, so a secret learned after a step was
|
|
|
1783
1783
|
written is left out too. Native reads keep every secret byte for byte, so a
|
|
1784
1784
|
replay of the served inputs holds what the served copy redacts.
|
|
1785
1785
|
|
|
1786
|
+
A copy's media files, `media/<sha256>.<ext>` beside the document, wait on the
|
|
1787
|
+
agent's disk as the adapter names them, one file per sha256, with a PNG, JPEG,
|
|
1788
|
+
GIF or WebP image's width and height read from its header. The worker pulls
|
|
1789
|
+
them at each turn's end with the trajectory extension's `media` call, listed on
|
|
1790
|
+
the card of an agent that serves `atif/1`: `{context_id, objects: {path: write
|
|
1791
|
+
grant}}` uploads each file the context holds under its exact-object grant, up
|
|
1792
|
+
to 8 at a time, checking each upload's bytes against its name. It answers what
|
|
1793
|
+
it uploaded, the paths it holds no file for (`missing`) and the uploads that
|
|
1794
|
+
failed (`failed`). Neither stops the rest. A file uploaded leaves the agent's
|
|
1795
|
+
disk, as do a context's files when it is evicted or restored over, and the
|
|
1796
|
+
rest when the server stops. A reader takes a part path only as
|
|
1797
|
+
`media/<sha256>.<ext>` and checks the bytes it reads against that name
|
|
1798
|
+
(`agentenv_protocol.atif.media_file` and `check_media`).
|
|
1799
|
+
|
|
1786
1800
|
`enable(..., description="...")` is reserved for declarations carrying
|
|
1787
1801
|
configuration or metadata. It preserves the agent-specific extension prose
|
|
1788
1802
|
published in the Agent Card. The versioned SDK definition provides a generic
|
|
@@ -1712,6 +1712,20 @@ first, and a read scrubs as it serves, so a secret learned after a step was
|
|
|
1712
1712
|
written is left out too. Native reads keep every secret byte for byte, so a
|
|
1713
1713
|
replay of the served inputs holds what the served copy redacts.
|
|
1714
1714
|
|
|
1715
|
+
A copy's media files, `media/<sha256>.<ext>` beside the document, wait on the
|
|
1716
|
+
agent's disk as the adapter names them, one file per sha256, with a PNG, JPEG,
|
|
1717
|
+
GIF or WebP image's width and height read from its header. The worker pulls
|
|
1718
|
+
them at each turn's end with the trajectory extension's `media` call, listed on
|
|
1719
|
+
the card of an agent that serves `atif/1`: `{context_id, objects: {path: write
|
|
1720
|
+
grant}}` uploads each file the context holds under its exact-object grant, up
|
|
1721
|
+
to 8 at a time, checking each upload's bytes against its name. It answers what
|
|
1722
|
+
it uploaded, the paths it holds no file for (`missing`) and the uploads that
|
|
1723
|
+
failed (`failed`). Neither stops the rest. A file uploaded leaves the agent's
|
|
1724
|
+
disk, as do a context's files when it is evicted or restored over, and the
|
|
1725
|
+
rest when the server stops. A reader takes a part path only as
|
|
1726
|
+
`media/<sha256>.<ext>` and checks the bytes it reads against that name
|
|
1727
|
+
(`agentenv_protocol.atif.media_file` and `check_media`).
|
|
1728
|
+
|
|
1715
1729
|
`enable(..., description="...")` is reserved for declarations carrying
|
|
1716
1730
|
configuration or metadata. It preserves the agent-specific extension prose
|
|
1717
1731
|
published in the Agent Card. The versioned SDK definition provides a generic
|
|
@@ -77,6 +77,8 @@ from .extensions import (
|
|
|
77
77
|
TaskObjectTrajectoryRequest,
|
|
78
78
|
TaskTrajectoryRequest,
|
|
79
79
|
TrajectoryEventsResponse,
|
|
80
|
+
TrajectoryMediaRequest,
|
|
81
|
+
TrajectoryMediaResponse,
|
|
80
82
|
TrajectoryObjectsResponse,
|
|
81
83
|
AtifEventsResponse,
|
|
82
84
|
AtifObjectsResponse,
|
|
@@ -256,6 +258,8 @@ __all__ = [
|
|
|
256
258
|
"AtifObjectsResponse",
|
|
257
259
|
"AtifUploadedObjects",
|
|
258
260
|
"TrajectoryLog",
|
|
261
|
+
"TrajectoryMediaRequest",
|
|
262
|
+
"TrajectoryMediaResponse",
|
|
259
263
|
"TrajectoryObjectsResponse",
|
|
260
264
|
"TrajectoryState",
|
|
261
265
|
"TrajectoryUploadedObjects",
|
|
@@ -68,8 +68,9 @@ class AtifCopy:
|
|
|
68
68
|
serves goes through ``scrub``, the agent's secrets redacted."""
|
|
69
69
|
|
|
70
70
|
def __init__(self, adapter: type[Adapter], context_id: str, *,
|
|
71
|
-
scrub: Callable[[Any], Any] = lambda served: served
|
|
72
|
-
|
|
71
|
+
scrub: Callable[[Any], Any] = lambda served: served,
|
|
72
|
+
media: Callable[[str, bytes], None] | None = None) -> None:
|
|
73
|
+
self._run = AdapterRun(adapter, media=media, trajectory_id=uuid.uuid4().hex)
|
|
73
74
|
self._adapter = adapter.__name__
|
|
74
75
|
self._context_id = context_id
|
|
75
76
|
self._scrub = scrub
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"""The media files of an agent's atif/1 copies, spooled to its disk as the adapter names them: one file per sha256,
|
|
2
|
+
held by the contexts whose copies reference it, until a push uploads it for a context or that context goes. The worker
|
|
3
|
+
pulls them at each turn's end (``TRAJECTORY_V1.media``), so the bytes never wait in memory."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import asyncio
|
|
8
|
+
import itertools
|
|
9
|
+
import logging
|
|
10
|
+
import os
|
|
11
|
+
import shutil
|
|
12
|
+
import tempfile
|
|
13
|
+
import threading
|
|
14
|
+
from collections.abc import Callable, Mapping
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
from ..atif import media_file
|
|
18
|
+
from ..transfers import TransferError, Uploaded, WriteObject, sha256_file, upload
|
|
19
|
+
from .extensions import TrajectoryMediaResponse
|
|
20
|
+
|
|
21
|
+
logger = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
#: How many of a push's files upload at once.
|
|
24
|
+
MAX_PARALLEL_MEDIA_PUSHES = 8
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class MediaSpool:
|
|
28
|
+
"""Each context's media files on disk. Safe to fill from the agent's thread while the loop pushes them; the folder
|
|
29
|
+
is made on the first file and removed by ``close``. Each hold has its own number, so an upload that outlives its
|
|
30
|
+
context's copy (a restore, an eviction) releases only the hold it began with, never a later copy's. A file that
|
|
31
|
+
can't be written, on a full disk say, is left out: a push reports it missing, and the copy goes on."""
|
|
32
|
+
|
|
33
|
+
def __init__(self) -> None:
|
|
34
|
+
self._lock = threading.Lock()
|
|
35
|
+
self._folder: Path | None = None
|
|
36
|
+
#: Each context's held paths, ``media/<sha256>.<ext>``, each with its hold's number.
|
|
37
|
+
self._held: dict[str, dict[str, int]] = {}
|
|
38
|
+
self._holds = itertools.count(1)
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def folder(self) -> Path | None:
|
|
42
|
+
"""Where the files are, once the first one is written."""
|
|
43
|
+
return self._folder
|
|
44
|
+
|
|
45
|
+
def sink(self, context_id: str) -> Callable[[str, bytes], None]:
|
|
46
|
+
"""Where a context's copy writes each media file once, as its builder names it."""
|
|
47
|
+
|
|
48
|
+
def write(path: str, data: bytes) -> None:
|
|
49
|
+
with self._lock:
|
|
50
|
+
try:
|
|
51
|
+
file = self._file(path)
|
|
52
|
+
if not file.exists():
|
|
53
|
+
part = file.with_name(f"{file.name}.{os.getpid()}.part")
|
|
54
|
+
try:
|
|
55
|
+
part.write_bytes(data)
|
|
56
|
+
os.replace(part, file)
|
|
57
|
+
finally:
|
|
58
|
+
part.unlink(missing_ok=True)
|
|
59
|
+
except OSError as exc:
|
|
60
|
+
logger.warning("the atif/1 copy of context %s keeps no file for %s, which a push reports "
|
|
61
|
+
"missing: %s", context_id, path, exc)
|
|
62
|
+
return
|
|
63
|
+
self._held.setdefault(context_id, {}).setdefault(path, next(self._holds))
|
|
64
|
+
|
|
65
|
+
return write
|
|
66
|
+
|
|
67
|
+
def held(self, context_id: str, path: str) -> Path | None:
|
|
68
|
+
"""The file a context holds at ``path``, or None when it holds none there."""
|
|
69
|
+
hold = self._hold(context_id, path)
|
|
70
|
+
return None if hold is None else hold[0]
|
|
71
|
+
|
|
72
|
+
async def push(self, context_id: str, objects: Mapping[str, WriteObject]) -> TrajectoryMediaResponse:
|
|
73
|
+
"""Upload the files a context holds at ``objects``' paths, each under its grant, ``MAX_PARALLEL_MEDIA_PUSHES``
|
|
74
|
+
at a time. Each file's sha256 is checked against its name before its bytes leave, and the upload's after; a file
|
|
75
|
+
uploaded is the context's no longer. A path the context holds no file for is ``missing``, an upload that fails
|
|
76
|
+
is ``failed``, and neither stops the rest."""
|
|
77
|
+
uploaded: dict[str, Uploaded] = {}
|
|
78
|
+
missing: list[str] = []
|
|
79
|
+
failed: dict[str, str] = {}
|
|
80
|
+
gate = asyncio.Semaphore(MAX_PARALLEL_MEDIA_PUSHES)
|
|
81
|
+
|
|
82
|
+
async def push_one(path: str, target: WriteObject) -> None:
|
|
83
|
+
held = self._hold(context_id, path)
|
|
84
|
+
if held is None:
|
|
85
|
+
missing.append(path)
|
|
86
|
+
return
|
|
87
|
+
file, hold = held
|
|
88
|
+
async with gate:
|
|
89
|
+
try:
|
|
90
|
+
digest = await asyncio.to_thread(sha256_file, file)
|
|
91
|
+
except OSError as exc:
|
|
92
|
+
failed[path] = f"the spooled file can't be read: {exc.strerror}"
|
|
93
|
+
return
|
|
94
|
+
if digest != media_file(path):
|
|
95
|
+
failed[path] = f"the spooled file's sha256 is {digest}"
|
|
96
|
+
return
|
|
97
|
+
try:
|
|
98
|
+
done = await upload(target, file)
|
|
99
|
+
except TransferError as exc:
|
|
100
|
+
failed[path] = f"{exc.code}: {exc}"
|
|
101
|
+
return
|
|
102
|
+
if done.sha256 is not None and done.sha256 != digest:
|
|
103
|
+
failed[path] = f"the upload's sha256 is {done.sha256}"
|
|
104
|
+
return
|
|
105
|
+
uploaded[path] = done
|
|
106
|
+
self._release(context_id, path, hold)
|
|
107
|
+
|
|
108
|
+
await asyncio.gather(*(push_one(path, target) for path, target in objects.items()))
|
|
109
|
+
return TrajectoryMediaResponse(objects=uploaded, missing=sorted(missing), failed=failed)
|
|
110
|
+
|
|
111
|
+
def drop(self, context_id: str) -> None:
|
|
112
|
+
"""The context is gone, evicted or restored over: its files go, but those another context still holds."""
|
|
113
|
+
with self._lock:
|
|
114
|
+
for path in self._held.pop(context_id, {}):
|
|
115
|
+
self._remove_unheld(path)
|
|
116
|
+
|
|
117
|
+
def close(self) -> None:
|
|
118
|
+
with self._lock:
|
|
119
|
+
if self._folder is not None:
|
|
120
|
+
shutil.rmtree(self._folder, ignore_errors=True)
|
|
121
|
+
self._folder = None
|
|
122
|
+
self._held.clear()
|
|
123
|
+
|
|
124
|
+
def _hold(self, context_id: str, path: str) -> tuple[Path, int] | None:
|
|
125
|
+
with self._lock:
|
|
126
|
+
hold = self._held.get(context_id, {}).get(path)
|
|
127
|
+
return None if hold is None else (self._file(path), hold)
|
|
128
|
+
|
|
129
|
+
def _release(self, context_id: str, path: str, hold: int) -> None:
|
|
130
|
+
"""Hold ``hold`` on ``path`` is the context's no longer. A later hold stays, and the file goes once no context
|
|
131
|
+
holds it."""
|
|
132
|
+
with self._lock:
|
|
133
|
+
held = self._held.get(context_id)
|
|
134
|
+
if held is None or held.get(path) != hold:
|
|
135
|
+
return
|
|
136
|
+
del held[path]
|
|
137
|
+
if not held:
|
|
138
|
+
del self._held[context_id]
|
|
139
|
+
self._remove_unheld(path)
|
|
140
|
+
|
|
141
|
+
def _file(self, path: str) -> Path:
|
|
142
|
+
if self._folder is None:
|
|
143
|
+
self._folder = Path(tempfile.mkdtemp(prefix="agentenv-atif-media-"))
|
|
144
|
+
return self._folder / path.removeprefix("media/")
|
|
145
|
+
|
|
146
|
+
def _remove_unheld(self, path: str) -> None:
|
|
147
|
+
if self._folder is not None and not any(path in held for held in self._held.values()):
|
|
148
|
+
(self._folder / path.removeprefix("media/")).unlink(missing_ok=True)
|
|
@@ -16,6 +16,7 @@ from urllib.parse import quote, unquote_plus, urlsplit
|
|
|
16
16
|
|
|
17
17
|
from pydantic import BaseModel, SecretStr
|
|
18
18
|
|
|
19
|
+
from ..atif.reader import MEDIA_NAME
|
|
19
20
|
from ..transfers import HttpGetGrant, HttpPostPolicyGrant, HttpPutGrant
|
|
20
21
|
from .extensions import CdpAddRequest, ClockSyncTimeRequest, McpAddRequest
|
|
21
22
|
from .tasks.v1 import AgentConfig
|
|
@@ -239,13 +240,14 @@ def _grant_secrets(grant: HttpGetGrant | HttpPutGrant | HttpPostPolicyGrant) ->
|
|
|
239
240
|
def _url_secrets(url: str) -> list[str]:
|
|
240
241
|
"""The parts of a URL that carry its credential: a presigned URL's credential-like query values, else its token-like
|
|
241
242
|
path segments, as a grant server's (``/v1/grants/<token>``, with or without a plain query such as ``?download=1``),
|
|
242
|
-
and its password. Every copy of the URL, whole or as a request line, holds them, so redacting them is enough; the
|
|
243
|
+
but a media file's name, which the copies that hold the file keep, and its password. Every copy of the URL, whole or as a request line, holds them, so redacting them is enough; the
|
|
243
244
|
rest (its host, its path, ``X-Amz-Algorithm``) isn't secret, and leaving it keeps each grant's share of the match
|
|
244
245
|
to its signature: the session token and access key a role signs every grant with are each one secret."""
|
|
245
246
|
parts = urlsplit(url)
|
|
246
247
|
carried = _query_values(url)
|
|
247
248
|
if not carried:
|
|
248
|
-
carried = [segment for segment in parts.path.split("/")
|
|
249
|
+
carried = [segment for segment in parts.path.split("/")
|
|
250
|
+
if _TOKEN_SEGMENT.fullmatch(segment) and not MEDIA_NAME.fullmatch(segment)]
|
|
249
251
|
return [*carried, *([parts.password] if parts.password else [])]
|
|
250
252
|
|
|
251
253
|
|
|
@@ -10,6 +10,7 @@ from typing import Any, Callable, Sequence
|
|
|
10
10
|
|
|
11
11
|
from ..atif import Adapter
|
|
12
12
|
from ._atif_copy import AtifCopy, AtifPage, TurnStart
|
|
13
|
+
from ._media_spool import MediaSpool
|
|
13
14
|
from ._turn_index import TurnIndex
|
|
14
15
|
from .extensions import TrajectoryState
|
|
15
16
|
from .tasks.v1 import TaskError, TrajectoryLog
|
|
@@ -98,6 +99,8 @@ class TaskTrajectories:
|
|
|
98
99
|
self._turns = TurnIndex() if atif is not None else None
|
|
99
100
|
#: What every atif/1 read goes through: the agent's secrets redacted.
|
|
100
101
|
self._scrub = scrub
|
|
102
|
+
#: The copies' media files, on disk until the worker pulls them.
|
|
103
|
+
self.media = MediaSpool()
|
|
101
104
|
self._tasks: dict[str, _TaskRecord] = {}
|
|
102
105
|
self._contexts: OrderedDict[str, list[str]] = OrderedDict()
|
|
103
106
|
self._copies: dict[str, AtifCopy] = {}
|
|
@@ -133,7 +136,8 @@ class TaskTrajectories:
|
|
|
133
136
|
copy = self._copies.get(record.context_id)
|
|
134
137
|
if copy is None:
|
|
135
138
|
copy = self._copies[record.context_id] = AtifCopy(
|
|
136
|
-
self._atif, record.context_id,
|
|
139
|
+
self._atif, record.context_id, media=self.media.sink(record.context_id),
|
|
140
|
+
**({"scrub": self._scrub} if self._scrub is not None else {}),
|
|
137
141
|
)
|
|
138
142
|
copy.start(task_id, self._turns.next(record.context_id), turn)
|
|
139
143
|
record.log._atif = _CopySink(copy, task_id)
|
|
@@ -149,6 +153,7 @@ class TaskTrajectories:
|
|
|
149
153
|
new document, since the conversation is the snapshot's now; an agent that serves atif/1 only."""
|
|
150
154
|
self._turns.set(context_id, turns)
|
|
151
155
|
self._copies.pop(context_id, None)
|
|
156
|
+
self.media.drop(context_id)
|
|
152
157
|
|
|
153
158
|
def request_cancel(self, task_id: str) -> None:
|
|
154
159
|
"""Make ``canceled`` the outcome the task is sealed with, whatever ``run`` returns."""
|
|
@@ -357,6 +362,7 @@ class TaskTrajectories:
|
|
|
357
362
|
continue
|
|
358
363
|
del self._contexts[context_id]
|
|
359
364
|
self._copies.pop(context_id, None)
|
|
365
|
+
self.media.drop(context_id)
|
|
360
366
|
for task_id in task_ids:
|
|
361
367
|
del self._tasks[task_id]
|
|
362
368
|
|
|
@@ -25,7 +25,7 @@ from pydantic import (
|
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
from ..atif import FORMAT as ATIF_FORMAT
|
|
28
|
-
from ..atif import Adapter, AdapterSpec
|
|
28
|
+
from ..atif import Adapter, AdapterSpec, media_file
|
|
29
29
|
from ._triggers import MAX_SOLVER_MESSAGE_LENGTH
|
|
30
30
|
from .tasks.v1 import AgentConfig
|
|
31
31
|
from ..transfers import (
|
|
@@ -205,6 +205,34 @@ class TrajectoryObjectsResponse(ExtensionResponse):
|
|
|
205
205
|
format: str | None = None
|
|
206
206
|
|
|
207
207
|
|
|
208
|
+
#: The most media files one media call may name: a turn of a computer-use run holds a few hundred screenshots.
|
|
209
|
+
MAX_MEDIA_OBJECTS = 10_000
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class TrajectoryMediaRequest(ExtensionRequest):
|
|
213
|
+
"""The media files of a context's atif/1 copy the caller wants, by their paths in it (``media/<sha256>.<ext>``),
|
|
214
|
+
each under its own exact-object write grant."""
|
|
215
|
+
|
|
216
|
+
context_id: str = Field(min_length=1)
|
|
217
|
+
objects: dict[str, WriteObject] = Field(min_length=1, max_length=MAX_MEDIA_OBJECTS)
|
|
218
|
+
|
|
219
|
+
@field_validator("objects")
|
|
220
|
+
@classmethod
|
|
221
|
+
def _media_paths(cls, objects: dict[str, WriteObject]) -> dict[str, WriteObject]:
|
|
222
|
+
for path in objects:
|
|
223
|
+
media_file(path)
|
|
224
|
+
return objects
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class TrajectoryMediaResponse(ExtensionResponse):
|
|
228
|
+
"""What a media call uploaded, by path; the paths the context holds no file for; and the uploads that failed, with
|
|
229
|
+
why. Neither of the last two stops the rest."""
|
|
230
|
+
|
|
231
|
+
objects: dict[str, Uploaded]
|
|
232
|
+
missing: list[str] = Field(default_factory=list)
|
|
233
|
+
failed: dict[str, str] = Field(default_factory=dict)
|
|
234
|
+
|
|
235
|
+
|
|
208
236
|
class AtifUploadedObjects(ExtensionResponse):
|
|
209
237
|
trajectory: Uploaded
|
|
210
238
|
aux: Uploaded | None = None
|
|
@@ -816,6 +844,9 @@ class OperationDefinition:
|
|
|
816
844
|
implementation: ImplementationOwner
|
|
817
845
|
request: RequestDefinition | type[BaseModel] | None = None
|
|
818
846
|
response: FieldSchema | type[BaseModel] | None = None
|
|
847
|
+
#: Served by the SDK alone, from state only it holds: no agent overrides it, and an agent that overrides the
|
|
848
|
+
#: extension's other SDK operations needn't override it with them.
|
|
849
|
+
sdk_only: bool = False
|
|
819
850
|
response_model: type[BaseModel] | None = field(default=None, init=False)
|
|
820
851
|
|
|
821
852
|
def __post_init__(self) -> None:
|
|
@@ -1104,6 +1135,7 @@ def _op(
|
|
|
1104
1135
|
response_required: Iterable[str] = (),
|
|
1105
1136
|
response_optional: Iterable[str] = (),
|
|
1106
1137
|
variants: Iterable[RequestVariant] = (),
|
|
1138
|
+
sdk_only: bool = False,
|
|
1107
1139
|
) -> OperationDefinition:
|
|
1108
1140
|
response_required = _tuple(response_required)
|
|
1109
1141
|
response_optional = _tuple(response_optional)
|
|
@@ -1123,6 +1155,7 @@ def _op(
|
|
|
1123
1155
|
implementation=owner,
|
|
1124
1156
|
request=request,
|
|
1125
1157
|
response=response,
|
|
1158
|
+
sdk_only=sdk_only,
|
|
1126
1159
|
)
|
|
1127
1160
|
|
|
1128
1161
|
|
|
@@ -1194,6 +1227,8 @@ def _configure_trajectory(
|
|
|
1194
1227
|
return ExtensionConfiguration(
|
|
1195
1228
|
wire_params={"formats": formats, "native": native, "default": native} if native else {},
|
|
1196
1229
|
options={"native": native, **({"atif": atif} if atif is not None else {})} if native else {},
|
|
1230
|
+
# An agent that serves atif/1 hands over its copies' media files, which the worker pulls at each turn's end.
|
|
1231
|
+
features={"media"} if atif is not None else frozenset(),
|
|
1197
1232
|
variants=(
|
|
1198
1233
|
{"get": {"task_events", "context_events", "context", "context_objects"}} if live else {}
|
|
1199
1234
|
),
|
|
@@ -1341,6 +1376,21 @@ TRAJECTORY_V1 = ExtensionDefinition(
|
|
|
1341
1376
|
),
|
|
1342
1377
|
)
|
|
1343
1378
|
},
|
|
1379
|
+
optional_features={
|
|
1380
|
+
"media": OperationGroup(
|
|
1381
|
+
operations={
|
|
1382
|
+
"media": _op(
|
|
1383
|
+
"media",
|
|
1384
|
+
"POST",
|
|
1385
|
+
"/ext/trajectory/media",
|
|
1386
|
+
SDK,
|
|
1387
|
+
request_model=TrajectoryMediaRequest,
|
|
1388
|
+
response_model=TrajectoryMediaResponse,
|
|
1389
|
+
sdk_only=True,
|
|
1390
|
+
),
|
|
1391
|
+
}
|
|
1392
|
+
)
|
|
1393
|
+
},
|
|
1344
1394
|
configuration_validator=_configure_trajectory,
|
|
1345
1395
|
)
|
|
1346
1396
|
|
|
@@ -68,6 +68,7 @@ from .extensions import (
|
|
|
68
68
|
AtifObjectsResponse,
|
|
69
69
|
AtifUploadedObjects,
|
|
70
70
|
TrajectoryEventsResponse,
|
|
71
|
+
TrajectoryMediaRequest,
|
|
71
72
|
TrajectoryObjectsResponse,
|
|
72
73
|
TrajectoryState,
|
|
73
74
|
TrajectoryUploadedObjects,
|
|
@@ -682,6 +683,7 @@ class _SdkServices:
|
|
|
682
683
|
(PEER_AGENTS_V1.uri, "list"): self.peer_agents_list,
|
|
683
684
|
(SKILL_CONFIG_V1.uri, "list"): self.skill_list,
|
|
684
685
|
(TRAJECTORY_V1.uri, "get"): self.trajectory_get,
|
|
686
|
+
(TRAJECTORY_V1.uri, "media"): self.trajectory_media,
|
|
685
687
|
(TRIGGERS_V1.uri, "register"): self.triggers_register,
|
|
686
688
|
(TRIGGERS_V1.uri, "decide"): self.triggers_decide,
|
|
687
689
|
(TRIGGERS_V1.uri, "state"): self.triggers_state,
|
|
@@ -964,6 +966,11 @@ class _SdkServices:
|
|
|
964
966
|
)
|
|
965
967
|
return AtifObjectsResponse(objects=uploaded, **versions).model_dump(mode="json", exclude_none=True)
|
|
966
968
|
|
|
969
|
+
async def trajectory_media(self, request: TrajectoryMediaRequest) -> dict[str, Any]:
|
|
970
|
+
"""Upload the media files of a context's atif/1 copy the worker asks for, from the spool (``MediaSpool.push``)."""
|
|
971
|
+
pushed = await self.task_trajectories.media.push(request.context_id, request.objects)
|
|
972
|
+
return pushed.model_dump(mode="json", exclude_none=True)
|
|
973
|
+
|
|
967
974
|
def check_trajectory_format(self, format: str | None) -> None:
|
|
968
975
|
"""Refuse a trajectory read naming a format the card doesn't offer, before any handler
|
|
969
976
|
runs, the agent's own included."""
|
|
@@ -1128,7 +1135,8 @@ def _taking_the_control_token(
|
|
|
1128
1135
|
inner: Callable[[Starlette], AbstractAsyncContextManager] | None,
|
|
1129
1136
|
) -> Callable[[Starlette], AbstractAsyncContextManager]:
|
|
1130
1137
|
"""The application's lifespan, ``inner``'s if it has one: serving starts by taking the agent's control token out of
|
|
1131
|
-
the environment, and the extension routes take it from then on
|
|
1138
|
+
the environment, and the extension routes take it from then on, and ends by removing the media spool. An
|
|
1139
|
+
application that isn't served stays open."""
|
|
1132
1140
|
|
|
1133
1141
|
@asynccontextmanager
|
|
1134
1142
|
async def lifespan(app: Starlette) -> AsyncIterator[Any]:
|
|
@@ -1136,11 +1144,14 @@ def _taking_the_control_token(
|
|
|
1136
1144
|
log_guard(application.control_token)
|
|
1137
1145
|
if application.services.secrets is not None:
|
|
1138
1146
|
application.services.secrets.add(application.control_token, source="the control token")
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1147
|
+
try:
|
|
1148
|
+
if inner is None:
|
|
1149
|
+
yield None
|
|
1150
|
+
else:
|
|
1151
|
+
async with inner(app) as state:
|
|
1152
|
+
yield state
|
|
1153
|
+
finally:
|
|
1154
|
+
application.services.task_trajectories.media.close()
|
|
1144
1155
|
|
|
1145
1156
|
return lifespan
|
|
1146
1157
|
|
|
@@ -1354,7 +1365,7 @@ class A2AAgentApplication:
|
|
|
1354
1365
|
extension_request = request_model.model_validate(payload)
|
|
1355
1366
|
if self.services.secrets is not None:
|
|
1356
1367
|
self.services.secrets.add_request(extension_request)
|
|
1357
|
-
if extension_uri == TRAJECTORY_V1.uri:
|
|
1368
|
+
if extension_uri == TRAJECTORY_V1.uri and operation.definition.name == "get":
|
|
1358
1369
|
self.services.check_trajectory_format(extension_request.format)
|
|
1359
1370
|
if extension_request.format == ATIF_FORMAT:
|
|
1360
1371
|
# The SDK serves atif/1 from its own copy, context reads an agent binds included.
|
|
@@ -304,6 +304,8 @@ def build_registry(
|
|
|
304
304
|
variant_handlers[key] = handler
|
|
305
305
|
continue
|
|
306
306
|
|
|
307
|
+
if operation.sdk_only:
|
|
308
|
+
raise ValueError(f"{uri}.{operation.name} is served by the SDK alone; an agent can't override it")
|
|
307
309
|
key = (uri, binding.operation)
|
|
308
310
|
if key in operation_handlers:
|
|
309
311
|
raise ValueError(f"multiple handlers for {uri}.{operation.name}")
|
|
@@ -424,7 +426,7 @@ def build_registry(
|
|
|
424
426
|
active_sdk_operations = {
|
|
425
427
|
name
|
|
426
428
|
for name, operation in resolved_operations.items()
|
|
427
|
-
if operation.definition.implementation is ImplementationOwner.SDK
|
|
429
|
+
if operation.definition.implementation is ImplementationOwner.SDK and not operation.definition.sdk_only
|
|
428
430
|
}
|
|
429
431
|
overridden_sdk_operations = {
|
|
430
432
|
name
|
|
@@ -108,7 +108,10 @@ One vocabulary, in three places:
|
|
|
108
108
|
`[video: media/<sha256>.mp4, 4.4 MB, 31 s]`. That covers video, documents, images other than JPEG, PNG, GIF and WebP
|
|
109
109
|
(such as HEIC or SVG), audio outside ATIF's eight types, and other files.
|
|
110
110
|
- Each file's details go in the `media` map of the profile of the object that holds the part (Step for a message,
|
|
111
|
-
ObservationResult for a result), keyed by its path.
|
|
111
|
+
ObservationResult for a result), keyed by its path. A PNG, JPEG, GIF or WebP image's `width` and `height` are read
|
|
112
|
+
from its header when the producer gives none.
|
|
113
|
+
- A reader takes a part path only as `media/<sha256>.<ext>` in the document's own folder, never another path or a URL,
|
|
114
|
+
and checks each file's bytes against its name (`media_file`, `check_media`).
|
|
112
115
|
|
|
113
116
|
## Fields
|
|
114
117
|
|
|
@@ -46,16 +46,16 @@ from .profile import (
|
|
|
46
46
|
read_profile,
|
|
47
47
|
)
|
|
48
48
|
from .kit import KIT_RULES, KitResult, check_adapter
|
|
49
|
-
from .reader import Task, check, is_prefix, load, media_paths, strip_profile, tasks
|
|
49
|
+
from .reader import MEDIA_PATH, Task, check, check_media, is_prefix, load, media_file, media_paths, strip_profile, tasks
|
|
50
50
|
from .runner import AdapterRun, Fed, RecordedTask, replay
|
|
51
51
|
from .served import AuxEntry, ContentItem, MediaItem, ServedData, ServedError, ServedMedia, ServedTurn
|
|
52
52
|
from .validator import RULES, Finding, Rule, errors_in, validate, validate_live
|
|
53
53
|
|
|
54
54
|
__all__ = [
|
|
55
55
|
"Adapter", "AdapterRef", "AdapterRun", "AdapterSpec", "Agent", "AgentProfile", "Arrival", "atif_adapter",
|
|
56
|
-
"AtifError", "AtifTurn", "AudioSource", "aux", "AuxEntry", "check", "check_adapter", "ContentItem", "ContentPart",
|
|
56
|
+
"AtifError", "AtifTurn", "AudioSource", "aux", "AuxEntry", "check", "check_adapter", "check_media", "ContentItem", "ContentPart",
|
|
57
57
|
"Document", "dump_profile", "errors_in", "Fed", "FinalMetrics", "FinalMetricsProfile", "Finding", "finish",
|
|
58
|
-
"FORMAT", "ImageSource", "is_prefix", "KIT_RULES", "KitResult", "load", "Media", "media_paths", "MediaInfo",
|
|
58
|
+
"FORMAT", "ImageSource", "is_prefix", "KIT_RULES", "KitResult", "load", "Media", "MEDIA_PATH", "media_file", "media_paths", "MediaInfo",
|
|
59
59
|
"MediaItem", "Metrics", "MetricsProfile", "Native", "native", "Observation", "ObservationResult",
|
|
60
60
|
"ObservationResultProfile", "PROFILE_KEY", "profile_of", "PROFILE_VERSION", "PROFILES", "RAW_ARGUMENTS",
|
|
61
61
|
"read_profile", "ReasoningBlock", "RecordedTask", "replay", "Rule", "RULES", "SCHEMA_VERSION", "Selector",
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""An image's width and height, read from its header for the four image types ATIF has parts for, so the profile can
|
|
2
|
+
carry them without Pillow. A header this can't read gives None: the image is stored all the same."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import struct
|
|
7
|
+
|
|
8
|
+
_PNG = b"\x89PNG\r\n\x1a\n"
|
|
9
|
+
#: JPEG's start-of-frame markers, the segments that hold the frame's size: every SOFn but DHT, JPG and DAC.
|
|
10
|
+
_JPEG_FRAMES = frozenset({0xC0, 0xC1, 0xC2, 0xC3, 0xC5, 0xC6, 0xC7, 0xC9, 0xCA, 0xCB, 0xCD, 0xCE, 0xCF})
|
|
11
|
+
#: JPEG markers that stand alone, with no length after them.
|
|
12
|
+
_JPEG_BARE = frozenset({0x01, *range(0xD0, 0xD9)})
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def image_size(data: bytes, media_type: str) -> tuple[int, int] | None:
|
|
16
|
+
"""``(width, height)`` of a PNG, JPEG, GIF or WebP image from its header, or None."""
|
|
17
|
+
read = {"image/png": _png, "image/jpeg": _jpeg, "image/gif": _gif, "image/webp": _webp}.get(media_type)
|
|
18
|
+
try:
|
|
19
|
+
size = read(data) if read is not None else None
|
|
20
|
+
except (IndexError, struct.error):
|
|
21
|
+
return None
|
|
22
|
+
return size if size is not None and size[0] > 0 and size[1] > 0 else None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _png(data: bytes) -> tuple[int, int] | None:
|
|
26
|
+
if data[:8] != _PNG or data[12:16] != b"IHDR":
|
|
27
|
+
return None
|
|
28
|
+
return struct.unpack(">II", data[16:24])
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _gif(data: bytes) -> tuple[int, int] | None:
|
|
32
|
+
if data[:6] not in (b"GIF87a", b"GIF89a"):
|
|
33
|
+
return None
|
|
34
|
+
return struct.unpack("<HH", data[6:10])
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _jpeg(data: bytes) -> tuple[int, int] | None:
|
|
38
|
+
if data[:2] != b"\xff\xd8":
|
|
39
|
+
return None
|
|
40
|
+
at = 2
|
|
41
|
+
while at + 4 <= len(data):
|
|
42
|
+
if data[at] != 0xFF:
|
|
43
|
+
return None
|
|
44
|
+
marker = data[at + 1]
|
|
45
|
+
if marker == 0xFF:
|
|
46
|
+
at += 1
|
|
47
|
+
continue
|
|
48
|
+
if marker in _JPEG_BARE:
|
|
49
|
+
at += 2
|
|
50
|
+
continue
|
|
51
|
+
(length,) = struct.unpack(">H", data[at + 2:at + 4])
|
|
52
|
+
if marker in _JPEG_FRAMES:
|
|
53
|
+
height, width = struct.unpack(">HH", data[at + 5:at + 9])
|
|
54
|
+
return width, height
|
|
55
|
+
if marker == 0xDA:
|
|
56
|
+
return None
|
|
57
|
+
at += 2 + length
|
|
58
|
+
return None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _webp(data: bytes) -> tuple[int, int] | None:
|
|
62
|
+
if data[:4] != b"RIFF" or data[8:12] != b"WEBP":
|
|
63
|
+
return None
|
|
64
|
+
chunk = data[12:16]
|
|
65
|
+
if len(data) < 30:
|
|
66
|
+
return None
|
|
67
|
+
if chunk == b"VP8 " and data[23:26] == b"\x9d\x01\x2a":
|
|
68
|
+
width, height = struct.unpack("<HH", data[26:30])
|
|
69
|
+
return width & 0x3FFF, height & 0x3FFF
|
|
70
|
+
if chunk == b"VP8L" and data[20] == 0x2F:
|
|
71
|
+
(bits,) = struct.unpack("<I", data[21:25])
|
|
72
|
+
return (bits & 0x3FFF) + 1, ((bits >> 14) & 0x3FFF) + 1
|
|
73
|
+
if chunk == b"VP8X":
|
|
74
|
+
return int.from_bytes(data[24:27], "little") + 1, int.from_bytes(data[27:30], "little") + 1
|
|
75
|
+
return None
|
|
@@ -16,6 +16,7 @@ from typing import Any, Callable, Iterable, Mapping, Sequence, get_args
|
|
|
16
16
|
|
|
17
17
|
from pydantic import ValidationError
|
|
18
18
|
|
|
19
|
+
from ._image_size import image_size
|
|
19
20
|
from .adapter import AdapterSpec
|
|
20
21
|
from .models.content import AudioMediaType, ContentPart, ImageSource
|
|
21
22
|
from .profile import (
|
|
@@ -418,6 +419,8 @@ class Document:
|
|
|
418
419
|
for key in ("width", "height", "duration_ms", "pages"):
|
|
419
420
|
_int(info.get(key), key)
|
|
420
421
|
_str(info.get("name"), "a media file's name")
|
|
422
|
+
if info.get("width") is None and info.get("height") is None and (size := image_size(bytes(data), media_type)):
|
|
423
|
+
info = {**info, "width": size[0], "height": size[1]}
|
|
421
424
|
digest = hashlib.sha256(data).hexdigest()
|
|
422
425
|
extension = _EXTENSIONS.get(media_type) or mimetypes.guess_extension(media_type, strict=False) or ".bin"
|
|
423
426
|
path = f"media/{digest}{extension}"
|