agentenv-framework-protocol 0.1.611__tar.gz → 0.1.614__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/PKG-INFO +18 -2
  2. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/README.md +17 -1
  3. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/pyproject.toml +1 -1
  4. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/agent_env_environment.py +24 -0
  5. agentenv_framework_protocol-0.1.614/src/agentenv_protocol/computer/annotate.py +551 -0
  6. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/conformance/checks.py +143 -24
  7. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/driver.py +23 -4
  8. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/extensions.py +6 -4
  9. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/manifest.py +2 -0
  10. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/recording.py +35 -9
  11. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/runtime.py +28 -2
  12. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/computer_fake.py +59 -0
  13. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/probe_fake.py +15 -1
  14. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_page.py +1 -58
  15. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_recording.py +2 -1
  16. agentenv_framework_protocol-0.1.614/tests/test_computer_recording_annotate.py +496 -0
  17. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/.gitignore +0 -0
  18. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/LICENSE +0 -0
  19. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/NOTICE +0 -0
  20. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/THIRD_PARTY_NOTICES.md +0 -0
  21. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/__init__.py +0 -0
  22. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/advanced_agent.py +0 -0
  23. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/basic_agent.py +0 -0
  24. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/custom_extensions_agent.py +0 -0
  25. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/multimodal_agent.py +0 -0
  26. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/reference_model.py +0 -0
  27. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/streaming_agent.py +0 -0
  28. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/.gitignore +0 -0
  29. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/Dockerfile +0 -0
  30. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/Dockerfile.dockerignore +0 -0
  31. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/README.md +0 -0
  32. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/data/seed.json +0 -0
  33. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/env.toml +0 -0
  34. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/site.py +0 -0
  35. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/web/index.html +0 -0
  36. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/web/package-lock.json +0 -0
  37. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/web/package.json +0 -0
  38. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/web/src/main.js +0 -0
  39. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/web/src/style.css +0 -0
  40. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/examples/website/notes/web/vite.config.js +0 -0
  41. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/__init__.py +0 -0
  42. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/__init__.py +0 -0
  43. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/_atif_copy.py +0 -0
  44. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/_secrets.py +0 -0
  45. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/_snapshot_state.py +0 -0
  46. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/_trajectory_log.py +0 -0
  47. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/_triggers.py +0 -0
  48. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/_turn_index.py +0 -0
  49. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/clock.py +0 -0
  50. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/control_token.py +0 -0
  51. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/extensions.py +0 -0
  52. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/framework.py +0 -0
  53. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/peer_agents.py +0 -0
  54. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/proxy.py +0 -0
  55. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/registry.py +0 -0
  56. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/staging.py +0 -0
  57. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/tasks/__init__.py +0 -0
  58. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/a2a_agent/tasks/v1.py +0 -0
  59. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/PROFILE.md +0 -0
  60. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/__init__.py +0 -0
  61. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/__main__.py +0 -0
  62. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/adapter.py +0 -0
  63. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/builder.py +0 -0
  64. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/coding.json +0 -0
  65. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/coding.stripped.json +0 -0
  66. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/computer_use.json +0 -0
  67. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/late_result.json +0 -0
  68. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/media/482405b002a62efa8516c36709a7a100637507670576fa73a20ad5420d55c66f.png +0 -0
  69. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/media/55c64d0fcd6f9d5f7c828093857e3fdfda68478bb4e9bd24d481ef391c7804e8.heic +0 -0
  70. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/media/67905ad3cc2dd52b1f5f6a6d2814de0396618b29b4238b9af5207aeb69936e6d.mp4 +0 -0
  71. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/media/69a8aa01fe5537076d023dd5e9cc4275b39fc0434aa6483a9f58b66ef2f3c896.png +0 -0
  72. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/media/82e60066a2de261b6653bcdda90d1cb9a7af2f474cecd82e8d371e8384d72315.png +0 -0
  73. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/media/845e91831319e89c4d656bdb80c278ac09a7230d61e5dfd2e1b1fbb436ac8917.pdf +0 -0
  74. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/multi_agent.json +0 -0
  75. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/odd_parts.json +0 -0
  76. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/subagent.json +0 -0
  77. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/fixtures/two_turns.json +0 -0
  78. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/kit.py +0 -0
  79. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/LICENSE +0 -0
  80. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/VENDORED.md +0 -0
  81. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/__init__.py +0 -0
  82. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/agent.py +0 -0
  83. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/content.py +0 -0
  84. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/final_metrics.py +0 -0
  85. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/metrics.py +0 -0
  86. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/observation.py +0 -0
  87. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/observation_result.py +0 -0
  88. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/step.py +0 -0
  89. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/subagent_trajectory_ref.py +0 -0
  90. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/tool_call.py +0 -0
  91. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/models/trajectory.py +0 -0
  92. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/profile.py +0 -0
  93. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/reader.py +0 -0
  94. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/runner.py +0 -0
  95. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/served.py +0 -0
  96. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/atif/validator.py +0 -0
  97. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/client.py +0 -0
  98. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/__init__.py +0 -0
  99. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_declare.py +0 -0
  100. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_desktop.py +0 -0
  101. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_job.py +0 -0
  102. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_linux.py +0 -0
  103. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_load.py +0 -0
  104. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_macos.py +0 -0
  105. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_reaping.py +0 -0
  106. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_session_posix.py +0 -0
  107. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_session_windows.py +0 -0
  108. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_windows.py +0 -0
  109. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_with_fds.py +0 -0
  110. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/_x11.py +0 -0
  111. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/app.py +0 -0
  112. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/app_data.py +0 -0
  113. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/app_runtime.py +0 -0
  114. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/apps.py +0 -0
  115. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/card.py +0 -0
  116. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/checks.py +0 -0
  117. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/clock.py +0 -0
  118. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/conformance/__init__.py +0 -0
  119. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/conformance/__main__.py +0 -0
  120. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/conformance/client.py +0 -0
  121. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/conformance/desk.py +0 -0
  122. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/conformance/fixture.py +0 -0
  123. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/conformance/mp4.py +0 -0
  124. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/conformance/page_fixture.py +0 -0
  125. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/conformance/report.py +0 -0
  126. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/conformance/wayland_fixture.py +0 -0
  127. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/dataplane.py +0 -0
  128. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/errors.py +0 -0
  129. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/frames.py +0 -0
  130. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/keys.py +0 -0
  131. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/launch.py +0 -0
  132. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/operations.py +0 -0
  133. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/platform.py +0 -0
  134. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/prefix.py +0 -0
  135. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/queue.py +0 -0
  136. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/results.py +0 -0
  137. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/run_install_step.py +0 -0
  138. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/seed.py +0 -0
  139. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/serve.py +0 -0
  140. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/serve_app.py +0 -0
  141. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/served.py +0 -0
  142. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/session.py +0 -0
  143. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/settings.py +0 -0
  144. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/skill.py +0 -0
  145. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/spaces.py +0 -0
  146. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/svc.py +0 -0
  147. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/computer/tools.py +0 -0
  148. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/errors.py +0 -0
  149. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/manifest.py +0 -0
  150. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/passthrough.py +0 -0
  151. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/preflight.py +0 -0
  152. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/tool_access.py +0 -0
  153. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/tool_client.py +0 -0
  154. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/tool_context.py +0 -0
  155. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/transfers.py +0 -0
  156. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/types.py +0 -0
  157. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website/__init__.py +0 -0
  158. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website/clock.py +0 -0
  159. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website/conformance.py +0 -0
  160. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website/environment.py +0 -0
  161. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website/errors.py +0 -0
  162. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website/forwarding.py +0 -0
  163. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website/readiness.py +0 -0
  164. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website/routes.py +0 -0
  165. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website/session.py +0 -0
  166. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/__init__.py +0 -0
  167. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/cdp.py +0 -0
  168. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/contexts.py +0 -0
  169. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/control.py +0 -0
  170. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/data.py +0 -0
  171. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/devtools.py +0 -0
  172. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/environment.py +0 -0
  173. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/log.py +0 -0
  174. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/network.py +0 -0
  175. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/recording.py +0 -0
  176. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/scope.py +0 -0
  177. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/shapes.py +0 -0
  178. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/src/agentenv_protocol/website_browser/stream.py +0 -0
  179. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/atif_cases.py +0 -0
  180. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/conftest.py +0 -0
  181. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_agent.py +0 -0
  182. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_agent_clock.py +0 -0
  183. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_agent_examples.py +0 -0
  184. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_atif_scrubbing.py +0 -0
  185. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_atif_serving.py +0 -0
  186. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_atif_turns.py +0 -0
  187. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_cdp_config.py +0 -0
  188. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_object_transfers.py +0 -0
  189. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_peer_agents.py +0 -0
  190. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_proxy.py +0 -0
  191. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_staging.py +0 -0
  192. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_a2a_trajectory_log.py +0 -0
  193. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_agent_env_environment.py +0 -0
  194. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_atif_builder.py +0 -0
  195. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_atif_fixtures.py +0 -0
  196. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_atif_kit.py +0 -0
  197. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_atif_profile.py +0 -0
  198. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_atif_reader.py +0 -0
  199. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_atif_validator.py +0 -0
  200. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_atif_vendored.py +0 -0
  201. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_browser_cdp.py +0 -0
  202. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_browser_contexts.py +0 -0
  203. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_browser_data.py +0 -0
  204. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_browser_log.py +0 -0
  205. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_browser_network.py +0 -0
  206. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_browser_recording.py +0 -0
  207. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_browser_state.py +0 -0
  208. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_client.py +0 -0
  209. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_app_data.py +0 -0
  210. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_app_server.py +0 -0
  211. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_clock.py +0 -0
  212. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_conformance.py +0 -0
  213. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_conformance_attempts.py +0 -0
  214. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_conformance_checks.py +0 -0
  215. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_conformance_page.py +0 -0
  216. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_conformance_recording.py +0 -0
  217. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_dataplane.py +0 -0
  218. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_declare.py +0 -0
  219. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_driver.py +0 -0
  220. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_driver_keys.py +0 -0
  221. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_extensions.py +0 -0
  222. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_frames.py +0 -0
  223. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_macos.py +0 -0
  224. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_queue.py +0 -0
  225. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_seed.py +0 -0
  226. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_serve.py +0 -0
  227. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_served.py +0 -0
  228. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_session_windows.py +0 -0
  229. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_spaces.py +0 -0
  230. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_svc_forward.py +0 -0
  231. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_tool_prefix.py +0 -0
  232. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_computer_windows_driver.py +0 -0
  233. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_control_token.py +0 -0
  234. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_data_objects.py +0 -0
  235. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_devtools_pipe.py +0 -0
  236. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_errors.py +0 -0
  237. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_extension_methods.py +0 -0
  238. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_intake.py +0 -0
  239. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_manifest.py +0 -0
  240. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_preflight.py +0 -0
  241. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_tool_access.py +0 -0
  242. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_tool_annotations.py +0 -0
  243. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_tool_client.py +0 -0
  244. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_tool_context.py +0 -0
  245. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_tool_context_fastmcp.py +0 -0
  246. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_tool_context_injection.py +0 -0
  247. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_usage.py +0 -0
  248. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_website_api.py +0 -0
  249. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_website_browser.py +0 -0
  250. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_website_conformance.py +0 -0
  251. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_website_environment.py +0 -0
  252. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_website_forwarding.py +0 -0
  253. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_website_live.py +0 -0
  254. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_website_mcp.py +0 -0
  255. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/tests/test_website_notes_example.py +0 -0
  256. {agentenv_framework_protocol-0.1.611 → agentenv_framework_protocol-0.1.614}/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.611
