agentenv-framework-protocol 0.1.649__tar.gz → 0.1.652__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.649 → agentenv_framework_protocol-0.1.652}/PKG-INFO +54 -1
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/README.md +53 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/pyproject.toml +1 -1
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/__init__.py +6 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/agent_env_environment.py +239 -9
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/types.py +2 -0
- agentenv_framework_protocol-0.1.652/tests/test_tool_defers.py +320 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/.gitignore +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/LICENSE +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/NOTICE +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/THIRD_PARTY_NOTICES.md +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/advanced_agent.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/basic_agent.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/custom_extensions_agent.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/multimodal_agent.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/reference_model.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/streaming_agent.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/.gitignore +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/Dockerfile +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/Dockerfile.dockerignore +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/README.md +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/data/seed.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/env.toml +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/site.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/web/index.html +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/web/package-lock.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/web/package.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/web/src/main.js +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/web/src/style.css +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/examples/website/notes/web/vite.config.js +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/_atif_copy.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/_media_spool.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/_secrets.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/_snapshot_state.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/_trajectory_log.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/_triggers.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/_turn_index.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/clock.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/control_token.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/extensions.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/framework.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/peer_agents.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/proxy.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/registry.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/staging.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/tasks/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/a2a_agent/tasks/v1.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/PROFILE.md +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/__main__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/_image_size.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/adapter.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/builder.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/coding.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/coding.stripped.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/computer_use.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/late_result.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/media/482405b002a62efa8516c36709a7a100637507670576fa73a20ad5420d55c66f.png +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/media/55c64d0fcd6f9d5f7c828093857e3fdfda68478bb4e9bd24d481ef391c7804e8.heic +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/media/67905ad3cc2dd52b1f5f6a6d2814de0396618b29b4238b9af5207aeb69936e6d.mp4 +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/media/69a8aa01fe5537076d023dd5e9cc4275b39fc0434aa6483a9f58b66ef2f3c896.png +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/media/82e60066a2de261b6653bcdda90d1cb9a7af2f474cecd82e8d371e8384d72315.png +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/media/845e91831319e89c4d656bdb80c278ac09a7230d61e5dfd2e1b1fbb436ac8917.pdf +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/multi_agent.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/odd_parts.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/subagent.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/fixtures/two_turns.json +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/kit.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/LICENSE +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/VENDORED.md +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/agent.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/content.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/final_metrics.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/metrics.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/observation.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/observation_result.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/step.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/subagent_trajectory_ref.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/tool_call.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/models/trajectory.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/profile.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/reader.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/runner.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/served.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/atif/validator.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/client.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_declare.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_desktop.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_job.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_linux.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_load.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_macos.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_reaping.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_session_posix.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_session_windows.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_windows.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_with_fds.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/_x11.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/annotate.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/app.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/app_data.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/app_runtime.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/apps.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/card.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/checks.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/clock.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/conformance/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/conformance/__main__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/conformance/checks.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/conformance/client.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/conformance/desk.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/conformance/fixture.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/conformance/mp4.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/conformance/page_fixture.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/conformance/report.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/conformance/wayland_fixture.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/dataplane.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/driver.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/errors.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/extensions.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/frames.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/keys.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/launch.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/manifest.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/operations.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/platform.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/prefix.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/queue.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/recording.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/results.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/run_install_step.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/runtime.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/seed.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/serve.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/serve_app.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/served.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/session.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/settings.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/skill.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/spaces.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/svc.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/computer/tools.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/errors.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/manifest.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/passthrough.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/preflight.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/tool_access.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/tool_client.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/tool_context.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/transfers.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website/clock.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website/conformance.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website/environment.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website/errors.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website/forwarding.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website/readiness.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website/routes.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website/session.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/__init__.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/cdp.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/contexts.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/control.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/data.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/devtools.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/environment.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/log.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/network.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/recording.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/scope.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/shapes.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/src/agentenv_protocol/website_browser/stream.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/atif_cases.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/computer_fake.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/conftest.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/probe_fake.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_agent.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_agent_clock.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_agent_examples.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_atif_media.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_atif_prescribe.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_atif_scrubbing.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_atif_serving.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_atif_turns.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_cdp_config.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_object_transfers.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_peer_agents.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_proxy.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_staging.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_a2a_trajectory_log.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_agent_env_environment.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_atif_builder.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_atif_fixtures.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_atif_kit.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_atif_profile.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_atif_reader.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_atif_validator.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_atif_vendored.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_browser_cdp.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_browser_contexts.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_browser_data.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_browser_log.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_browser_network.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_browser_recording.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_browser_state.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_client.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_app_data.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_app_server.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_clock.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_conformance.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_conformance_attempts.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_conformance_checks.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_conformance_page.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_conformance_recording.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_dataplane.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_declare.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_driver.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_driver_keys.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_extensions.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_frames.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_macos.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_page.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_queue.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_recording.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_recording_annotate.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_screenshot_delay.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_seed.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_serve.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_served.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_session_windows.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_spaces.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_svc_forward.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_tool_prefix.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_computer_windows_driver.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_control_token.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_data_objects.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_devtools_pipe.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_errors.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_extension_methods.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_intake.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_manifest.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_preflight.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_tool_access.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_tool_annotations.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_tool_client.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_tool_context.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_tool_context_fastmcp.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_tool_context_injection.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_usage.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_usage_models.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_website_api.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_website_browser.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_website_conformance.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_website_environment.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_website_forwarding.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_website_live.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_website_mcp.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/tests/test_website_notes_example.py +0 -0
- {agentenv_framework_protocol-0.1.649 → agentenv_framework_protocol-0.1.652}/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.652
|
|
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
|
|
@@ -161,6 +161,59 @@ step names it. Steps that name it show and hide it as they do any tool. Steps fo
|
|
|
161
161
|
that role's earlier named steps, and a full reset (`role: "*", tools: "*"`) clears all of them, so
|
|
162
162
|
grant a hidden tool after such steps. Trigger tool actions call it as usual.
|
|
163
163
|
|
|
164
|
+
A tool's successful result can ask the gateway to call the same server later, for something the
|
|
165
|
+
server does at a time of its own (a scheduled message posted at its time) that no tool call would
|
|
166
|
+
otherwise mark. Its `_meta` `"agentenv.io/deferredCalls"` (`DEFERRED_CALLS_META_KEY`) is a list of
|
|
167
|
+
`{"key", "at", "call", "report_as"}`: `at` an RFC 3339 instant with an offset, `call` and
|
|
168
|
+
`report_as` each `{"tool", "arguments"}`. The gateway takes the key off the result, so no caller sees
|
|
169
|
+
it, and schedules each entry once per server and `key` (one its server declares again while pending
|
|
170
|
+
or done is ignored). When the gateway clock reaches `at` (its virtual time while armed, wall UTC
|
|
171
|
+
while not) it calls `call.tool` as the role that made the declaring call, as it makes a live call
|
|
172
|
+
(under the consistent mode's lock, its write attributed to it). After a transport failure it calls
|
|
173
|
+
again: five attempts in all, 1, 2, 4 and 8 s apart, each of which first reopens the server's session
|
|
174
|
+
if it must (retrying the connection for about ten seconds), so against a server that stays down the
|
|
175
|
+
call fails about 51 s after its first attempt (as observed). So make that tool idempotent (and
|
|
176
|
+
`hidden_by_default`, as plumbing). Unless the result is an error, the gateway hands its triggers that
|
|
177
|
+
result as that role's call of `report_as.tool` with `report_as.arguments`; a trigger action's own
|
|
178
|
+
call provokes no trigger, and neither does one it declares. `GET /triggers/state` lists each under
|
|
179
|
+
`deferred_calls` (`due` marks one the clock has reached that is still to make, which settle checks
|
|
180
|
+
wait for), and counts the earliest still to make in `next_event_at`. Behind no gateway, or one that
|
|
181
|
+
ignores the key, nothing calls it, so a server still acts by itself once the time has passed (on its
|
|
182
|
+
next read, say).
|
|
183
|
+
|
|
184
|
+
`@tool(..., defers=Defers(call=..., report_as=..., using=...))` builds that declaration for you, and
|
|
185
|
+
the tool returns its reply as before:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from agentenv_protocol import DeferredCall, Defers, tool
|
|
189
|
+
|
|
190
|
+
@tool(hidden_by_default=True)
|
|
191
|
+
def deliver_reminder(self, reminder_id: str) -> str: ...
|
|
192
|
+
|
|
193
|
+
@tool(defers=Defers(call="deliver_reminder", report_as="send_notification", using="_reminder_delivery"))
|
|
194
|
+
def schedule_reminder(self, event_id: str, remind_at: str) -> str: ...
|
|
195
|
+
|
|
196
|
+
def _reminder_delivery(self, arguments: dict, result) -> DeferredCall | list[DeferredCall] | None:
|
|
197
|
+
if not result.get("ok"):
|
|
198
|
+
return None
|
|
199
|
+
return DeferredCall(key=result["reminder_id"], at=result["remind_at"],
|
|
200
|
+
arguments={"reminder_id": result["reminder_id"]},
|
|
201
|
+
report_arguments={"event_id": arguments["event_id"]})
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
After each successful call of the registered tool, the SDK calls `self.<using>(arguments, result)`
|
|
205
|
+
with the call's arguments and the tool's result: a JSON text reply parsed to its dict or list, a dict
|
|
206
|
+
as is, a `CallToolResult`'s `structuredContent` or else its text so parsed, anything else as it is.
|
|
207
|
+
Each `DeferredCall` it returns becomes one entry, with the named tools as its `call` and `report_as`;
|
|
208
|
+
`at` is an aware datetime, epoch seconds or an RFC 3339 string with an offset, declared in UTC. The
|
|
209
|
+
reply's content and structured content are unchanged, and the entries join any `_meta` it has. An
|
|
210
|
+
error reply declares nothing, and a declaration that fails (`using` raises, or returns a wrong type,
|
|
211
|
+
an empty key or an `at` without an offset) is logged and left out rather than breaking the reply.
|
|
212
|
+
The method called in process still returns its plain value. The mount raises unless `call` is a
|
|
213
|
+
`hidden_by_default` tool and `report_as` a tool the environment serves (by served name,
|
|
214
|
+
`{environment_name}` resolved), and `using` a plain method; the card lists both tools under the
|
|
215
|
+
tool's `defers`.
|
|
216
|
+
|
|
164
217
|
`@tool(..., annotations={"readOnlyHint": True}, structured_output=True, meta={...})` lists the tool
|
|
165
218
|
with MCP `ToolAnnotations`, an output schema and `_meta`, on mcp's FastMCP and on fastmcp alike.
|
|
166
219
|
`structured_output` follows mcp's FastMCP (None derives an output schema from the return annotation
|
|
@@ -90,6 +90,59 @@ step names it. Steps that name it show and hide it as they do any tool. Steps fo
|
|
|
90
90
|
that role's earlier named steps, and a full reset (`role: "*", tools: "*"`) clears all of them, so
|
|
91
91
|
grant a hidden tool after such steps. Trigger tool actions call it as usual.
|
|
92
92
|
|
|
93
|
+
A tool's successful result can ask the gateway to call the same server later, for something the
|
|
94
|
+
server does at a time of its own (a scheduled message posted at its time) that no tool call would
|
|
95
|
+
otherwise mark. Its `_meta` `"agentenv.io/deferredCalls"` (`DEFERRED_CALLS_META_KEY`) is a list of
|
|
96
|
+
`{"key", "at", "call", "report_as"}`: `at` an RFC 3339 instant with an offset, `call` and
|
|
97
|
+
`report_as` each `{"tool", "arguments"}`. The gateway takes the key off the result, so no caller sees
|
|
98
|
+
it, and schedules each entry once per server and `key` (one its server declares again while pending
|
|
99
|
+
or done is ignored). When the gateway clock reaches `at` (its virtual time while armed, wall UTC
|
|
100
|
+
while not) it calls `call.tool` as the role that made the declaring call, as it makes a live call
|
|
101
|
+
(under the consistent mode's lock, its write attributed to it). After a transport failure it calls
|
|
102
|
+
again: five attempts in all, 1, 2, 4 and 8 s apart, each of which first reopens the server's session
|
|
103
|
+
if it must (retrying the connection for about ten seconds), so against a server that stays down the
|
|
104
|
+
call fails about 51 s after its first attempt (as observed). So make that tool idempotent (and
|
|
105
|
+
`hidden_by_default`, as plumbing). Unless the result is an error, the gateway hands its triggers that
|
|
106
|
+
result as that role's call of `report_as.tool` with `report_as.arguments`; a trigger action's own
|
|
107
|
+
call provokes no trigger, and neither does one it declares. `GET /triggers/state` lists each under
|
|
108
|
+
`deferred_calls` (`due` marks one the clock has reached that is still to make, which settle checks
|
|
109
|
+
wait for), and counts the earliest still to make in `next_event_at`. Behind no gateway, or one that
|
|
110
|
+
ignores the key, nothing calls it, so a server still acts by itself once the time has passed (on its
|
|
111
|
+
next read, say).
|
|
112
|
+
|
|
113
|
+
`@tool(..., defers=Defers(call=..., report_as=..., using=...))` builds that declaration for you, and
|
|
114
|
+
the tool returns its reply as before:
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from agentenv_protocol import DeferredCall, Defers, tool
|
|
118
|
+
|
|
119
|
+
@tool(hidden_by_default=True)
|
|
120
|
+
def deliver_reminder(self, reminder_id: str) -> str: ...
|
|
121
|
+
|
|
122
|
+
@tool(defers=Defers(call="deliver_reminder", report_as="send_notification", using="_reminder_delivery"))
|
|
123
|
+
def schedule_reminder(self, event_id: str, remind_at: str) -> str: ...
|
|
124
|
+
|
|
125
|
+
def _reminder_delivery(self, arguments: dict, result) -> DeferredCall | list[DeferredCall] | None:
|
|
126
|
+
if not result.get("ok"):
|
|
127
|
+
return None
|
|
128
|
+
return DeferredCall(key=result["reminder_id"], at=result["remind_at"],
|
|
129
|
+
arguments={"reminder_id": result["reminder_id"]},
|
|
130
|
+
report_arguments={"event_id": arguments["event_id"]})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
After each successful call of the registered tool, the SDK calls `self.<using>(arguments, result)`
|
|
134
|
+
with the call's arguments and the tool's result: a JSON text reply parsed to its dict or list, a dict
|
|
135
|
+
as is, a `CallToolResult`'s `structuredContent` or else its text so parsed, anything else as it is.
|
|
136
|
+
Each `DeferredCall` it returns becomes one entry, with the named tools as its `call` and `report_as`;
|
|
137
|
+
`at` is an aware datetime, epoch seconds or an RFC 3339 string with an offset, declared in UTC. The
|
|
138
|
+
reply's content and structured content are unchanged, and the entries join any `_meta` it has. An
|
|
139
|
+
error reply declares nothing, and a declaration that fails (`using` raises, or returns a wrong type,
|
|
140
|
+
an empty key or an `at` without an offset) is logged and left out rather than breaking the reply.
|
|
141
|
+
The method called in process still returns its plain value. The mount raises unless `call` is a
|
|
142
|
+
`hidden_by_default` tool and `report_as` a tool the environment serves (by served name,
|
|
143
|
+
`{environment_name}` resolved), and `using` a plain method; the card lists both tools under the
|
|
144
|
+
tool's `defers`.
|
|
145
|
+
|
|
93
146
|
`@tool(..., annotations={"readOnlyHint": True}, structured_output=True, meta={...})` lists the tool
|
|
94
147
|
with MCP `ToolAnnotations`, an output schema and `_meta`, on mcp's FastMCP and on fastmcp alike.
|
|
95
148
|
`structured_output` follows mcp's FastMCP (None derives an output schema from the return annotation
|
|
@@ -6,11 +6,14 @@ from .errors import Applied, AgentEnvError
|
|
|
6
6
|
from .preflight import intake_fit_check
|
|
7
7
|
from .tool_client import ToolResult, ToolSession, ToolSessionError
|
|
8
8
|
from .agent_env_environment import (
|
|
9
|
+
DEFERRED_CALLS_META_KEY,
|
|
9
10
|
HIDDEN_BY_DEFAULT_META_KEY,
|
|
10
11
|
AgentEnvApplication,
|
|
11
12
|
AgentEnvEnvironment,
|
|
12
13
|
AgentEnvFastMCPApplication,
|
|
13
14
|
AgentEnvStarletteApplication,
|
|
15
|
+
DeferredCall,
|
|
16
|
+
Defers,
|
|
14
17
|
ForwardedTool,
|
|
15
18
|
add_data,
|
|
16
19
|
agent_skill,
|
|
@@ -114,6 +117,9 @@ __all__ = [
|
|
|
114
117
|
"ROLE_META_KEY",
|
|
115
118
|
"SESSION_META_KEY",
|
|
116
119
|
"HIDDEN_BY_DEFAULT_META_KEY",
|
|
120
|
+
"DEFERRED_CALLS_META_KEY",
|
|
121
|
+
"Defers",
|
|
122
|
+
"DeferredCall",
|
|
117
123
|
"ROLE_HEADER",
|
|
118
124
|
"DEFAULT_ROLE",
|
|
119
125
|
"EnvironmentCapabilities",
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"""Server SDK: decorate a handler's methods with @reset_data/@add_data/@get_data (JSON-RPC data plane at /agentenv; each optional, advertised as capabilities.operations), @extension (card-advertised REST routes), and @tool (MCP tools; FastMCP-backed apps only; a parameter annotated ToolContext receives the caller and is never advertised). Mount onto a FastMCP, Starlette, or FastAPI app via a per-framework AgentEnvApplication subclass — or subclass AgentEnvEnvironment, configure its card with @environment_card(...), and serve() it."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
+
import contextlib
|
|
5
|
+
import contextvars
|
|
6
|
+
import dataclasses
|
|
4
7
|
import datetime
|
|
5
8
|
import decimal
|
|
6
9
|
import enum
|
|
@@ -15,8 +18,8 @@ import sys
|
|
|
15
18
|
import types
|
|
16
19
|
import uuid
|
|
17
20
|
from abc import ABC, abstractmethod
|
|
18
|
-
from typing import (Annotated, Any, Callable, ClassVar, Literal, NamedTuple, Optional, Union, get_args,
|
|
19
|
-
get_type_hints)
|
|
21
|
+
from typing import (Annotated, Any, Callable, ClassVar, Iterator, Literal, NamedTuple, Optional, Union, get_args,
|
|
22
|
+
get_origin, get_type_hints)
|
|
20
23
|
|
|
21
24
|
from pydantic import TypeAdapter, ValidationError
|
|
22
25
|
from pydantic.fields import FieldInfo
|
|
@@ -39,6 +42,7 @@ _EXT_ROUTE_ATTR = "_aee_ext_route"
|
|
|
39
42
|
_EXT_OP_ATTR = "_aee_ext_op"
|
|
40
43
|
_TOOL_ATTR = "_aee_tool"
|
|
41
44
|
_HIDDEN_BY_DEFAULT_ATTR = "_aee_hidden_by_default"
|
|
45
|
+
_DEFERS_ATTR = "_aee_defers"
|
|
42
46
|
_TOOL_OPTIONS_ATTR = "_aee_tool_options"
|
|
43
47
|
_FORWARDED_ATTR = "_aee_forwarded"
|
|
44
48
|
_INSTRUCTIONS_ATTR = "_aee_instructions"
|
|
@@ -49,6 +53,8 @@ _TOOL_CONTEXT_BOUND_ATTR = "__agentenv_tool_context__"
|
|
|
49
53
|
|
|
50
54
|
#: MCP tools/list ``_meta`` key marking a tool a gateway hides from every role until a tool-access step names it.
|
|
51
55
|
HIDDEN_BY_DEFAULT_META_KEY = "agentenv.io/hiddenByDefault"
|
|
56
|
+
#: MCP tools/call result ``_meta`` key by which a server declares calls on itself for a gateway to make later.
|
|
57
|
+
DEFERRED_CALLS_META_KEY = "agentenv.io/deferredCalls"
|
|
52
58
|
|
|
53
59
|
OP_RESET_DATA = "reset_data"
|
|
54
60
|
OP_ADD_DATA = "add_data"
|
|
@@ -195,7 +201,8 @@ def _extension_slug(uri: str) -> str:
|
|
|
195
201
|
|
|
196
202
|
|
|
197
203
|
def tool(name: str | None = None, *, description: str | None = None, hidden_by_default: bool = False,
|
|
198
|
-
annotations: dict | None = None, structured_output: bool | None = None, meta: dict | None = None
|
|
204
|
+
annotations: dict | None = None, structured_output: bool | None = None, meta: dict | None = None,
|
|
205
|
+
defers: Defers | None = None) -> Callable:
|
|
199
206
|
"""Mark a handler method as an MCP tool.
|
|
200
207
|
|
|
201
208
|
At mount the bound method is registered as a real MCP tool on the server app and advertised
|
|
@@ -224,9 +231,23 @@ def tool(name: str | None = None, *, description: str | None = None, hidden_by_d
|
|
|
224
231
|
where it can, True requires one, False lists none; on a fastmcp app it is fastmcp's own inference, off with
|
|
225
232
|
False. A tool returning ``Annotated[CallToolResult, Model]`` sends its result as is on either, listed with
|
|
226
233
|
``Model``'s schema.
|
|
234
|
+
|
|
235
|
+
``defers=Defers(call, report_as, using)`` has each successful reply declare, under ``DEFERRED_CALLS_META_KEY``, the
|
|
236
|
+
calls a gateway is to make on this server later. After the tool returns, the SDK calls
|
|
237
|
+
``self.<using>(arguments, result)`` with the call's arguments as a dict and the tool's result: a JSON text reply
|
|
238
|
+
parsed to its dict or list, a dict as is, a ``CallToolResult``'s structured content or else its text so parsed,
|
|
239
|
+
anything else as it is. It returns a ``DeferredCall``, a list of them, or None for none; each declares a call of
|
|
240
|
+
``call``, reported to the gateway's triggers as a call of ``report_as``. The reply is otherwise what the tool
|
|
241
|
+
returns, and an error reply declares nothing. A declaration that fails (``using`` raises or returns something
|
|
242
|
+
invalid) is logged and left out, so the reply never breaks. Only the registered tool declares: the method called in
|
|
243
|
+
process returns its plain value. ``call`` must be a ``hidden_by_default`` tool and ``report_as`` a tool this
|
|
244
|
+
environment serves, by their served names (``{environment_name}`` resolved), and ``using`` a plain method, or the
|
|
245
|
+
mount raises. The card lists them under the tool's ``defers``.
|
|
227
246
|
"""
|
|
228
247
|
if callable(name):
|
|
229
248
|
raise TypeError("use @tool(...) with parentheses, not bare @tool")
|
|
249
|
+
if defers is not None and not isinstance(defers, Defers):
|
|
250
|
+
raise TypeError(f"defers takes a Defers, not a {type(defers).__name__}")
|
|
230
251
|
|
|
231
252
|
def deco(fn: Callable) -> Callable:
|
|
232
253
|
setattr(fn, _TOOL_ATTR, EnvironmentTool(
|
|
@@ -236,6 +257,8 @@ def tool(name: str | None = None, *, description: str | None = None, hidden_by_d
|
|
|
236
257
|
))
|
|
237
258
|
if hidden_by_default:
|
|
238
259
|
setattr(fn, _HIDDEN_BY_DEFAULT_ATTR, True)
|
|
260
|
+
if defers is not None:
|
|
261
|
+
setattr(fn, _DEFERS_ATTR, defers)
|
|
239
262
|
setattr(fn, _TOOL_OPTIONS_ATTR, _ToolOptions(annotations, structured_output, meta))
|
|
240
263
|
return fn
|
|
241
264
|
|
|
@@ -263,6 +286,29 @@ class ForwardedTool(NamedTuple):
|
|
|
263
286
|
call, tool.get("annotations"), tool.get("outputSchema"), hidden_by_default)
|
|
264
287
|
|
|
265
288
|
|
|
289
|
+
@dataclasses.dataclass(frozen=True)
|
|
290
|
+
class Defers:
|
|
291
|
+
"""What a ``@tool(defers=...)`` defers: ``call``, the hidden tool a gateway calls on this server at each declared
|
|
292
|
+
call's time, ``report_as``, the tool its triggers see that call as, and ``using``, the name of the environment's
|
|
293
|
+
method that builds the calls from each reply (see ``tool``)."""
|
|
294
|
+
|
|
295
|
+
call: str
|
|
296
|
+
report_as: str
|
|
297
|
+
using: str
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
@dataclasses.dataclass(frozen=True)
|
|
301
|
+
class DeferredCall:
|
|
302
|
+
"""One call a ``Defers`` method declares. ``key`` names it on its server, which declaring it again does not
|
|
303
|
+
change; ``at`` is when, as an aware datetime, epoch seconds or an RFC 3339 string with an offset, declared as a UTC
|
|
304
|
+
instant; ``arguments`` are the ``call`` tool's and ``report_arguments`` the ``report_as`` tool's."""
|
|
305
|
+
|
|
306
|
+
key: str
|
|
307
|
+
at: datetime.datetime | int | float | str
|
|
308
|
+
arguments: dict = dataclasses.field(default_factory=dict)
|
|
309
|
+
report_arguments: dict = dataclasses.field(default_factory=dict)
|
|
310
|
+
|
|
311
|
+
|
|
266
312
|
class _ResourceMarker(NamedTuple):
|
|
267
313
|
uri: str
|
|
268
314
|
name: str | None
|
|
@@ -323,11 +369,12 @@ class AgentEnvApplication(ABC):
|
|
|
323
369
|
handler, _with_forwarded(_discover_tools(handler, environment_card.name), handler)))
|
|
324
370
|
if tool_handlers and not self.supports_tools:
|
|
325
371
|
raise ValueError(f"@tool methods require a FastMCP-backed application; {type(self).__name__} cannot serve MCP tools")
|
|
372
|
+
self._defers = _resolved_defers(handler, tool_handlers, environment_card.name)
|
|
326
373
|
self._resources = _discover_resources(handler)
|
|
327
374
|
if self._resources and not self.supports_tools:
|
|
328
375
|
raise ValueError(f"@resource methods require a FastMCP-backed application; {type(self).__name__} cannot "
|
|
329
376
|
"serve MCP resources")
|
|
330
|
-
environment_card = _merge_tools(environment_card, tool_handlers)
|
|
377
|
+
environment_card = _merge_defers(_merge_tools(environment_card, tool_handlers), self._defers)
|
|
331
378
|
self._tool_access = (
|
|
332
379
|
ToolAccess(descriptor.name for descriptor, fn in tool_handlers if getattr(fn, _HIDDEN_BY_DEFAULT_ATTR, False))
|
|
333
380
|
if self.supports_tools and getattr(handler, "tool_access", False) else None
|
|
@@ -439,6 +486,8 @@ class AgentEnvFastMCPApplication(AgentEnvApplication):
|
|
|
439
486
|
elif options.structured_output is False:
|
|
440
487
|
extra["output_schema"] = None
|
|
441
488
|
registered = injecting(fn)
|
|
489
|
+
if (declares := self._defers.get(descriptor.name)) is not None:
|
|
490
|
+
registered = _declaring(registered, declares)
|
|
442
491
|
if fastmcp and _returns_call_tool_result(fn):
|
|
443
492
|
registered, schema = _fastmcp_returning(registered)
|
|
444
493
|
extra["output_schema"] = None if options.structured_output is False else schema
|
|
@@ -502,7 +551,8 @@ class AgentEnvFastMCPApplication(AgentEnvApplication):
|
|
|
502
551
|
raise RuntimeError("this FastMCP app already carries an AgentEnv tool dispatch; mount one handler per app")
|
|
503
552
|
self._binding = "dispatch"
|
|
504
553
|
return
|
|
505
|
-
readers = [descriptor.name for descriptor, fn in self._tools
|
|
554
|
+
readers = [descriptor.name for descriptor, fn in self._tools
|
|
555
|
+
if _tool_context_slot(fn) or descriptor.name in self._defers]
|
|
506
556
|
readers += ["on_tool_call"] if self._hook is not None else []
|
|
507
557
|
readers += ["tool_access"] if self._tool_access is not None else []
|
|
508
558
|
if readers:
|
|
@@ -545,7 +595,7 @@ class AgentEnvFastMCPApplication(AgentEnvApplication):
|
|
|
545
595
|
if manager.get_tool(name) is None:
|
|
546
596
|
return await inner(name, arguments, *args, **kwargs)
|
|
547
597
|
context = kwargs.get("context", args[0] if args else None)
|
|
548
|
-
with bound(context_from_mcp(context, name, arguments)) as tool_context:
|
|
598
|
+
with bound(context_from_mcp(context, name, arguments)) as tool_context, _collecting() as declared:
|
|
549
599
|
try:
|
|
550
600
|
if access is not None:
|
|
551
601
|
access.check_call(tool_context)
|
|
@@ -554,7 +604,9 @@ class AgentEnvFastMCPApplication(AgentEnvApplication):
|
|
|
554
604
|
if answer is not None:
|
|
555
605
|
_check_call_tool_result(answer)
|
|
556
606
|
return answer
|
|
557
|
-
|
|
607
|
+
result = await inner(name, arguments, *args, **kwargs)
|
|
608
|
+
# an unconverted result is the tool's raw value, which has nowhere to carry a declaration
|
|
609
|
+
return _with_declared(result, declared) if kwargs.get("convert_result") else result
|
|
558
610
|
except Exception as e:
|
|
559
611
|
error = _agentenv_error(e)
|
|
560
612
|
if error is None:
|
|
@@ -967,7 +1019,8 @@ def _tool_context_middleware(hook: Callable | None, access: ToolAccess | None =
|
|
|
967
1019
|
async def on_call_tool(self, context: Any, call_next: Callable) -> Any:
|
|
968
1020
|
message = context.message
|
|
969
1021
|
arguments = dict(getattr(message, "arguments", None) or {})
|
|
970
|
-
with bound(context_from_mcp(context.fastmcp_context, message.name, arguments)) as tool_context
|
|
1022
|
+
with (bound(context_from_mcp(context.fastmcp_context, message.name, arguments)) as tool_context,
|
|
1023
|
+
_collecting() as declared):
|
|
971
1024
|
try:
|
|
972
1025
|
if access is not None:
|
|
973
1026
|
access.check_call(tool_context)
|
|
@@ -976,7 +1029,7 @@ def _tool_context_middleware(hook: Callable | None, access: ToolAccess | None =
|
|
|
976
1029
|
if answer is not None:
|
|
977
1030
|
_check_call_tool_result(answer)
|
|
978
1031
|
return _fastmcp_tool_result(answer)
|
|
979
|
-
return await call_next(context)
|
|
1032
|
+
return _with_declared(await call_next(context), declared)
|
|
980
1033
|
except Exception as e:
|
|
981
1034
|
error = _agentenv_error(e)
|
|
982
1035
|
if error is None:
|
|
@@ -1726,3 +1779,180 @@ async def _maybe_await(result: Any) -> Any:
|
|
|
1726
1779
|
if inspect.isawaitable(result):
|
|
1727
1780
|
return await result
|
|
1728
1781
|
return result
|
|
1782
|
+
|
|
1783
|
+
|
|
1784
|
+
class _Declares(NamedTuple):
|
|
1785
|
+
"""A served tool's ``Defers`` as its replies declare it: the tool, the served names it defers, the bound method."""
|
|
1786
|
+
|
|
1787
|
+
tool: str
|
|
1788
|
+
call: str
|
|
1789
|
+
report_as: str
|
|
1790
|
+
using: Callable
|
|
1791
|
+
|
|
1792
|
+
|
|
1793
|
+
def _resolved_defers(handler: Any, tool_handlers: list, environment_name: str) -> dict[str, _Declares]:
|
|
1794
|
+
"""Each served tool's ``Defers`` by tool name, its names resolved as tool names are; one naming a tool the
|
|
1795
|
+
environment does not serve, a ``call`` that is not hidden, or a ``using`` that is not a plain method raises."""
|
|
1796
|
+
served = {descriptor.name: fn for descriptor, fn in tool_handlers}
|
|
1797
|
+
resolved = {}
|
|
1798
|
+
for name, fn in served.items():
|
|
1799
|
+
defers = getattr(fn, _DEFERS_ATTR, None)
|
|
1800
|
+
if defers is None:
|
|
1801
|
+
continue
|
|
1802
|
+
call, report_as = (n.replace(_ENV_NAME_TOKEN, environment_name) for n in (defers.call, defers.report_as))
|
|
1803
|
+
if call not in served:
|
|
1804
|
+
raise ValueError(f"@tool {name!r} defers {call!r}, which is not a tool {environment_name} serves")
|
|
1805
|
+
if not getattr(served[call], _HIDDEN_BY_DEFAULT_ATTR, False):
|
|
1806
|
+
raise ValueError(f"@tool {name!r} defers {call!r}, which is not hidden_by_default: a deferred call is "
|
|
1807
|
+
"plumbing the agent must not see")
|
|
1808
|
+
if report_as not in served:
|
|
1809
|
+
raise ValueError(f"@tool {name!r} reports its deferred calls as {report_as!r}, which is not a tool "
|
|
1810
|
+
f"{environment_name} serves")
|
|
1811
|
+
using = getattr(handler, defers.using, None)
|
|
1812
|
+
if not callable(using):
|
|
1813
|
+
raise ValueError(f"@tool {name!r} builds its deferred calls with {defers.using!r}, which is not a method of "
|
|
1814
|
+
f"{type(handler).__name__}")
|
|
1815
|
+
if inspect.iscoroutinefunction(using):
|
|
1816
|
+
raise ValueError(f"@tool {name!r} builds its deferred calls with {defers.using!r}, a coroutine; it must be "
|
|
1817
|
+
"a plain method")
|
|
1818
|
+
resolved[name] = _Declares(name, call, report_as, using)
|
|
1819
|
+
return resolved
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
def _merge_defers(card: EnvironmentCard, declares: dict[str, _Declares]) -> EnvironmentCard:
|
|
1823
|
+
"""List what each tool defers under its card entry's ``defers``."""
|
|
1824
|
+
if not declares:
|
|
1825
|
+
return card
|
|
1826
|
+
caps = card.capabilities
|
|
1827
|
+
tools = [t.model_copy(update={"defers": {"call": d.call, "report_as": d.report_as}}) if (d := declares.get(t.name))
|
|
1828
|
+
else t for t in caps.tools or []]
|
|
1829
|
+
return card.model_copy(update={"capabilities": caps.model_copy(update={"tools": tools})})
|
|
1830
|
+
|
|
1831
|
+
|
|
1832
|
+
def _declaring(fn: Callable, declares: _Declares) -> Callable:
|
|
1833
|
+
"""``fn`` as registered for a tool that defers: a twin of the same name, doc, sync/async nature, signature and
|
|
1834
|
+
annotations (resolved, since the registry reads them verbatim) that hands each result to ``_declare``."""
|
|
1835
|
+
signature, annotations = _reduced_signature(fn, "")
|
|
1836
|
+
if inspect.iscoroutinefunction(fn):
|
|
1837
|
+
async def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
1838
|
+
result = await fn(*args, **kwargs)
|
|
1839
|
+
_declare(declares, result)
|
|
1840
|
+
return result
|
|
1841
|
+
else:
|
|
1842
|
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
1843
|
+
result = fn(*args, **kwargs)
|
|
1844
|
+
_declare(declares, result)
|
|
1845
|
+
return result
|
|
1846
|
+
functools.update_wrapper(wrapper, fn)
|
|
1847
|
+
wrapper.__signature__, wrapper.__annotations__ = signature, annotations
|
|
1848
|
+
return wrapper
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
def _declare(declares: _Declares, result: Any) -> None:
|
|
1852
|
+
"""Collect the calls ``declares.using`` builds from a tool's result for the dispatch to put on its reply. An error
|
|
1853
|
+
result declares none, and a declaration that fails is logged and left out, so the reply never breaks."""
|
|
1854
|
+
collected = _declared.get()
|
|
1855
|
+
result_type = getattr(sys.modules.get("mcp.types"), "CallToolResult", None)
|
|
1856
|
+
if collected is None or (result_type is not None and isinstance(result, result_type) and result.isError):
|
|
1857
|
+
return
|
|
1858
|
+
try:
|
|
1859
|
+
built = declares.using(dict(ToolContext.current().arguments), _replied(result))
|
|
1860
|
+
entries = [_declared_entry(declares, call) for call in ([] if built is None else
|
|
1861
|
+
built if isinstance(built, list) else [built])]
|
|
1862
|
+
except Exception as e:
|
|
1863
|
+
logger.warning("@tool %r declares no deferred call: %s", declares.tool, e)
|
|
1864
|
+
return
|
|
1865
|
+
collected.extend(entries)
|
|
1866
|
+
|
|
1867
|
+
|
|
1868
|
+
def _replied(result: Any) -> Any:
|
|
1869
|
+
"""A tool's result as its ``using`` receives it: a JSON text reply parsed to its dict or list, a dict as is, a
|
|
1870
|
+
``CallToolResult``'s structured content or else its text so parsed, anything else as it is."""
|
|
1871
|
+
if isinstance(result, str):
|
|
1872
|
+
return _json_container(result, result)
|
|
1873
|
+
result_type = getattr(sys.modules.get("mcp.types"), "CallToolResult", None)
|
|
1874
|
+
if result_type is not None and isinstance(result, result_type):
|
|
1875
|
+
if result.structuredContent is not None:
|
|
1876
|
+
return result.structuredContent
|
|
1877
|
+
return _json_container("\n".join(c.text for c in result.content if getattr(c, "type", None) == "text"), result)
|
|
1878
|
+
return result
|
|
1879
|
+
|
|
1880
|
+
|
|
1881
|
+
def _json_container(text: str, otherwise: Any) -> Any:
|
|
1882
|
+
"""``text`` parsed when it is a JSON object or array, else ``otherwise``."""
|
|
1883
|
+
try:
|
|
1884
|
+
parsed = json.loads(text)
|
|
1885
|
+
except ValueError:
|
|
1886
|
+
return otherwise
|
|
1887
|
+
return parsed if isinstance(parsed, (dict, list)) else otherwise
|
|
1888
|
+
|
|
1889
|
+
|
|
1890
|
+
def _declared_entry(declares: _Declares, call: Any) -> dict:
|
|
1891
|
+
"""One ``DeferredCall`` as the declaration's contract entry, or the error naming what in it breaks the contract."""
|
|
1892
|
+
if not isinstance(call, DeferredCall):
|
|
1893
|
+
raise TypeError(f"using returned a {type(call).__name__}, not a DeferredCall")
|
|
1894
|
+
if not isinstance(call.key, str) or not call.key:
|
|
1895
|
+
raise ValueError(f"a deferred call needs a non-empty string key, not {call.key!r}")
|
|
1896
|
+
if not isinstance(call.arguments, dict) or not isinstance(call.report_arguments, dict):
|
|
1897
|
+
raise TypeError(f"deferred call {call.key!r}: arguments and report_arguments must be dicts")
|
|
1898
|
+
entry = {"key": call.key, "at": _utc_instant(call.at),
|
|
1899
|
+
"call": {"tool": declares.call, "arguments": call.arguments},
|
|
1900
|
+
"report_as": {"tool": declares.report_as, "arguments": call.report_arguments}}
|
|
1901
|
+
try:
|
|
1902
|
+
json.dumps(entry)
|
|
1903
|
+
except (TypeError, ValueError) as e:
|
|
1904
|
+
raise ValueError(f"deferred call {call.key!r} is not JSON: {e}") from None
|
|
1905
|
+
return entry
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
def _utc_instant(at: Any) -> str:
|
|
1909
|
+
"""``at`` as the UTC RFC 3339 instant a declaration carries (``...Z``): an aware datetime, epoch seconds, or an RFC
|
|
1910
|
+
3339 string with an offset, in the grammar a gateway parses; a naive datetime or a string without one is refused."""
|
|
1911
|
+
if isinstance(at, datetime.datetime):
|
|
1912
|
+
if at.utcoffset() is None:
|
|
1913
|
+
raise ValueError(f"at {at.isoformat()!r} has no UTC offset")
|
|
1914
|
+
moment = at
|
|
1915
|
+
elif isinstance(at, (int, float)) and not isinstance(at, bool):
|
|
1916
|
+
moment = datetime.datetime.fromtimestamp(at, datetime.timezone.utc)
|
|
1917
|
+
elif isinstance(at, str):
|
|
1918
|
+
if not _RFC3339_INSTANT.match(at):
|
|
1919
|
+
raise ValueError(f"at {at!r} is not an RFC 3339 instant with an offset (YYYY-MM-DDThh:mm:ss[.fff](Z|+hh:mm))")
|
|
1920
|
+
moment = datetime.datetime.fromisoformat(at[:-1] + "+00:00" if at[-1] in "Zz" else at)
|
|
1921
|
+
else:
|
|
1922
|
+
raise TypeError(f"at {at!r} is not a time: give an aware datetime, epoch seconds or an RFC 3339 string")
|
|
1923
|
+
return moment.astimezone(datetime.timezone.utc).isoformat().replace("+00:00", "Z")
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
# The grammar a gateway's clock parses: fromisoformat alone is looser than RFC 3339.
|
|
1927
|
+
_RFC3339_INSTANT = re.compile(r"^\d{4}-\d{2}-\d{2}[Tt ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$")
|
|
1928
|
+
|
|
1929
|
+
#: The calls the tool of the current dispatch declared, collected for its reply; None outside a dispatch.
|
|
1930
|
+
_declared: contextvars.ContextVar[list | None] = contextvars.ContextVar("agentenv_protocol.declared_calls", default=None)
|
|
1931
|
+
|
|
1932
|
+
|
|
1933
|
+
@contextlib.contextmanager
|
|
1934
|
+
def _collecting() -> Iterator[list]:
|
|
1935
|
+
"""Collect the calls the tool of this dispatch declares, in the list it yields."""
|
|
1936
|
+
collected: list = []
|
|
1937
|
+
token = _declared.set(collected)
|
|
1938
|
+
try:
|
|
1939
|
+
yield collected
|
|
1940
|
+
finally:
|
|
1941
|
+
_declared.reset(token)
|
|
1942
|
+
|
|
1943
|
+
|
|
1944
|
+
def _with_declared(result: Any, declared: list) -> Any:
|
|
1945
|
+
"""A tool's reply with the calls it declared under ``DEFERRED_CALLS_META_KEY``, after any it declared itself and
|
|
1946
|
+
beside any other ``_meta`` it has. mcp's
|
|
1947
|
+
FastMCP replies with content and structured content, content alone, or a ``CallToolResult``; fastmcp with its
|
|
1948
|
+
``ToolResult``."""
|
|
1949
|
+
if not declared:
|
|
1950
|
+
return result
|
|
1951
|
+
if isinstance(result, (tuple, list)):
|
|
1952
|
+
from mcp.types import CallToolResult
|
|
1953
|
+
content, structured = result if isinstance(result, tuple) else (result, None)
|
|
1954
|
+
result = CallToolResult(content=list(content), structuredContent=structured)
|
|
1955
|
+
meta = result.meta or {}
|
|
1956
|
+
own = meta.get(DEFERRED_CALLS_META_KEY)
|
|
1957
|
+
calls = [*own, *declared] if isinstance(own, list) else declared
|
|
1958
|
+
return result.model_copy(update={"meta": {**meta, DEFERRED_CALLS_META_KEY: calls}})
|
|
@@ -185,6 +185,8 @@ class EnvironmentTool(BaseModel):
|
|
|
185
185
|
name: str
|
|
186
186
|
description: Optional[str] = None
|
|
187
187
|
inputSchema: Optional[dict] = None
|
|
188
|
+
# {"call", "report_as"}: the tools of the same server that the calls its replies declare make and are reported as.
|
|
189
|
+
defers: Optional[dict] = None
|
|
188
190
|
|
|
189
191
|
|
|
190
192
|
class EnvironmentCapabilities(BaseModel):
|