awp-python 0.1.0a1__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 (91) hide show
  1. awp_python-0.1.0a1/.gitignore +15 -0
  2. awp_python-0.1.0a1/.gitmodules +3 -0
  3. awp_python-0.1.0a1/.python-version +1 -0
  4. awp_python-0.1.0a1/CHANGELOG.md +19 -0
  5. awp_python-0.1.0a1/LICENSE +201 -0
  6. awp_python-0.1.0a1/PKG-INFO +127 -0
  7. awp_python-0.1.0a1/README.md +106 -0
  8. awp_python-0.1.0a1/pyproject.toml +81 -0
  9. awp_python-0.1.0a1/scripts/check_traces.py +57 -0
  10. awp_python-0.1.0a1/scripts/sync_spec.py +52 -0
  11. awp_python-0.1.0a1/src/awp/__init__.py +64 -0
  12. awp_python-0.1.0a1/src/awp/_spec/lifecycle.json +190 -0
  13. awp_python-0.1.0a1/src/awp/_spec/schemas/action-cancel-result.schema.json +13 -0
  14. awp_python-0.1.0a1/src/awp/_spec/schemas/action-ref.schema.json +11 -0
  15. awp_python-0.1.0a1/src/awp/_spec/schemas/action-schema.schema.json +37 -0
  16. awp_python-0.1.0a1/src/awp/_spec/schemas/action-status.schema.json +39 -0
  17. awp_python-0.1.0a1/src/awp/_spec/schemas/action-submit-result.schema.json +16 -0
  18. awp_python-0.1.0a1/src/awp/_spec/schemas/action-submit.schema.json +19 -0
  19. awp_python-0.1.0a1/src/awp/_spec/schemas/agent-manifest.schema.json +27 -0
  20. awp_python-0.1.0a1/src/awp/_spec/schemas/approval-requested.schema.json +25 -0
  21. awp_python-0.1.0a1/src/awp/_spec/schemas/approval-respond.schema.json +31 -0
  22. awp_python-0.1.0a1/src/awp/_spec/schemas/common.schema.json +150 -0
  23. awp_python-0.1.0a1/src/awp/_spec/schemas/embodiment.schema.json +22 -0
  24. awp_python-0.1.0a1/src/awp/_spec/schemas/empty-result.schema.json +8 -0
  25. awp_python-0.1.0a1/src/awp/_spec/schemas/error.schema.json +25 -0
  26. awp_python-0.1.0a1/src/awp/_spec/schemas/frame-inline.schema.json +20 -0
  27. awp_python-0.1.0a1/src/awp/_spec/schemas/frame-tree.schema.json +26 -0
  28. awp_python-0.1.0a1/src/awp/_spec/schemas/obs-report.schema.json +40 -0
  29. awp_python-0.1.0a1/src/awp/_spec/schemas/observation-channel.schema.json +28 -0
  30. awp_python-0.1.0a1/src/awp/_spec/schemas/ping-result.schema.json +13 -0
  31. awp_python-0.1.0a1/src/awp/_spec/schemas/ping.schema.json +12 -0
  32. awp_python-0.1.0a1/src/awp/_spec/schemas/profiles/gui-actions.schema.json +57 -0
  33. awp_python-0.1.0a1/src/awp/_spec/schemas/reset-result.schema.json +11 -0
  34. awp_python-0.1.0a1/src/awp/_spec/schemas/reset.schema.json +12 -0
  35. awp_python-0.1.0a1/src/awp/_spec/schemas/restore.schema.json +11 -0
  36. awp_python-0.1.0a1/src/awp/_spec/schemas/safety-policy.schema.json +81 -0
  37. awp_python-0.1.0a1/src/awp/_spec/schemas/session-open.schema.json +41 -0
  38. awp_python-0.1.0a1/src/awp/_spec/schemas/session-ready.schema.json +50 -0
  39. awp_python-0.1.0a1/src/awp/_spec/schemas/session-resume.schema.json +12 -0
  40. awp_python-0.1.0a1/src/awp/_spec/schemas/session-state.schema.json +14 -0
  41. awp_python-0.1.0a1/src/awp/_spec/schemas/session-telemetry.schema.json +22 -0
  42. awp_python-0.1.0a1/src/awp/_spec/schemas/session-transfer-result.schema.json +12 -0
  43. awp_python-0.1.0a1/src/awp/_spec/schemas/session-transfer.schema.json +11 -0
  44. awp_python-0.1.0a1/src/awp/_spec/schemas/snapshot-result.schema.json +11 -0
  45. awp_python-0.1.0a1/src/awp/_spec/schemas/subscribe-result.schema.json +11 -0
  46. awp_python-0.1.0a1/src/awp/_spec/schemas/subscribe.schema.json +11 -0
  47. awp_python-0.1.0a1/src/awp/_spec/schemas/task-update.schema.json +11 -0
  48. awp_python-0.1.0a1/src/awp/_spec/schemas/tick-result.schema.json +9 -0
  49. awp_python-0.1.0a1/src/awp/_spec/schemas/tick.schema.json +12 -0
  50. awp_python-0.1.0a1/src/awp/_spec/schemas/unsubscribe.schema.json +11 -0
  51. awp_python-0.1.0a1/src/awp/_spec/schemas/world-event.schema.json +45 -0
  52. awp_python-0.1.0a1/src/awp/_spec/schemas/world-manifest.schema.json +61 -0
  53. awp_python-0.1.0a1/src/awp/aio.py +380 -0
  54. awp_python-0.1.0a1/src/awp/client.py +781 -0
  55. awp_python-0.1.0a1/src/awp/clock.py +61 -0
  56. awp_python-0.1.0a1/src/awp/errors.py +112 -0
  57. awp_python-0.1.0a1/src/awp/frames.py +174 -0
  58. awp_python-0.1.0a1/src/awp/jsonrpc.py +84 -0
  59. awp_python-0.1.0a1/src/awp/lifecycle.py +78 -0
  60. awp_python-0.1.0a1/src/awp/py.typed +0 -0
  61. awp_python-0.1.0a1/src/awp/schema.py +158 -0
  62. awp_python-0.1.0a1/src/awp_sim/__init__.py +8 -0
  63. awp_python-0.1.0a1/src/awp_sim/__main__.py +5 -0
  64. awp_python-0.1.0a1/src/awp_sim/arm.py +163 -0
  65. awp_python-0.1.0a1/src/awp_sim/audit.py +138 -0
  66. awp_python-0.1.0a1/src/awp_sim/cli.py +238 -0
  67. awp_python-0.1.0a1/src/awp_sim/config.py +225 -0
  68. awp_python-0.1.0a1/src/awp_sim/demo.py +85 -0
  69. awp_python-0.1.0a1/src/awp_sim/loopback.py +222 -0
  70. awp_python-0.1.0a1/src/awp_sim/py.typed +0 -0
  71. awp_python-0.1.0a1/src/awp_sim/recorder.py +72 -0
  72. awp_python-0.1.0a1/src/awp_sim/replay.py +134 -0
  73. awp_python-0.1.0a1/src/awp_sim/scenarios.py +427 -0
  74. awp_python-0.1.0a1/src/awp_sim/server.py +333 -0
  75. awp_python-0.1.0a1/src/awp_sim/session.py +153 -0
  76. awp_python-0.1.0a1/src/awp_sim/world.py +1612 -0
  77. awp_python-0.1.0a1/tests/__init__.py +0 -0
  78. awp_python-0.1.0a1/tests/conftest.py +21 -0
  79. awp_python-0.1.0a1/tests/helpers.py +62 -0
  80. awp_python-0.1.0a1/tests/test_audit.py +62 -0
  81. awp_python-0.1.0a1/tests/test_cli.py +26 -0
  82. awp_python-0.1.0a1/tests/test_client_traces.py +187 -0
  83. awp_python-0.1.0a1/tests/test_e2e.py +118 -0
  84. awp_python-0.1.0a1/tests/test_features.py +297 -0
  85. awp_python-0.1.0a1/tests/test_frames.py +73 -0
  86. awp_python-0.1.0a1/tests/test_regressions.py +243 -0
  87. awp_python-0.1.0a1/tests/test_scenarios.py +33 -0
  88. awp_python-0.1.0a1/tests/test_schema.py +67 -0
  89. awp_python-0.1.0a1/tests/test_streams.py +139 -0
  90. awp_python-0.1.0a1/tests/test_world.py +479 -0
  91. awp_python-0.1.0a1/uv.lock +1003 -0