3
+ Version: 0.1.614
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
@@ -826,7 +826,7 @@ class MyDriver(ComputerDriverEnvironment):
826
826
  of its own, the latest 8 frames wait for the encoder, and it is closed when the recording stops. A
827
827
  driver without `@record` records by the base class polling `@capture`, with a pointer drawn at
828
828
  `@pointer_position`: the slow path, at most 15 fps.
829
- - **The methods.** `start {request_id, scope?, fps?, max_edge?, cursor?, upload?}` returns
829
+ - **The methods.** `start {request_id, scope?, fps?, max_edge?, cursor?, upload?, annotate?}` returns
830
830
  `{recording_id, started_at, format}`; `end {recording_id, upload?, reason?}` closes the last segment
831
831
  and returns the manifest; `end_all {reason?}` ends every recording not yet ended, each under the
832
832
  grant it started with, and returns `{manifests}`, as the framework does before it resets or tears a
@@ -839,6 +839,22 @@ class MyDriver(ComputerDriverEnvironment):
839
839
  `<recording_id>/<index>.mp4`, and is then deleted; `end`'s own grant uploads any that missed. With no
840
840
  grant they stay under `~/.agentenv-recordings/`. An ended recording's manifest uploads beside its
841
841
  segments, at `<recording_id>/manifest.json`, so a reader that didn't end it finds it there.