@@ -0,0 +1,15 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv*/
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .coverage
8
+ coverage.xml
9
+ htmlcov/
10
+ .mypy_cache/
11
+ .pytest_cache/
12
+ .ruff_cache/
13
+ .DS_Store
14
+ awp-audit/
15
+ traces/
@@ -0,0 +1,3 @@
1
+ [submodule "spec"]
2
+ path = spec
3
+ url = https://github.com/Hyperduality/agent-world-protocol.git
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0a1
4
+
5
+ First release, targeting specification revision `0.1-draft.7`.
6
+
7
+ - The `ws` stream binding: `awp-sim serve --stream-binding ws` offers frames on a stream connection in the binary envelope, and `AsyncClient` uses it when offered, re-establishing it if only the stream drops (AWP-TRN-010..013).
8
+ - Beyond Core, each enabled with `awp-sim serve --features`: `task`, `approval` (the `park` action; approvers connect with `--approver-token`), `blend`, `transfer`, `sim` (seeding, snapshot and restore, replay bundles with `--replay-dir`, and `awp-sim replay`), and `servo` (a command channel). `ClientConnection` gains `update_task`, `transfer`, `reset`, `snapshot`, `restore`, `respond_approval`, and `command`.
9
+ - The lockstep session clock counts advances, so reset and restore, which now move the tick, never move it backward (AWP-TIM-013). Audit records hash frame payloads, not their base64 text.
10
+
11
+ - `awp`: `ClientConnection.submit` refuses action types the session was not granted (AWP-AGT-003); `AsyncClient` treats three heartbeat intervals without a message from the world as a lost connection (AWP-SAF-002).
12
+ - `awp_sim`: channels in modalities the agent did not declare are not granted (AWP-AGM-001); granted rates honor the agent's `max_obs_rate_hz` (AWP-AGM-002); a connection without a session is closed after at least 15 s (AWP-SES-012); `--max-duration-ms`. The demo agent does nothing when `move_to_pose` is not granted.
13
+
14
+ ## 0.1.0.dev0 — unreleased
15
+
16
+ First implementation, targeting specification revision `0.1-draft.5`.
17
+
18
+ - `awp`: sans-IO `ClientConnection`, asyncio `AsyncClient`, binary and inline frame codec, canonical schema validation (receiver and sender forms), the lifecycle transition table, clock synchronization.
19
+ - `awp_sim`: sans-IO world engine for lockstep and streaming, simulated arm, WebSocket server with bearer authentication, audit log, trace recorder, in-process loopback, twelve scripted scenarios, and the `awp-sim` command.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to those parts of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to those parts of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Hyperduality and Agent World Protocol contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.5
2
+ Name: awp-python
3
+ Version: 0.1.0a1
4
+ Summary: Agent World Protocol client protocol layer and reference world for Python.
5
+ Project-URL: Specification, https://www.agentworldprotocol.com
6
+ Project-URL: Source, https://github.com/Hyperduality/awp-python
7
+ Author: Hyperduality
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: jsonschema>=4.23
19
+ Requires-Dist: websockets>=13.0
20
+ Description-Content-Type: text/markdown
21
+
22
+ # awp-python
23
+
24
+ Python implementation of the [Agent World Protocol](https://www.agentworldprotocol.com):
25
+
26
+ - **`awp`** — the client protocol layer. `ClientConnection` is the agent side of AWP as a sans-IO state machine; `awp.aio.AsyncClient` drives it over a WebSocket.
27
+ - **`awp_sim`** — the reference world. A sans-IO world engine with a simulated arm, a WebSocket server, an audit log, and a scenario suite that records wire traces.
28
+
29
+ It targets specification revision **`0.1-draft.7`**, pinned as the `spec/` submodule. This is an alpha: the API will change with the draft.
30
+
31
+ ## Status
32
+
33
+ The world and client target **Core World** and **Core Agent** for both time models, and the world the **sim** profile in lockstep, *self-assessed against 0.1-draft.7*: [awp-conformance](https://github.com/Hyperduality/awp-conformance) reports no failure against any configuration and leaves a few requirements untested. Every recorded trace also passes the spec's own checker, which verifies schemas, the action lifecycle table, idempotency, replay, and frame sequencing.
34
+
35
+ | Implemented | Not implemented |
36
+ |---|---|
37
+ | Lockstep (`on_tick`, `any_session`) and streaming | `barrier` tick authority |
38
+ | Inline and `ws` stream bindings; binary frame codec (all spec vectors) | Other stream bindings (`webrtc`, `webtransport`, `shm`, `grpc`) |
39
+ | Full action lifecycle; preemption (`replace`, `queue`, `reject`, `blend`); idempotency | Standing approvals, grant expiry |
40
+ | Watchdog and safe state, heartbeats, resumption with replay and acknowledgement | Multi-bind and shared control (one embodiment) |
41
+ | Spatial, velocity, and rate envelopes (`command_check`) | Robotics profile (a simulated arm proves nothing physical) |
42
+ | Audit log with redaction and hash chain; e-stop; `world.reset` | |
43
+ | Beyond Core (`--features`): task, approval, transfer, seeding, snapshots, replay bundles, a servo command channel | |
44
+
45
+ ## Quickstart
46
+
47
+ Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/) (Node 20+ only for the trace checker).
48
+
49
+ ```bash
50
+ git clone --recurse-submodules https://github.com/Hyperduality/awp-python
51
+ cd awp-python
52
+ uv sync
53
+ ```
54
+
55
+ Run a world, then drive it with the scripted demo agent:
56
+
57
+ ```bash
58
+ uv run awp-sim serve # streaming world on ws://127.0.0.1:8710
59
+ uv run awp-sim demo # in another terminal
60
+ ```
61
+
62
+ `awp-sim serve --mode lockstep` runs the lockstep world. A token (`--token`, or `$AWP_SIM_TOKEN`) is required on any non-loopback bind, as is TLS (`--tls-cert`, `--tls-key`). Audit logs go to `./awp-audit`; `--record-dir` also writes each session's wire trace. `kill -USR1` engages the e-stop and `kill -USR2` releases it.
63
+
64
+ Run the failure scenarios and check their traces against the spec:
65
+
66
+ ```bash
67
+ uv run awp-sim scenarios --out traces
68
+ uv run python scripts/check_traces.py traces/*.jsonl
69
+ ```
70
+
71
+ ## Using the client
72
+
73
+ With asyncio:
74
+
75
+ ```python
76
+ from awp import ClientConnection
77
+ from awp.aio import AsyncClient
78
+
79
+ conn = ClientConnection({"name": "my-agent", "version": "0.1.0", "vendor": "me"}, ["proprio/json"])
80
+ async with AsyncClient(conn, "ws://127.0.0.1:8710") as client:
81
+ await client.initialize()
82
+ await client.open_session("streaming", embodiment="arm_01", subscribe=["proprio"])
83
+ await client.wait_for(lambda e: "proprio" in client.latest)
84
+ record = await client.submit(
85
+ "move_to_pose",
86
+ {"pose": {"frame": "base", "p_m": [0.3, 0.2, 0.5], "q": [0, 0, 0, 1]}},
87
+ basis=client.latest["proprio"].frame, # the observation this intent rests on
88
+ valid_for_ms=200,
89
+ )
90
+ print((await client.wait_terminal(record.action_id)).state)
91
+ await client.close_session()
92
+ ```
93
+
94
+ Without it, feed `ClientConnection` decoded messages and send what it queues:
95
+
96
+ ```python
97
+ events = conn.receive(message) # typed events: ActionUpdated, FrameReceived, ...
98
+ for out in conn.outgoing(): # messages to send, in order
99
+ transport.send(json.dumps(out))
100
+ ```
101
+
102
+ The connection tracks the action lifecycle against the spec's transition table, deduplicates replayed statuses, keeps the clock offset from heartbeats, and reports any violation by the world as a `ProtocolViolation` event.
103
+
104
+ ## Layout
105
+
106
+ ```
107
+ src/awp/ client protocol layer (sans-IO), asyncio adapter, frame codec, schemas
108
+ src/awp/_spec/ schemas and lifecycle table bundled from spec/ (scripts/sync_spec.py)
109
+ src/awp_sim/ world engine, arm, server, audit log, loopback, scenarios, CLI
110
+ spec/ agent-world-protocol, pinned at spec-v0.1-draft.7
111
+ scripts/ spec sync and trace checking
112
+ ```
113
+
114
+ ## Development
115
+
116
+ ```bash
117
+ uv run ruff check && uv run ruff format --check
118
+ uv run mypy
119
+ uv run pytest --cov
120
+ uv run python scripts/sync_spec.py --check
121
+ ```
122
+
123
+ To move to a new draft revision: check out its tag in `spec/`, run `scripts/sync_spec.py`, update `SPEC_REVISION` in `src/awp/__init__.py`, and fix what the tests report.
124
+
125
+ ## License
126
+
127
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,106 @@
1
+ # awp-python
2
+
3
+ Python implementation of the [Agent World Protocol](https://www.agentworldprotocol.com):
4
+
5
+ - **`awp`** — the client protocol layer. `ClientConnection` is the agent side of AWP as a sans-IO state machine; `awp.aio.AsyncClient` drives it over a WebSocket.
6
+ - **`awp_sim`** — the reference world. A sans-IO world engine with a simulated arm, a WebSocket server, an audit log, and a scenario suite that records wire traces.
7
+
8
+ It targets specification revision **`0.1-draft.7`**, pinned as the `spec/` submodule. This is an alpha: the API will change with the draft.
9
+
10
+ ## Status
11
+
12
+ The world and client target **Core World** and **Core Agent** for both time models, and the world the **sim** profile in lockstep, *self-assessed against 0.1-draft.7*: [awp-conformance](https://github.com/Hyperduality/awp-conformance) reports no failure against any configuration and leaves a few requirements untested. Every recorded trace also passes the spec's own checker, which verifies schemas, the action lifecycle table, idempotency, replay, and frame sequencing.
13
+
14
+ | Implemented | Not implemented |
15
+ |---|---|
16
+ | Lockstep (`on_tick`, `any_session`) and streaming | `barrier` tick authority |
17
+ | Inline and `ws` stream bindings; binary frame codec (all spec vectors) | Other stream bindings (`webrtc`, `webtransport`, `shm`, `grpc`) |
18
+ | Full action lifecycle; preemption (`replace`, `queue`, `reject`, `blend`); idempotency | Standing approvals, grant expiry |
19
+ | Watchdog and safe state, heartbeats, resumption with replay and acknowledgement | Multi-bind and shared control (one embodiment) |
20
+ | Spatial, velocity, and rate envelopes (`command_check`) | Robotics profile (a simulated arm proves nothing physical) |
21
+ | Audit log with redaction and hash chain; e-stop; `world.reset` | |
22
+ | Beyond Core (`--features`): task, approval, transfer, seeding, snapshots, replay bundles, a servo command channel | |
23
+
24
+ ## Quickstart
25
+
26
+ Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/) (Node 20+ only for the trace checker).
27
+
28
+ ```bash
29
+ git clone --recurse-submodules https://github.com/Hyperduality/awp-python
30
+ cd awp-python
31
+ uv sync
32
+ ```
33
+
34
+ Run a world, then drive it with the scripted demo agent:
35
+
36
+ ```bash
37
+ uv run awp-sim serve # streaming world on ws://127.0.0.1:8710
38
+ uv run awp-sim demo # in another terminal
39
+ ```
40
+
41
+ `awp-sim serve --mode lockstep` runs the lockstep world. A token (`--token`, or `$AWP_SIM_TOKEN`) is required on any non-loopback bind, as is TLS (`--tls-cert`, `--tls-key`). Audit logs go to `./awp-audit`; `--record-dir` also writes each session's wire trace. `kill -USR1` engages the e-stop and `kill -USR2` releases it.
42
+
43
+ Run the failure scenarios and check their traces against the spec:
44
+
45
+ ```bash
46
+ uv run awp-sim scenarios --out traces
47
+ uv run python scripts/check_traces.py traces/*.jsonl
48
+ ```
49
+
50
+ ## Using the client
51
+
52
+ With asyncio:
53
+
54
+ ```python
55
+ from awp import ClientConnection
56
+ from awp.aio import AsyncClient
57
+
58
+ conn = ClientConnection({"name": "my-agent", "version": "0.1.0", "vendor": "me"}, ["proprio/json"])
59
+ async with AsyncClient(conn, "ws://127.0.0.1:8710") as client:
60
+ await client.initialize()
61
+ await client.open_session("streaming", embodiment="arm_01", subscribe=["proprio"])
62
+ await client.wait_for(lambda e: "proprio" in client.latest)
63
+ record = await client.submit(
64
+ "move_to_pose",
65
+ {"pose": {"frame": "base", "p_m": [0.3, 0.2, 0.5], "q": [0, 0, 0, 1]}},
66
+ basis=client.latest["proprio"].frame, # the observation this intent rests on
67
+ valid_for_ms=200,
68
+ )
69
+ print((await client.wait_terminal(record.action_id)).state)
70
+ await client.close_session()
71
+ ```
72
+
73
+ Without it, feed `ClientConnection` decoded messages and send what it queues:
74
+
75
+ ```python
76
+ events = conn.receive(message) # typed events: ActionUpdated, FrameReceived, ...
77
+ for out in conn.outgoing(): # messages to send, in order
78
+ transport.send(json.dumps(out))
79
+ ```
80
+
81
+ The connection tracks the action lifecycle against the spec's transition table, deduplicates replayed statuses, keeps the clock offset from heartbeats, and reports any violation by the world as a `ProtocolViolation` event.
82
+
83
+ ## Layout
84
+
85
+ ```
86
+ src/awp/ client protocol layer (sans-IO), asyncio adapter, frame codec, schemas
87
+ src/awp/_spec/ schemas and lifecycle table bundled from spec/ (scripts/sync_spec.py)
88
+ src/awp_sim/ world engine, arm, server, audit log, loopback, scenarios, CLI
89
+ spec/ agent-world-protocol, pinned at spec-v0.1-draft.7
90
+ scripts/ spec sync and trace checking
91
+ ```
92
+
93
+ ## Development
94
+
95
+ ```bash
96
+ uv run ruff check && uv run ruff format --check
97
+ uv run mypy
98
+ uv run pytest --cov
99
+ uv run python scripts/sync_spec.py --check
100
+ ```
101
+
102
+ To move to a new draft revision: check out its tag in `spec/`, run `scripts/sync_spec.py`, update `SPEC_REVISION` in `src/awp/__init__.py`, and fix what the tests report.
103
+
104
+ ## License
105
+
106
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,81 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "awp-python"
7
+ version = "0.1.0a1"
8
+ description = "Agent World Protocol client protocol layer and reference world for Python."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.11"
13
+ authors = [{ name = "Hyperduality" }]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Intended Audience :: Science/Research",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
20
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
21
+ "Typing :: Typed",
22
+ ]
23
+ dependencies = [
24
+ "jsonschema>=4.23",
25
+ "websockets>=13.0",
26
+ ]
27
+
28
+ [project.urls]
29
+ Specification = "https://www.agentworldprotocol.com"
30
+ Source = "https://github.com/Hyperduality/awp-python"
31
+
32
+ [project.scripts]
33
+ awp-sim = "awp_sim.cli:main"
34
+
35
+ [dependency-groups]
36
+ dev = [
37
+ "mypy>=1.13",
38
+ "pytest>=8.3",
39
+ "pytest-asyncio>=0.24",
40
+ "pytest-cov>=6.0",
41
+ "pyyaml>=6.0",
42
+ "ruff>=0.8",
43
+ "types-jsonschema",
44
+ "types-pyyaml",
45
+ ]
46
+
47
+ [tool.hatch.build.targets.wheel]
48
+ packages = ["src/awp", "src/awp_sim"]
49
+
50
+ [tool.hatch.build.targets.sdist]
51
+ exclude = ["/spec", "/.github"]
52
+
53
+ [tool.ruff]
54
+ line-length = 100
55
+ target-version = "py311"
56
+
57
+ [tool.ruff.lint]
58
+ select = ["E", "F", "W", "I", "UP", "B", "SIM", "RUF", "PT", "ASYNC", "C4", "PIE", "RET"]
59
+ ignore = ["ASYNC109"] # awaitables take explicit timeouts, as websockets' own API does
60
+
61
+ [tool.mypy]
62
+ strict = true
63
+ python_version = "3.11"
64
+ files = ["src", "tests", "scripts"]
65
+
66
+ [[tool.mypy.overrides]]
67
+ module = ["tests.*"]
68
+ disallow_untyped_defs = false
69
+ disallow_incomplete_defs = false
70
+ disallow_untyped_calls = false
71
+
72
+ [tool.pytest.ini_options]
73
+ testpaths = ["tests"]
74
+ asyncio_mode = "auto"
75
+ asyncio_default_fixture_loop_scope = "function"
76
+ addopts = "-ra --strict-markers"
77
+ markers = ["slow: real-time scenarios"]
78
+
79
+ [tool.coverage.run]
80
+ source = ["awp", "awp_sim"]
81
+ branch = true
@@ -0,0 +1,57 @@
1
+ """Validate JSON Lines wire traces with the pinned spec's own checker (spec/scripts/validate.mjs).
2
+
3
+ The spec's checker validates every trace under examples/v0.1/traces, so this copies the spec to a
4
+ temporary directory, replaces its traces with the given files, and runs it there.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import shutil
10
+ import subprocess
11
+ import sys
12
+ import tempfile
13
+ from pathlib import Path
14
+
15
+ ROOT = Path(__file__).resolve().parent.parent
16
+ SPEC = ROOT / "spec"
17
+
18
+
19
+ def ensure_node_modules() -> None:
20
+ if not (SPEC / "node_modules").is_dir():
21
+ subprocess.run(["npm", "ci", "--silent"], cwd=SPEC, check=True)
22
+
23
+
24
+ def check(paths: list[Path]) -> int:
25
+ if shutil.which("node") is None or shutil.which("npm") is None:
26
+ print("node and npm are required to run the spec's trace checker", file=sys.stderr)
27
+ return 2
28
+ ensure_node_modules()
29
+ with tempfile.TemporaryDirectory() as tmp:
30
+ work = Path(tmp) / "spec"
31
+ shutil.copytree(SPEC, work, ignore=shutil.ignore_patterns(".git", "node_modules"))
32
+ (work / "node_modules").symlink_to(SPEC / "node_modules")
33
+ traces = work / "examples" / "v0.1" / "traces"
34
+ shutil.rmtree(traces)
35
+ traces.mkdir()
36
+ for p in paths:
37
+ shutil.copy(p, traces / p.name)
38
+ proc = subprocess.run(
39
+ ["node", "scripts/validate.mjs"], cwd=work, capture_output=True, text=True
40
+ )
41
+ lines = (proc.stdout + proc.stderr).splitlines()
42
+ for line in lines:
43
+ if line.startswith(("FAIL", "all checks")) or "trace " in line:
44
+ print(line.replace("examples/v0.1/traces/", ""))
45
+ return proc.returncode
46
+
47
+
48
+ def main() -> int:
49
+ paths = [Path(p) for p in sys.argv[1:]]
50
+ if not paths:
51
+ print("usage: check_traces.py TRACE.jsonl...", file=sys.stderr)
52
+ return 2
53
+ return check(paths)
54
+
55
+
56
+ if __name__ == "__main__":
57
+ sys.exit(main())
@@ -0,0 +1,52 @@
1
+ """Copy the pinned spec's schemas and lifecycle table into the package. `--check` fails on drift."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ import yaml
10
+
11
+ ROOT = Path(__file__).resolve().parent.parent
12
+ SPEC = ROOT / "spec"
13
+ DEST = ROOT / "src" / "awp" / "_spec"
14
+
15
+
16
+ def expected() -> dict[Path, str]:
17
+ files: dict[Path, str] = {}
18
+ schema_dir = SPEC / "schemas" / "v0.1"
19
+ for src in sorted(schema_dir.rglob("*.schema.json")):
20
+ files[DEST / "schemas" / src.relative_to(schema_dir)] = src.read_text()
21
+ table = yaml.safe_load((SPEC / "spec" / "action-lifecycle.yaml").read_text())
22
+ table.pop("pre_execution_cancel", None) # YAML anchor holder, not part of the table
23
+ files[DEST / "lifecycle.json"] = json.dumps(table, indent=2) + "\n"
24
+ return files
25
+
26
+
27
+ def main() -> int:
28
+ if not (SPEC / "schemas").is_dir():
29
+ print("spec/ submodule missing; run `git submodule update --init`", file=sys.stderr)
30
+ return 1
31
+ want = expected()
32
+ have = {p: p.read_text() for p in DEST.rglob("*.json")} if DEST.exists() else {}
33
+ if "--check" in sys.argv:
34
+ drift = sorted(
35
+ str(p.relative_to(ROOT))
36
+ for p in want.keys() | have.keys()
37
+ if want.get(p) != have.get(p)
38
+ )
39
+ for name in drift:
40
+ print(f"DRIFT: {name}; run `python scripts/sync_spec.py`", file=sys.stderr)
41
+ return 1 if drift else 0
42
+ for p in have.keys() - want.keys():
43
+ p.unlink()
44
+ for p, text in want.items():
45
+ p.parent.mkdir(parents=True, exist_ok=True)
46
+ p.write_text(text)
47
+ print(f"synced {len(want)} files into {DEST.relative_to(ROOT)}")
48
+ return 0
49
+
50
+
51
+ if __name__ == "__main__":
52
+ sys.exit(main())