842
+ - **Annotations.** `start` with `annotate`, an object of options (`{}` for none; the card lists those a
843
+ driver takes under its params' `annotate.options`), draws each input over the frames captured while it
844
+ shows, in the colour of the role that sent it (the agent's always the same; another role's picked by its
845
+ name, so it's the same on every recording unless a role that acted earlier there has it): a ring where a click landed, round a
846
+ hollow dot that leaves the pointer's tip in sight (a square for the right button, a ring for each click
847
+ of a double or triple), a trail for a drag, an
848
+ arrow for a scroll, a cross for a move, and a chip for a key chord, typed text as it was typed, and
849
+ each of the driver's own or forwarded tools whose annotations don't say it only reads, by name and
850
+ main argument. Where the frames can't show the pointer themselves, as frames polled from captures that
851
+ leave it out do (cua-driver's), a pointer is drawn for each role and pointer that has acted, where its
852
+ last input left it, along a drag's path as it moves, after a fading line from where it jumped: the one
853
+ that moved last at full strength, the others fainter, each named once there are several. Every `computer_*` input is marked
854
+ as `act` delivers it, best effort, and shows on
855
+ every frame while it lasts and on the first one after it however late, as at a low fps. A segment a
856
+ native recorder finished is kept as it came. The manifest's `annotate` is the object the recording
857
+ drew with, and is left out for one that took a native recorder's segments.
842
858
  - **The manifest** (`RecordingManifest`). Its `segments` (`ManifestSegment`) carry each one's path,
843
859
  `started_at` and `ended_at` (its first and last frames' capture times), size, frame count, byte size,
844
860
  SHA-256 and whether it uploaded, and `ended_by` says why the recording ended: `end`, `reset`,
@@ -755,7 +755,7 @@ class MyDriver(ComputerDriverEnvironment):
755
755
  of its own, the latest 8 frames wait for the encoder, and it is closed when the recording stops. A
756
756
  driver without `@record` records by the base class polling `@capture`, with a pointer drawn at
757
757
  `@pointer_position`: the slow path, at most 15 fps.
758
- - **The methods.** `start {request_id, scope?, fps?, max_edge?, cursor?, upload?}` returns
758
+ - **The methods.** `start {request_id, scope?, fps?, max_edge?, cursor?, upload?, annotate?}` returns
759
759
  `{recording_id, started_at, format}`; `end {recording_id, upload?, reason?}` closes the last segment
760
760
  and returns the manifest; `end_all {reason?}` ends every recording not yet ended, each under the
761
761
  grant it started with, and returns `{manifests}`, as the framework does before it resets or tears a
@@ -768,6 +768,22 @@ class MyDriver(ComputerDriverEnvironment):
768
768
  `<recording_id>/<index>.mp4`, and is then deleted; `end`'s own grant uploads any that missed. With no
769
769
  grant they stay under `~/.agentenv-recordings/`. An ended recording's manifest uploads beside its
770
770
  segments, at `<recording_id>/manifest.json`, so a reader that didn't end it finds it there.
771
+ - **Annotations.** `start` with `annotate`, an object of options (`{}` for none; the card lists those a
772
+ driver takes under its params' `annotate.options`), draws each input over the frames captured while it
773
+ shows, in the colour of the role that sent it (the agent's always the same; another role's picked by its
774
+ name, so it's the same on every recording unless a role that acted earlier there has it): a ring where a click landed, round a
775
+ hollow dot that leaves the pointer's tip in sight (a square for the right button, a ring for each click
776
+ of a double or triple), a trail for a drag, an
777
+ arrow for a scroll, a cross for a move, and a chip for a key chord, typed text as it was typed, and
778
+ each of the driver's own or forwarded tools whose annotations don't say it only reads, by name and
779
+ main argument. Where the frames can't show the pointer themselves, as frames polled from captures that
780
+ leave it out do (cua-driver's), a pointer is drawn for each role and pointer that has acted, where its
781
+ last input left it, along a drag's path as it moves, after a fading line from where it jumped: the one
782
+ that moved last at full strength, the others fainter, each named once there are several. Every `computer_*` input is marked
783
+ as `act` delivers it, best effort, and shows on
784
+ every frame while it lasts and on the first one after it however late, as at a low fps. A segment a
785
+ native recorder finished is kept as it came. The manifest's `annotate` is the object the recording
786
+ drew with, and is left out for one that took a native recorder's segments.
771
787
  - **The manifest** (`RecordingManifest`). Its `segments` (`ManifestSegment`) carry each one's path,
772
788
  `started_at` and `ended_at` (its first and last frames' capture times), size, frame count, byte size,
773
789
  SHA-256 and whether it uploaded, and `ended_by` says why the recording ended: `end`, `reset`,
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agentenv-framework-protocol"
3
- version = "0.1.611"
3
+ version = "0.1.614"
4
4
  description = "Open data-plane protocol and server SDK for agent environments."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -1242,6 +1242,30 @@ def _discover_tools(handler: Any, environment_name: str) -> list:
1242
1242
  return ordered
1243
1243
 
1244
1244
 
1245
+ def read_only_tools(handler: Any, environment_name: str) -> frozenset[str]:
1246
+ """The ``@tool`` methods and forwarded tools ``handler`` serves whose MCP annotations say they only read
1247
+ (``readOnlyHint``), by the names an app mounts them under for environment ``environment_name``, before its
1248
+ ``serve_tools_as`` renames any."""
1249
+ return frozenset(descriptor.name for descriptor, fn in _with_forwarded(_discover_tools(handler, environment_name),
1250
+ handler)
1251
+ if _reads_only(_annotations_of(fn)))
1252
+
1253
+
1254
+ def _annotations_of(fn: Callable) -> Any:
1255
+ """A tool's MCP annotations as it was given them: a forwarded tool's as its server lists them."""
1256
+ if (forwarded := getattr(fn, _FORWARDED_ATTR, None)) is not None:
1257
+ return forwarded.annotations
1258
+ options = getattr(fn, _TOOL_OPTIONS_ATTR, None)
1259
+ return options.annotations if options is not None else None
1260
+
1261
+
1262
+ def _reads_only(annotations: Any) -> bool:
1263
+ """Whether MCP annotations, as a dict or a ``ToolAnnotations``, say a tool only reads."""
1264
+ if isinstance(annotations, dict):
1265
+ return annotations.get("readOnlyHint") is True
1266
+ return getattr(annotations, "readOnlyHint", None) is True
1267
+
1268
+
1245
1269
  def _served_extensions(handler: Any, ext_handlers: list) -> list:
1246
1270
  """The extension handlers the handler's ``served_extensions`` keeps, with its descriptors."""
1247
1271
  hook = getattr(handler, "served_extensions", None)
@@ -0,0 +1,551 @@
1
+ """What an annotated recording (computer-recording/v1 ``start`` with ``annotate``) draws over its frames: where each
2
+ input landed and what it typed or pressed, in the colour of the role that sent it, on the frames captured while its
3
+ mark shows. ``ComputerRuntime.act`` marks every ``computer_*`` input as it is delivered; a call to one of the
4
+ driver's own or forwarded tools, which acts without it, shows as a chip naming the tool and its main argument. Where
5
+ the frames can't show the pointer themselves, as frames from screenshots that leave it out, the agent's pointer is
6
+ drawn where its inputs left it."""
7
+ from __future__ import annotations
8
+
9
+ import dataclasses
10
+ import functools
11
+ import itertools
12
+ import math
13
+ import zlib
14
+ from collections.abc import Callable, Mapping, Sequence
15
+ from dataclasses import dataclass
16
+ from datetime import datetime, timedelta
17
+ from typing import Any, Optional, Union
18
+
19
+ import av
20
+ from PIL import Image as PILImage
21
+ from PIL import ImageDraw, ImageFont
22
+ from pydantic import BaseModel, ConfigDict, ValidationError
23
+
24
+ from .errors import InvalidArgument
25
+
26
+ #: The role of a call that names none: the agent.
27
+ DEFAULT_ROLE = "default"
28
+ #: The pointer an input acts through when it names none: the computer's own, the only one the SDK drives yet.
29
+ DEFAULT_POINTER = "default"
30
+ #: The roles' colours: the agent's the first; another role's one of the rest, picked by its name so it is the same on
31
+ #: every recording (``role_colour``), unless a role that acted earlier on the recording has it.
32
+ COLOURS =((255, 138, 0), (0, 184, 148), (175, 82, 222), (255, 59, 105), (52, 120, 246), (250, 204, 21))
33
+ #: How long a mark shows from its input, in seconds; a drag's, after its moves. A mark's kind is its operation's name,
34
+ #: or chip for one drawn as a caption.
35
+ SHOW_S = {"click": 0.8, "pointer_down": 0.8, "pointer_up": 0.8, "pointer_move": 0.5, "scroll": 0.9, "drag": 0.8,
36
+ "chip": 1.6}
37
+ #: The last part of a mark's time, in seconds, over which it fades out.
38
+ FADE_S = 0.3
39
+ #: How long a mark no frame has drawn is kept, in seconds: past it, the recording's frames have stopped coming.
40
+ KEEP_S = 30.0
41
+ #: How long after the pointer jumps a line shows where it came from, in seconds.
42
+ JUMP_S = 0.4
43
+ #: The inputs whose marks are drawn at a point of the display, which leave the pointer at their last point, a drag's
44
+ #: after moving it along its path.
45
+ POINTED = ("click", "drag", "scroll", "pointer_move", "pointer_down", "pointer_up")
46
+ #: The most a chip of typed text shows, which grows with its length from the chip's own time.
47
+ MOST_TEXT_S = 4.0
48
+ #: The most of a chip's text it shows; the rest is cut with an ellipsis.
49
+ CHIP_CHARS = 60
50
+ #: The most chips shown at once, the newest lowest.
51
+ MOST_CHIPS = 4
52
+ #: How far above the bottom edge, as a fraction of the frame's height, the lowest chip ends.
53
+ CHIPS_ABOVE = 0.1
54
+ #: A frame's longer edge that marks are sized for; on a larger or smaller frame they scale with it.
55
+ UNIT_EDGE = 1280
56
+ #: Arguments a tool's chip shows, the first one a call has.
57
+ MAIN_ARGUMENTS = ("text", "keys", "key", "url", "query", "label", "name", "element", "title", "code", "script")
58
+ #: Key names as chips show them.
59
+ KEY_NAMES = {"Control": "Ctrl", "Escape": "Esc", "ArrowLeft": "Left", "ArrowRight": "Right", "ArrowUp": "Up",
60
+ "ArrowDown": "Down", " ": "Space"}
61
+
62
+
63
+ class AnnotateOptions(BaseModel):
64
+ """What computer-recording/v1 ``start``'s ``annotate`` takes: no options yet, so ``{}`` draws every input. An
65
+ option is a field here, which the card lists, ``start`` checks, and a task step's annotation settings take too."""
66
+
67
+ model_config = ConfigDict(extra="forbid", strict=True)
68
+
69
+
70
+ def options_problem(error: ValidationError, model: type[BaseModel] = AnnotateOptions) -> str:
71
+ """What is wrong with annotation options ``model`` refused, in a sentence."""
72
+ takes = ", ".join(model.model_fields) or "no options yet"
73
+ problems = []
74
+ for e in error.errors():
75
+ where = ".".join(str(part) for part in e["loc"])
76
+ if e["type"] == "extra_forbidden":
77
+ problems.append(f"it takes {takes}, not {where!r}")
78
+ elif not where:
79
+ problems.append(f"it is an object of options, got {type(e['input']).__name__}")
80
+ else:
81
+ problems.append(f"{where}: {e['msg'].lower()}")
82
+ return "; ".join(problems)
83
+
84
+
85
+ def check_annotate(annotate: object) -> Optional[dict]:
86
+ """``start``'s ``annotate``: None, or an object of the options this driver takes, as given."""
87
+ if annotate is None:
88
+ return None
89
+ try:
90
+ return AnnotateOptions.model_validate(annotate).model_dump(exclude_unset=True)
91
+ except ValidationError as e:
92
+ raise InvalidArgument(f"annotate: {options_problem(e)}; give {{}} to draw every input") from None
93
+
94
+
95
+ @dataclass(frozen=True)
96
+ class Mark:
97
+ """One input on a recording: ``kind`` is its operation (click, drag, scroll, pointer_move, pointer_down,
98
+ pointer_up) for one drawn at a point, or chip for one drawn as a caption; ``points`` are fractions of the display,
99
+ so they land on any frame size; it shows from ``at`` until ``until``, a drag moving for its first ``moving_s``.
100
+ ``pointer`` is the pointer it acted through."""
101
+
102
+ kind: str
103
+ at: datetime
104
+ until: datetime
105
+ role: str
106
+ points: tuple[tuple[float, float], ...] = ()
107
+ button: str = "left"
108
+ count: int = 1
109
+ direction: str = ""
110
+ label: str = ""
111
+ moving_s: float = 0.0
112
+ pointer: str = DEFAULT_POINTER
113
+
114
+
115
+ @dataclass(frozen=True)
116
+ class PointerMove:
117
+ """Where a role's pointer went at ``at``: from ``was`` along ``path``, a single point for a jump, a drag's path
118
+ while it moves for ``moving_s``. ``faded`` and ``label`` are how a frame draws it among others: fainter when it
119
+ didn't move last, named when there are several."""
120
+
121
+ at: datetime
122
+ role: str
123
+ pointer: str
124
+ was: tuple[float, float]
125
+ path: tuple[tuple[float, float], ...]
126
+ moving_s: float = 0.0
127
+ faded: bool = False
128
+ label: str = ""
129
+
130
+
131
+ #: What a frame draws: a mark or a pointer, in its colour, at its age in seconds.
132
+ Shown = tuple[Union[Mark, PointerMove], tuple[int, int, int], float]
133
+
134
+
135
+ class Annotations:
136
+ """One annotated recording's marks, from their inputs until they stop showing, and the colour of each role. Each
137
+ mark shows on every frame captured while it lasts, and on the first one after its input however late that comes,
138
+ as at a low fps or from a slow capture. With ``pointer``, as for frames that can't show the pointer themselves,
139
+ each frame also draws a pointer for each role and pointer that has acted, where its last input before the frame
140
+ left it: the one that moved last at full strength, the others fainter, each named once there are several."""
141
+
142
+ def __init__(self, pointer: bool = False) -> None:
143
+ self._kept: dict[int, Mark] = {} # each mark by the number it was added as, oldest first
144
+ self._added = itertools.count()
145
+ self._drawn: set[int] = set() # the numbers of the kept marks a frame has drawn
146
+ self.colours: dict[str, tuple[int, int, int]] = {DEFAULT_ROLE: COLOURS[0]}
147
+ self.pointer = pointer
148
+ self.moves: dict[tuple[str, str], list[PointerMove]] = {} # each role's and pointer's, oldest first
149
+
150
+ @property
151
+ def marks(self) -> list[Mark]:
152
+ """The marks kept, oldest first."""
153
+ return list(self._kept.values())
154
+
155
+ def add(self, marks: Sequence[Mark]) -> None:
156
+ for mark in marks:
157
+ if mark.role not in self.colours:
158
+ self.colours[mark.role] = _free_colour(mark.role, set(self.colours.values()))
159
+ stale = mark.at - timedelta(seconds=KEEP_S)
160
+ self._keep(lambda _number, kept: kept.until > stale)
161
+ self._kept[next(self._added)] = mark
162
+ if self.pointer and mark.kind in POINTED:
163
+ moves = self.moves.setdefault((mark.role, mark.pointer), [])
164
+ path = mark.points if mark.kind == "drag" else mark.points[-1:]
165
+ was = moves[-1].path[-1] if moves else path[0]
166
+ moves.append(PointerMove(mark.at, mark.role, mark.pointer, was, path, mark.moving_s))
167
+
168
+ def _pointers(self, at: datetime) -> list[Shown]:
169
+ """The pointers a frame captured ``at`` shows, each as its last move before the frame at its age, the one that
170
+ moved last drawn over the others; none for a role or pointer that hadn't acted by then."""
171
+ current = []
172
+ for key, moves in self.moves.items():
173
+ last = next((i for i in range(len(moves) - 1, -1, -1) if moves[i].at <= at), None)
174
+ if last is not None:
175
+ self.moves[key] = moves[last:] # the frames come in order, so an earlier move won't show again
176
+ current.append(moves[last])
177
+ current.sort(key=lambda move: move.at)
178
+ several = len(current) > 1
179
+ shown = [dataclasses.replace(move, faded=move is not current[-1],
180
+ label=_pointer_label(move) if several else "") for move in current]
181
+ return [(move, self.colours[move.role], (at - move.at).total_seconds()) for move in shown]
182
+
183
+ def next_frame(self, at: datetime) -> list[Shown]:
184
+ """What the next frame, captured ``at``, draws, each mark with its colour and the age, in seconds, it is drawn
185
+ at, then the pointers; and notes it drawn. Called once per frame, in the order the frames were captured: a mark
186
+ over by then that no frame has drawn yet is drawn once, at the age it is last fully shown, and a mark that is
187
+ over and drawn, or a pointer's move another has followed, isn't drawn on any later frame."""
188
+ due = []
189
+ for number, mark in self._kept.items():
190
+ if mark.at > at:
191
+ continue
192
+ age = (at - mark.at).total_seconds()
193
+ if at >= mark.until:
194
+ if number in self._drawn:
195
+ continue
196
+ age = max(0.0, (mark.until - mark.at).total_seconds() - FADE_S)
197
+ due.append((number, (mark, self.colours[mark.role], age)))
198
+ chips = [number for number, (mark, _colour, _age) in due if mark.kind == "chip"]
199
+ waiting = set(chips[:-MOST_CHIPS]) # older chips than a frame shows wait for a later one
200
+ shown = [(number, entry) for number, entry in due if number not in waiting]
201
+ self._drawn |= {number for number, _entry in shown}
202
+ self._keep(lambda number, mark: mark.until > at or number not in self._drawn)
203
+ return [entry for _number, entry in shown] + (self._pointers(at) if self.pointer else [])
204
+
205
+ def _keep(self, keeps: Callable[[int, Mark], bool]) -> None:
206
+ """Keep only the marks ``keeps`` says to, by their number and the mark."""
207
+ self._kept = {number: mark for number, mark in self._kept.items() if keeps(number, mark)}
208
+ self._drawn &= self._kept.keys()
209
+
210
+
211
+ def role_colour(role: str) -> tuple[int, int, int]:
212
+ """The colour ``role`` draws in on every recording no other role took it on first: the agent's the first of
213
+ COLOURS, another role's one of the rest, picked by its name."""
214
+ if role == DEFAULT_ROLE:
215
+ return COLOURS[0]
216
+ return COLOURS[1 + zlib.crc32(role.encode()) % (len(COLOURS) - 1)]
217
+
218
+
219
+ def _free_colour(role: str, taken: set[tuple[int, int, int]]) -> tuple[int, int, int]:
220
+ """``role``'s colour on a recording whose roles have ``taken`` theirs: its own, else the next of the rest none has,
221
+ else its own again once every one is taken."""
222
+ own = role_colour(role)
223
+ if own not in taken:
224
+ return own
225
+ rest = COLOURS[1:]
226
+ start = rest.index(own)
227
+ return next((colour for colour in (rest[(start + step) % len(rest)] for step in range(1, len(rest)))
228
+ if colour not in taken), own)
229
+
230
+
231
+ def input_marks(operation: str, args: tuple, *, role: Optional[str], at: datetime, size: tuple[int, int],
232
+ point: Optional[tuple] = None, repeat: int = 1, hold_ms: Optional[int] = None) -> list[Mark]:
233
+ """The marks of one ``ComputerRuntime.act`` input: ``args`` are the operation's, in screen units on a display of
234
+ ``size``; ``point`` is where an input with no point of its own acts (its ``move_to``, or the pointer)."""
235
+ role = role or DEFAULT_ROLE
236
+ width, height = size
237
+
238
+ def where(x: float, y: float) -> tuple[float, float]:
239
+ return (x / width, y / height)
240
+
241
+ def shown(kind: str, extra_s: float = 0.0) -> datetime:
242
+ return at + timedelta(seconds=SHOW_S[kind] + extra_s)
243
+
244
+ def chip(label: str, seconds: Optional[float] = None) -> Mark:
245
+ until = at + timedelta(seconds=seconds) if seconds is not None else shown("chip")
246
+ return Mark("chip", at, until, role, label=label if role == DEFAULT_ROLE else f"{role}: {label}")
247
+
248
+ held = args[-1] if operation in ("click", "drag", "scroll") and args and isinstance(args[-1], list) else []
249
+ marks: list[Mark] = []
250
+ if operation == "click":
251
+ x, y, button, count = args[:4]
252
+ marks.append(Mark("click", at, shown("click"), role, (where(x, y),), button=button, count=count))
253
+ elif operation == "drag":
254
+ path, button, duration = args[:3]
255
+ marks.append(Mark("drag", at, shown("drag", duration / 1000), role, tuple(where(*p) for p in path),
256
+ button=button, moving_s=duration / 1000))
257
+ elif operation == "scroll":
258
+ x, y, direction, amount = args[:4]
259
+ marks.append(Mark("scroll", at, shown("scroll"), role, (where(x, y),), direction=direction, count=amount))
260
+ elif operation == "pointer_move":
261
+ marks.append(Mark(operation, at, shown(operation), role, (where(*args[:2]),)))
262
+ elif operation in ("pointer_down", "pointer_up"):
263
+ if point is not None:
264
+ marks.append(Mark(operation, at, shown(operation), role, (where(*point[:2]),), button=args[0]))
265
+ else:
266
+ marks.append(chip(f"{'press' if operation == 'pointer_down' else 'release'} {args[0]}"))
267
+ elif operation == "type_text":
268
+ text = args[0]
269
+ marks.append(chip(f'type "{_shown_text(text)}"', min(MOST_TEXT_S, SHOW_S["chip"] + len(text) / 25)))
270
+ elif operation == "press":
271
+ times = f" x{repeat}" if repeat > 1 else ""
272
+ marks.append(chip(f"key {_chord(args[0])}{times}"))
273
+ elif operation == "key_down":
274
+ for_ms = f" {hold_ms} ms" if hold_ms is not None else ""
275
+ marks.append(chip(f"hold {_chord(args[0])}{for_ms}"))
276
+ elif operation == "key_up":
277
+ marks.append(chip(f"release {_chord(args[0])}"))
278
+ elif operation == "navigate":
279
+ marks.append(chip(f"open {_cut(args[0])}"))
280
+ elif operation == "history":
281
+ marks.append(chip(args[0]))
282
+ elif operation == "tabs":
283
+ action, tab, url = args
284
+ if action != "list":
285
+ marks.append(chip(" ".join(str(part) for part in ("tab", action, tab or _cut(url or "")) if part)))
286
+ elif operation == "dialog":
287
+ marks.append(chip("dialog OK" if args[0] else "dialog Cancel"))
288
+ elif operation == "upload":
289
+ marks.append(chip(f"upload {_cut(', '.join(args[0]))}"))
290
+ else:
291
+ marks.append(chip(operation))
292
+ if held:
293
+ marks.append(chip(f"{_chord(held)} + {operation}"))
294
+ return marks
295
+
296
+
297
+ def tool_mark(tool: str, arguments: Mapping[str, Any], *, role: Optional[str], at: datetime) -> Mark:
298
+ """The chip of a call to one of the driver's own or forwarded tools: its name and its main argument."""
299
+ role = role or DEFAULT_ROLE
300
+ main = next((arguments[name] for name in MAIN_ARGUMENTS if arguments.get(name) not in (None, "", [])), None)
301
+ if isinstance(main, list) and all(isinstance(part, str) for part in main):
302
+ shown = _chord(main)
303
+ elif isinstance(main, str):
304
+ shown = f'"{_shown_text(main)}"' if main.strip() else ""
305
+ else:
306
+ shown = "" if main is None else _cut(str(main))
307
+ label = f"{tool} {shown}".strip()
308
+ return Mark("chip", at, at + timedelta(seconds=SHOW_S["chip"]), role,
309
+ label=label if role == DEFAULT_ROLE else f"{role}: {label}")
310
+
311
+
312
+ def draw(image: Any, shown: Sequence[Shown]) -> PILImage.Image:
313
+ """``image``, a Pillow image or a PyAV frame, with what a frame shows drawn, each in its colour at its age."""
314
+ base = (image.to_image() if isinstance(image, av.VideoFrame) else image).convert("RGBA")
315
+ overlay = PILImage.new("RGBA", base.size, (0, 0, 0, 0))
316
+ pen = ImageDraw.Draw(overlay)
317
+ unit = max(base.size) / UNIT_EDGE
318
+
319
+ def pixels(point: tuple[float, float]) -> tuple[float, float]:
320
+ return (point[0] * base.width, point[1] * base.height)
321
+
322
+ chips = []
323
+ for item, colour, age in shown:
324
+ if isinstance(item, PointerMove):
325
+ _draw_pointer(pen, item, pixels(item.was), [pixels(p) for p in item.path], colour, unit, age)
326
+ continue
327
+ if item.kind == "chip":
328
+ chips.append((item, colour))
329
+ continue
330
+ span = max((item.until - item.at).total_seconds(), 1e-3)
331
+ fade = 1.0 - max(0.0, min(1.0, (age - (span - FADE_S)) / FADE_S))
332
+ _DRAWERS[item.kind](pen, item, [pixels(p) for p in item.points], colour, unit, age, fade)
333
+ if chips:
334
+ _draw_chips(pen, chips, base.size, unit)
335
+ return PILImage.alpha_composite(base, overlay).convert("RGB")
336
+
337
+
338
+ @dataclass(frozen=True)
339
+ class Style:
340
+ """How marks look: sizes in pixels of a frame whose longer edge is UNIT_EDGE, scaled with the frame; each coloured
341
+ stroke over a wider white halo, so a mark reads on any background."""
342
+
343
+ stroke: float = 3 # a ring's and a cross's coloured stroke
344
+ halo: float = 5 # the white band under a ring's stroke
345
+ line: float = 4 # a trail's and an arrow's coloured stroke
346
+ line_halo: float = 7
347
+ outline: float = 1.5 # a dot's white outline
348
+ ring_grow_s: float = 0.35 # how long a click's ring takes to grow to its full size, in seconds
349
+ ring_from: float = 12 # a click's ring's radius as it starts
350
+ ring_grows: float = 18 # and how much it grows
351
+ ring_apart: float = 8 # between the rings of a double or triple click
352
+ most_rings: int = 3
353
+ dot: float = 5 # the hollow dot at a click's point, which leaves the pointer's tip there in sight
354
+ dot_stroke: float = 2
355
+ pointer: float = 1.6 # the agent's pointer, as a multiple of the usual arrow cursor's size
356
+ pointer_outline: float = 2
357
+ pointer_faded_alpha: int = 120 # a pointer that didn't move last
358
+ jump_alpha: int = 170 # the line from where the pointer jumped, at its start
359
+ press_down: float = 10 # a press's filled ring's radius
360
+ press_up: float = 16 # a release's ring's radius
361
+ press_fill: float = 0.7 # a press's fill opacity, as a share of its stroke's
362
+ cross: float = 9 # each arm of a move's cross
363
+ cross_alpha: int = 200 # a move's cross is fainter than the marks of inputs that act
364
+ arrow: float = 46 # a scroll's arrow
365
+ arrowhead: float = 14 # an arrowhead's sides, beside the stroke's own width
366
+ arrowhead_angle: float = 0.5 # radians either side of its line
367
+ start_dot: float = 6 # the dot where a drag starts
368
+ chip_text: float = 20
369
+ chip_pad: float = 10 # beside a chip's text; above and below it, CHIP_PAD_HIGH of that
370
+ chip_gap: float = 8 # between stacked chips
371
+ chip_radius: float = 8
372
+ chip_alpha: int = 235
373
+ chip_low: float = 48 # the least the lowest chip ends above the bottom edge
374
+ label_text: float = 15 # a scroll's count and a button's name beside its mark
375
+ label_pad: float = 4
376
+ label_from: float = 16 # a button's name, right and down from its click
377
+ label_alpha: float = 0.9
378
+ least_text: int = 9 # the smallest text, in pixels, on any frame
379
+
380
+
381
+ STYLE = Style()
382
+ #: A chip's padding above and below its text, as a share of the padding beside it.
383
+ CHIP_PAD_HIGH = 0.7
384
+ WHITE = (255, 255, 255)
385
+
386
+
387
+ def _width(width: float, unit: float) -> int:
388
+ return max(1, round(width * unit))
389
+
390
+
391
+ def _draw_click(pen, mark, points, colour, unit, age, fade) -> None:
392
+ x, y = points[0]
393
+ grow = min(1.0, age / STYLE.ring_grow_s)
394
+ alpha = round(255 * fade)
395
+ for ring in range(max(1, min(mark.count, STYLE.most_rings))):
396
+ r = unit * (STYLE.ring_from + STYLE.ring_grows * grow + STYLE.ring_apart * ring)
397
+ box = (x - r, y - r, x + r, y + r)
398
+ shape = pen.rectangle if mark.button == "right" else pen.ellipse
399
+ shape(box, outline=(*WHITE, alpha), width=_width(STYLE.halo, unit))
400
+ shape(box, outline=(*colour, alpha), width=_width(STYLE.stroke, unit))
401
+ dot = unit * STYLE.dot
402
+ pen.ellipse((x - dot, y - dot, x + dot, y + dot), outline=(*colour, alpha), width=_width(STYLE.dot_stroke, unit))
403
+ if mark.button not in ("left", "right"):
404
+ _label(pen, (x + unit * STYLE.label_from, y + unit * STYLE.label_from), mark.button, colour, unit, alpha)
405
+
406
+
407
+ def _draw_press(pen, mark, points, colour, unit, age, fade) -> None:
408
+ x, y = points[0]
409
+ alpha = round(255 * fade)
410
+ down = mark.kind == "pointer_down"
411
+ r = unit * (STYLE.press_down if down else STYLE.press_up)
412
+ fill = (*colour, round(alpha * STYLE.press_fill)) if down else None
413
+ pen.ellipse((x - r, y - r, x + r, y + r), fill=fill, outline=(*WHITE, alpha), width=_width(STYLE.halo, unit))
414
+ pen.ellipse((x - r, y - r, x + r, y + r), outline=(*colour, alpha), width=_width(STYLE.stroke, unit))
415
+
416
+
417
+ def _draw_move(pen, mark, points, colour, unit, age, fade) -> None:
418
+ x, y = points[0]
419
+ alpha = round(STYLE.cross_alpha * fade)
420
+ arm = unit * STYLE.cross
421
+ for dx, dy in ((arm, 0), (0, arm)):
422
+ pen.line((x - dx, y - dy, x + dx, y + dy), fill=(*WHITE, alpha), width=_width(STYLE.halo, unit))
423
+ pen.line((x - dx, y - dy, x + dx, y + dy), fill=(*colour, alpha), width=_width(STYLE.stroke, unit))
424
+
425
+
426
+ def _draw_scroll(pen, mark, points, colour, unit, age, fade) -> None:
427
+ x, y = points[0]
428
+ alpha = round(255 * fade)
429
+ dx, dy = {"up": (0, -1), "down": (0, 1), "left": (-1, 0), "right": (1, 0)}.get(mark.direction, (0, 1))
430
+ end = (x + dx * unit * STYLE.arrow, y + dy * unit * STYLE.arrow)
431
+ for width, fill in ((STYLE.line_halo, (*WHITE, alpha)), (STYLE.line, (*colour, alpha))):
432
+ pen.line((x, y, *end), fill=fill, width=_width(width, unit))
433
+ _arrowhead(pen, (x, y), end, unit, fill, width)
434
+ _label(pen, (end[0] + unit * STYLE.label_pad * 2, end[1] + unit * STYLE.label_pad), f"x{mark.count}", colour,
435
+ unit, alpha)
436
+
437
+
438
+ def _draw_drag(pen, mark, points, colour, unit, age, fade) -> None:
439
+ alpha = round(255 * fade)
440
+ shown = points if age >= mark.moving_s else _along(points, age / mark.moving_s)
441
+ for width, fill in ((STYLE.line_halo, (*WHITE, alpha)), (STYLE.line, (*colour, alpha))):
442
+ if len(shown) > 1:
443
+ pen.line([coord for point in shown for coord in point], fill=fill, width=_width(width, unit),
444
+ joint="curve")
445
+ _arrowhead(pen, shown[-2], shown[-1], unit, fill, width)
446
+ sx, sy = points[0]
447
+ r = unit * STYLE.start_dot
448
+ pen.ellipse((sx - r, sy - r, sx + r, sy + r), fill=(*colour, alpha), outline=(*WHITE, alpha),
449
+ width=_width(STYLE.outline, unit))
450
+
451
+
452
+ #: The usual arrow cursor, its tip at (0, 0), in pixels of a UNIT_EDGE frame.
453
+ ARROW = ((0, 0), (0, 17), (4, 13), (7, 20), (10, 19), (7, 12), (12, 12))
454
+
455
+
456
+ def _draw_pointer(pen, move: PointerMove, was, path, colour, unit, age) -> None:
457
+ """A pointer: along a drag's path while it moves, else where its input left it, after a fading line from where
458
+ it jumped; fainter when it didn't move last, and named when it is one of several."""
459
+ tip = _along(path, age / move.moving_s)[-1] if len(path) > 1 and age < move.moving_s else path[-1]
460
+ if age < JUMP_S and math.dist(was, path[0]) > unit * STYLE.cross:
461
+ alpha = round(STYLE.jump_alpha * (1 - age / JUMP_S))
462
+ pen.line((*was, *path[0]), fill=(*colour, alpha), width=_width(STYLE.stroke, unit))
463
+ scale = unit * STYLE.pointer
464
+ arrow = [(tip[0] + dx * scale, tip[1] + dy * scale) for dx, dy in ARROW]
465
+ alpha = STYLE.pointer_faded_alpha if move.faded else 255
466
+ pen.polygon(arrow, fill=(*colour, alpha), outline=(*WHITE, alpha), width=_width(STYLE.pointer_outline, unit))
467
+ if move.label:
468
+ corner = max(dx for dx, _dy in ARROW), max(dy for _dx, dy in ARROW)
469
+ _label(pen, (tip[0] + corner[0] * scale, tip[1] + corner[1] * scale), move.label, colour, unit, alpha)
470
+
471
+
472
+ #: How each kind of mark drawn at a point is drawn, by its operation.
473
+ _DRAWERS = {"click": _draw_click, "pointer_down": _draw_press, "pointer_up": _draw_press,
474
+ "pointer_move": _draw_move, "scroll": _draw_scroll, "drag": _draw_drag}
475
+
476
+
477
+ def _draw_chips(pen, chips, size, unit) -> None:
478
+ """Chips stacked centred above the bottom edge, clear of a panel or dock there, the newest lowest."""
479
+ font = _font(max(STYLE.least_text, round(STYLE.chip_text * unit)))
480
+ pad, high, gap = unit * STYLE.chip_pad, unit * STYLE.chip_pad * CHIP_PAD_HIGH, unit * STYLE.chip_gap
481
+ y = size[1] - max(unit * STYLE.chip_low, size[1] * CHIPS_ABOVE)
482
+ for mark, colour in reversed(chips):
483
+ left, top, right, bottom = pen.textbbox((0, 0), mark.label, font=font)
484
+ w, h = right - left + 2 * pad, bottom - top + 2 * high
485
+ x0, y0 = (size[0] - w) / 2, y - h
486
+ pen.rounded_rectangle((x0, y0, x0 + w, y), radius=unit * STYLE.chip_radius, fill=(*colour, STYLE.chip_alpha),
487
+ outline=(*WHITE, STYLE.chip_alpha), width=_width(STYLE.outline, unit))
488
+ pen.text((x0 + pad - left, y0 + high - top), mark.label, font=font, fill=_ink(colour))
489
+ y = y0 - gap
490
+
491
+
492
+ def _label(pen, at: tuple[float, float], text: str, colour, unit, alpha) -> None:
493
+ font = _font(max(STYLE.least_text, round(STYLE.label_text * unit)))
494
+ left, top, right, bottom = pen.textbbox(at, text, font=font)
495
+ pad = unit * STYLE.label_pad
496
+ pen.rounded_rectangle((left - pad, top - pad, right + pad, bottom + pad), radius=pad,
497
+ fill=(*colour, round(alpha * STYLE.label_alpha)))
498
+ pen.text(at, text, font=font, fill=(*_ink(colour)[:3], alpha))
499
+
500
+
501
+ def _arrowhead(pen, start, end, unit, fill, width) -> None:
502
+ angle = math.atan2(end[1] - start[1], end[0] - start[0])
503
+ size = unit * (STYLE.arrowhead + width)
504
+ sides = [(end[0] - size * math.cos(angle + turn), end[1] - size * math.sin(angle + turn))
505
+ for turn in (-STYLE.arrowhead_angle, STYLE.arrowhead_angle)]
506
+ pen.polygon([end, *sides], fill=fill)
507
+
508
+
509
+ def _along(points: list[tuple[float, float]], fraction: float) -> list[tuple[float, float]]:
510
+ """The first ``fraction`` of the path through ``points``, by length."""
511
+ legs = [math.dist(a, b) for a, b in zip(points, points[1:])]
512
+ left = sum(legs) * max(0.0, min(1.0, fraction))
513
+ shown = [points[0]]
514
+ for (a, b), leg in zip(zip(points, points[1:]), legs):
515
+ if left >= leg:
516
+ shown.append(b)
517
+ left -= leg
518
+ continue
519
+ t = left / leg if leg else 0.0
520
+ shown.append((a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t))
521
+ break
522
+ return shown
523
+
524
+
525
+ def _pointer_label(move: PointerMove) -> str:
526
+ """A pointer's name beside it: its role's, the agent's as agent, and its own when it isn't the default."""
527
+ role = "agent" if move.role == DEFAULT_ROLE else move.role
528
+ return role if move.pointer == DEFAULT_POINTER else f"{role} {move.pointer}"
529
+
530
+
531
+ def _ink(colour: tuple[int, int, int]) -> tuple[int, int, int, int]:
532
+ """Black or white, whichever reads on ``colour``."""
533
+ r, g, b = colour
534
+ return (20, 20, 20, 255) if 0.299 * r + 0.587 * g + 0.114 * b > 160 else (255, 255, 255, 255)
535
+
536
+
537
+ def _chord(keys: Sequence[str]) -> str:
538
+ return "+".join(KEY_NAMES.get(key, key.upper() if len(key) == 1 else key) for key in keys)
539
+
540
+
541
+ def _shown_text(text: str) -> str:
542
+ return _cut(text.replace("\n", "[Enter]").replace("\t", "[Tab]"))
543
+
544
+
545
+ def _cut(text: str) -> str:
546
+ return text if len(text) <= CHIP_CHARS else text[:CHIP_CHARS - 1] + "…"
547
+
548
+
549
+ @functools.lru_cache(maxsize=16)
550
+ def _font(size: int) -> Any:
551
+ return ImageFont.load_default(size=size)