awp-python 0.1.0a1__py3-none-any.whl

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 (71) hide show
  1. awp/__init__.py +64 -0
  2. awp/_spec/lifecycle.json +190 -0
  3. awp/_spec/schemas/action-cancel-result.schema.json +13 -0
  4. awp/_spec/schemas/action-ref.schema.json +11 -0
  5. awp/_spec/schemas/action-schema.schema.json +37 -0
  6. awp/_spec/schemas/action-status.schema.json +39 -0
  7. awp/_spec/schemas/action-submit-result.schema.json +16 -0
  8. awp/_spec/schemas/action-submit.schema.json +19 -0
  9. awp/_spec/schemas/agent-manifest.schema.json +27 -0
  10. awp/_spec/schemas/approval-requested.schema.json +25 -0
  11. awp/_spec/schemas/approval-respond.schema.json +31 -0
  12. awp/_spec/schemas/common.schema.json +150 -0
  13. awp/_spec/schemas/embodiment.schema.json +22 -0
  14. awp/_spec/schemas/empty-result.schema.json +8 -0
  15. awp/_spec/schemas/error.schema.json +25 -0
  16. awp/_spec/schemas/frame-inline.schema.json +20 -0
  17. awp/_spec/schemas/frame-tree.schema.json +26 -0
  18. awp/_spec/schemas/obs-report.schema.json +40 -0
  19. awp/_spec/schemas/observation-channel.schema.json +28 -0
  20. awp/_spec/schemas/ping-result.schema.json +13 -0
  21. awp/_spec/schemas/ping.schema.json +12 -0
  22. awp/_spec/schemas/profiles/gui-actions.schema.json +57 -0
  23. awp/_spec/schemas/reset-result.schema.json +11 -0
  24. awp/_spec/schemas/reset.schema.json +12 -0
  25. awp/_spec/schemas/restore.schema.json +11 -0
  26. awp/_spec/schemas/safety-policy.schema.json +81 -0
  27. awp/_spec/schemas/session-open.schema.json +41 -0
  28. awp/_spec/schemas/session-ready.schema.json +50 -0
  29. awp/_spec/schemas/session-resume.schema.json +12 -0
  30. awp/_spec/schemas/session-state.schema.json +14 -0
  31. awp/_spec/schemas/session-telemetry.schema.json +22 -0
  32. awp/_spec/schemas/session-transfer-result.schema.json +12 -0
  33. awp/_spec/schemas/session-transfer.schema.json +11 -0
  34. awp/_spec/schemas/snapshot-result.schema.json +11 -0
  35. awp/_spec/schemas/subscribe-result.schema.json +11 -0
  36. awp/_spec/schemas/subscribe.schema.json +11 -0
  37. awp/_spec/schemas/task-update.schema.json +11 -0
  38. awp/_spec/schemas/tick-result.schema.json +9 -0
  39. awp/_spec/schemas/tick.schema.json +12 -0
  40. awp/_spec/schemas/unsubscribe.schema.json +11 -0
  41. awp/_spec/schemas/world-event.schema.json +45 -0
  42. awp/_spec/schemas/world-manifest.schema.json +61 -0
  43. awp/aio.py +380 -0
  44. awp/client.py +781 -0
  45. awp/clock.py +61 -0
  46. awp/errors.py +112 -0
  47. awp/frames.py +174 -0
  48. awp/jsonrpc.py +84 -0
  49. awp/lifecycle.py +78 -0
  50. awp/py.typed +0 -0
  51. awp/schema.py +158 -0
  52. awp_python-0.1.0a1.dist-info/METADATA +127 -0
  53. awp_python-0.1.0a1.dist-info/RECORD +71 -0
  54. awp_python-0.1.0a1.dist-info/WHEEL +4 -0
  55. awp_python-0.1.0a1.dist-info/entry_points.txt +2 -0
  56. awp_python-0.1.0a1.dist-info/licenses/LICENSE +201 -0
  57. awp_sim/__init__.py +8 -0
  58. awp_sim/__main__.py +5 -0
  59. awp_sim/arm.py +163 -0
  60. awp_sim/audit.py +138 -0
  61. awp_sim/cli.py +238 -0
  62. awp_sim/config.py +225 -0
  63. awp_sim/demo.py +85 -0
  64. awp_sim/loopback.py +222 -0
  65. awp_sim/py.typed +0 -0
  66. awp_sim/recorder.py +72 -0
  67. awp_sim/replay.py +134 -0
  68. awp_sim/scenarios.py +427 -0
  69. awp_sim/server.py +333 -0
  70. awp_sim/session.py +153 -0
  71. awp_sim/world.py +1612 -0
@@ -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,71 @@
1
+ awp/__init__.py,sha256=WAIY67rB0389FGPq1T-mB0wGsr3iu3ccS5v0h_Uonhg,1464
2
+ awp/aio.py,sha256=6vw0__d2iHJInLRg65-0RNU-kXiIZsXAhnIHInVgXXY,15025
3
+ awp/client.py,sha256=sGzILt6D-ChbfKmR7UPUNoeeIGxC5vd5sd770nOlyYI,29989
4
+ awp/clock.py,sha256=Ck3BMlqurMlSK61bhkYODbsP5SneWa3SsqbutoyAxWo,1865
5
+ awp/errors.py,sha256=5ENIGrv1Xj9Q4k5igkSga14EVAZulYDYpWLO5rCy3-8,3341
6
+ awp/frames.py,sha256=p1YqhDa53b4rxtzPcjH3pbknvvI5ps7Zubl9e9-Plt8,6159
7
+ awp/jsonrpc.py,sha256=e-QjwZeWIUwkmHOIuiM7SQDft5eqrRBBqjApVMVbzgg,2853
8
+ awp/lifecycle.py,sha256=hclxzm21GsVkjiaRei__zkLC864O4A0lR75B2YXy0yU,2234
9
+ awp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ awp/schema.py,sha256=zgYSux2RSUqCne7jc6ygfzMiFtKdQna371rSOGCcOSQ,6407
11
+ awp/_spec/lifecycle.json,sha256=SYXnTDVvgyBeGbNdOoxdYF26X-4AXLSUi6Za58d6OBk,4200
12
+ awp/_spec/schemas/action-cancel-result.schema.json,sha256=5-VF-shZLhJJF8MPFKOCNVtJK2VItkPeVEMb5ETqpXk,533
13
+ awp/_spec/schemas/action-ref.schema.json,sha256=AQq3JV0CqOPQG3FKCFqk4UV8HRGodO9zVUpWVjGe_F0,364
14
+ awp/_spec/schemas/action-schema.schema.json,sha256=k8r92NKzQqiuYdI9flrbTOast_WiYKj-o6KPoVZrDd0,2601
15
+ awp/_spec/schemas/action-status.schema.json,sha256=f4WmvvCwjd0sUqiDDxCVPvKlnQrq2MiB5whBfWrjpHM,1708
16
+ awp/_spec/schemas/action-submit-result.schema.json,sha256=v2jx3t8oZb5nVNNgzO9zkshUE9QWEzU1P07B6Kn6VmI,1409
17
+ awp/_spec/schemas/action-submit.schema.json,sha256=vqc_dVNybmIxlFqcgPNKn3ARO9MRImNTcwbYFpDRwfY,1219
18
+ awp/_spec/schemas/agent-manifest.schema.json,sha256=RQgPh6CBoP0SzN1lJlbYnFE42Eh-IN4LELpNUI5-IC0,1398
19
+ awp/_spec/schemas/approval-requested.schema.json,sha256=73ELQHNFLXDU8qSQFWM_wLiEaDCFev0_O6ur0tzMIbo,995
20
+ awp/_spec/schemas/approval-respond.schema.json,sha256=D3YwJu13TYVmzzSLvw0Cd5-WcFrKCgwoKGhsdF4icWc,1095
21
+ awp/_spec/schemas/common.schema.json,sha256=J32cFaV6aoG89gZylPSxoDL02Pk6KwlxZ5PZXKWiRLc,6814
22
+ awp/_spec/schemas/embodiment.schema.json,sha256=H8Fmxs_YupnHTfJ9k1dilHal9rw12q4PG223T8e4tzM,1598
23
+ awp/_spec/schemas/empty-result.schema.json,sha256=Jz7Goj3FqNop73fYXPPNnGCKdHv84W-7Yl1snjpITE0,364
24
+ awp/_spec/schemas/error.schema.json,sha256=8iWixT3Ct-A4p1w9BA3UQQjYekNCxMObHM_u2JYic9s,966
25
+ awp/_spec/schemas/frame-inline.schema.json,sha256=fVRwoKEBWoJlzEcDI0b5a4suLYf3MEwYWVuurRqecFk,1402
26
+ awp/_spec/schemas/frame-tree.schema.json,sha256=NhbOUDKDbveCinZgHfzr8JogRW41Qg9QltT-ZfMSB1w,942
27
+ awp/_spec/schemas/obs-report.schema.json,sha256=SkxMgfCXUzzZ0-bZPYO8OxuF50cb5AN7j6Zq4mQwoKE,2334
28
+ awp/_spec/schemas/observation-channel.schema.json,sha256=N7o7AseQEgIetDEwUwcsHtSR9BqdVokornNhaYzdR94,1715
29
+ awp/_spec/schemas/ping-result.schema.json,sha256=JZB304jYU7Zrr0LgCkewsvTwdmTj99B5n0gZzKfj36I,677
30
+ awp/_spec/schemas/ping.schema.json,sha256=M1aCqpRL0L68YJXZal0DZkbLg4ADDnt3VflUaNGgXOs,688
31
+ awp/_spec/schemas/reset-result.schema.json,sha256=mdKYV3_Df50-BXyEfI-2XidgHHFzJCJtINOZWDpBCnI,396
32
+ awp/_spec/schemas/reset.schema.json,sha256=XykCfE4-W-LM7urwpV2c-ighgdfUyZPXHNXW1bs78mE,524
33
+ awp/_spec/schemas/restore.schema.json,sha256=y66_TWzrk9IdPeUeOdqYGUo8QbIzPu4GOOLu8O4nsYM,360
34
+ awp/_spec/schemas/safety-policy.schema.json,sha256=DKTBdAInpP6gViuYCKwK8wIAT1XOTWZeqOchceMCPwU,3438
35
+ awp/_spec/schemas/session-open.schema.json,sha256=VANVFRgtzm5KOrvsM_6Z2SvfUhxkbWDbFda1nz96Oak,1859
36
+ awp/_spec/schemas/session-ready.schema.json,sha256=V-_bxQ2R5uMatWbQl4qkT_Cty8I9f2yCK8Rg73ykXJM,3366
37
+ awp/_spec/schemas/session-resume.schema.json,sha256=QQHtDwtqk87aZYDmmzIB3th8xMjoBqBWrIeZih0D5OM,508
38
+ awp/_spec/schemas/session-state.schema.json,sha256=0Kw9lz1Hn8JO-Z8-rbWsUA-DvjX9h3cbvDMu7Hevk6c,753
39
+ awp/_spec/schemas/session-telemetry.schema.json,sha256=xSQwHB3ZcMFJzVT0Bl4f8aAc5ANNJmzydbqA-mCdzQs,1689
40
+ awp/_spec/schemas/session-transfer-result.schema.json,sha256=TzsJKsJNjRFqHnCWZMK0qOHaNdHl3NrZS-pjJ6akbQs,524
41
+ awp/_spec/schemas/session-transfer.schema.json,sha256=Z8oSDSyG6zPnxO7MLkHeI9T856DfL7U4SI6watnm6p8,362
42
+ awp/_spec/schemas/snapshot-result.schema.json,sha256=g3bPZVK3ntmon1b11y5dY7S5eae37VQ8SfnO_-edjC4,434
43
+ awp/_spec/schemas/subscribe-result.schema.json,sha256=eQnQjcR_H60opvi9VgcwYFaG93y273dGP4P74itFwh4,483
44
+ awp/_spec/schemas/subscribe.schema.json,sha256=fg6Jee_31ZJiInGePPeJJrKdC9B4N50VUhXvtn-CHOY,542
45
+ awp/_spec/schemas/task-update.schema.json,sha256=0jS4IC0avvf_4bifxQG3Bf-aDBuaK0sxLef0R5ChRB0,344
46
+ awp/_spec/schemas/tick-result.schema.json,sha256=tb5hsYS71HeRvYOjpJiz0v8RSI9NfCOeg6_KgbgMDsE,332
47
+ awp/_spec/schemas/tick.schema.json,sha256=9CjDeVRHKTfqH9a3wnvjO5-tBLhnJUhAcTv2tGQJvKg,547
48
+ awp/_spec/schemas/unsubscribe.schema.json,sha256=5rCpuoCx9sJbcL_g_YdHvxIWSxCjPzLG1T4SAS1dxOo,419
49
+ awp/_spec/schemas/world-event.schema.json,sha256=BOtiMEpiNiUDhHylyZAizgXw9NU60q03UZ6Bdxgdt9k,1537
50
+ awp/_spec/schemas/world-manifest.schema.json,sha256=E70_0DeJbHmTPvYLWkvjefkpQPW16mEaTvEgZkGVwD8,3471
51
+ awp/_spec/schemas/profiles/gui-actions.schema.json,sha256=9-Djvl9oiW19bak60QsxswV-_SdCbhAbkwrzb5uYEiU,2052
52
+ awp_sim/__init__.py,sha256=a1QhO-sEWhHD-rvxtqFe4K5uYi_Iw-cTiioczSXC6PE,272
53
+ awp_sim/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
54
+ awp_sim/arm.py,sha256=pmSytjP8ykFNUm85Xmnh2MbcRqlVajagSb2Gh5r28cg,6058
55
+ awp_sim/audit.py,sha256=00kS0ujx11kKBDuZKuQzpYtZV09XZCUez9NhBdYmUik,5294
56
+ awp_sim/cli.py,sha256=SQVIRECuW8H5hKNUayYALo7-xdW52JF1NBrvpz3zTSE,8454
57
+ awp_sim/config.py,sha256=ZhhL3mSX1SnX4fEFtc8Gs-aJdh_DeqqsGDsc31G9s4c,9390
58
+ awp_sim/demo.py,sha256=tUIAV6imqbPUqdoVt1Ni4dTdJEhpR6jwH32K4SXgIe0,3218
59
+ awp_sim/loopback.py,sha256=52L_NBukHg1Nl1KhnhhB0TCCVH9HEbq1mq8gAMXTetw,8129
60
+ awp_sim/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
61
+ awp_sim/recorder.py,sha256=dSqdz2AufngLwgygtSYrTjxatxIYyPsnRvFjVQeY9H4,2402
62
+ awp_sim/replay.py,sha256=11GtyO3x1vf67JvKPvU5datyvQvEoYosvj0qSGIPPhk,5101
63
+ awp_sim/scenarios.py,sha256=hwYgCo9dF52L65qEdeuIrH2LEcRWzcQXtEMYYZN2oDk,16838
64
+ awp_sim/server.py,sha256=QvgsqKOa6vvuY_tcw7oyHB0_BIb7qrWv9iSr6lCCTHQ,13177
65
+ awp_sim/session.py,sha256=3gkEftrk-PNrwCz2hNx1_2xXNEouyjBHayhdv-bsTAU,5019
66
+ awp_sim/world.py,sha256=XMhkykL2y3AVaLdPK55Dcu4eK95vA9LRLIaULboAh0A,72431
67
+ awp_python-0.1.0a1.dist-info/METADATA,sha256=fpRc7CLhRBq8Zho8HSBKQgFKITgd8YccHjWvNTLoF4Q,5719
68
+ awp_python-0.1.0a1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
69
+ awp_python-0.1.0a1.dist-info/entry_points.txt,sha256=juYQelQ4XhWiirfq4qJrR20uWdjOOK6_XxSY4rP0z6g,45
70
+ awp_python-0.1.0a1.dist-info/licenses/LICENSE,sha256=oFFLc1htz1Qm3Vcmnpupr2rGfRTE5VOTe-YOqrQ8yGk,11386
71
+ awp_python-0.1.0a1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.4
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ awp-sim = awp_sim.cli:main
@@ -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.
awp_sim/__init__.py ADDED
@@ -0,0 +1,8 @@
1
+ """Agent World Protocol reference world."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("awp-python")
7
+ except PackageNotFoundError: # pragma: no cover - running from a source tree without install
8
+ __version__ = "0.0.0"
awp_sim/__main__.py ADDED
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())
awp_sim/arm.py ADDED
@@ -0,0 +1,163 @@
1
+ """A kinematic end effector: straight-line moves with bounded speed and acceleration.
2
+
3
+ The model is deliberately trivial. It exists to make timing real (moves take time, aborts
4
+ decelerate) so the protocol's execution, interruption, and freshness semantics are exercised.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import math
10
+ from dataclasses import dataclass
11
+ from enum import StrEnum
12
+
13
+ Vec3 = tuple[float, float, float]
14
+
15
+
16
+ class Phase(StrEnum):
17
+ IDLE = "idle"
18
+ MOVING = "moving"
19
+ STOPPING = "stopping"
20
+ SERVO = "servo" # following velocity setpoints from a command channel
21
+
22
+
23
+ @dataclass(slots=True)
24
+ class Arm:
25
+ position: Vec3 = (0.0, 0.0, 0.4)
26
+ accel_mps2: float = 2.0
27
+ phase: Phase = Phase.IDLE
28
+ speed: float = 0.0
29
+ stuck: bool = False # fault injection: aborts never finish
30
+
31
+ _start: Vec3 = (0.0, 0.0, 0.0)
32
+ _target: Vec3 | None = None
33
+ _length: float = 0.0
34
+ _travelled: float = 0.0
35
+ _v_max: float = 0.0
36
+ _servo_target: Vec3 = (0.0, 0.0, 0.0)
37
+ _servo_velocity: Vec3 = (0.0, 0.0, 0.0)
38
+ bounds: tuple[Vec3, Vec3] | None = None
39
+
40
+ @property
41
+ def target(self) -> Vec3 | None:
42
+ return self._target
43
+
44
+ @property
45
+ def progress(self) -> float:
46
+ if self._length == 0:
47
+ return 1.0 if self._target is not None else 0.0
48
+ return min(1.0, self._travelled / self._length)
49
+
50
+ @property
51
+ def at_rest(self) -> bool:
52
+ return self.speed == 0.0 and self.phase is not Phase.MOVING
53
+
54
+ @property
55
+ def velocity(self) -> Vec3:
56
+ if self.phase is Phase.SERVO:
57
+ return self._servo_velocity
58
+ if self._target is None or self._length == 0:
59
+ return (0.0, 0.0, 0.0)
60
+ d = _direction(self._start, self._target, self._length)
61
+ return (d[0] * self.speed, d[1] * self.speed, d[2] * self.speed)
62
+
63
+ def move_to(self, target: Vec3, v_max: float) -> None:
64
+ self._start = self.position
65
+ self._target = target
66
+ self._length = math.dist(self.position, target)
67
+ self._travelled = 0.0
68
+ self._v_max = v_max
69
+ self.phase = Phase.MOVING if self._length > 0 else Phase.IDLE
70
+
71
+ def servo(self) -> None:
72
+ """Follow velocity setpoints (`command`) until stopped."""
73
+ self._servo_velocity = self.velocity if self.phase is not Phase.IDLE else (0.0, 0.0, 0.0)
74
+ self._servo_target = (0.0, 0.0, 0.0)
75
+ self.speed = math.hypot(*self._servo_velocity)
76
+ self._target = None
77
+ self.phase = Phase.SERVO
78
+
79
+ def command(self, v: Vec3) -> None:
80
+ self._servo_target = v
81
+
82
+ def stop(self) -> None:
83
+ """Decelerate to rest along the current path."""
84
+ if self.phase is Phase.SERVO:
85
+ v = self._servo_velocity
86
+ speed = math.hypot(*v)
87
+ self._start = self.position
88
+ if speed == 0:
89
+ self.phase = Phase.IDLE
90
+ return
91
+ ahead = (v[0] / speed, v[1] / speed, v[2] / speed)
92
+ self._target = tuple(p + d for p, d in zip(self.position, ahead, strict=True)) # type: ignore[assignment]
93
+ self._length = 1.0
94
+ self._travelled = 0.0
95
+ self.speed = speed
96
+ self.phase = Phase.STOPPING
97
+ return
98
+ if self.phase is Phase.MOVING or self.speed > 0:
99
+ self.phase = Phase.STOPPING
100
+
101
+ def halt(self) -> None:
102
+ """Stop instantly (e-stop, reset, or a stop that no simulated time will follow)."""
103
+ self.speed = 0.0
104
+ self.phase = Phase.IDLE
105
+
106
+ def reset(self, position: Vec3) -> None:
107
+ self.halt()
108
+ self.position = position
109
+ self._target = None
110
+ self._length = self._travelled = 0.0
111
+
112
+ def step(self, dt_s: float) -> None:
113
+ if dt_s <= 0:
114
+ return
115
+ if self.phase is Phase.SERVO:
116
+ self._step_servo(dt_s)
117
+ return
118
+ if self._target is None:
119
+ return
120
+ if self.phase is Phase.MOVING:
121
+ remaining = self._length - self._travelled
122
+ allowed = min(self._v_max, math.sqrt(2 * self.accel_mps2 * max(remaining, 0.0)))
123
+ self.speed = min(self.speed + self.accel_mps2 * dt_s, allowed)
124
+ self._advance(min(self.speed * dt_s, remaining))
125
+ if self._length - self._travelled <= 1e-9:
126
+ self.speed = 0.0
127
+ self.phase = Phase.IDLE
128
+ elif self.phase is Phase.STOPPING and not self.stuck:
129
+ new_speed = max(0.0, self.speed - self.accel_mps2 * dt_s)
130
+ self._advance(min((self.speed + new_speed) / 2 * dt_s, self._length - self._travelled))
131
+ self.speed = new_speed
132
+ if self.speed == 0.0:
133
+ self.phase = Phase.IDLE
134
+
135
+ def _step_servo(self, dt_s: float) -> None:
136
+ v, goal = self._servo_velocity, self._servo_target
137
+ dv = tuple(g - c for g, c in zip(goal, v, strict=True))
138
+ mag = math.hypot(*dv)
139
+ limit = self.accel_mps2 * dt_s
140
+ if mag > limit:
141
+ dv = tuple(d * limit / mag for d in dv)
142
+ v = (v[0] + dv[0], v[1] + dv[1], v[2] + dv[2])
143
+ p = tuple(pos + vel * dt_s for pos, vel in zip(self.position, v, strict=True))
144
+ if self.bounds is not None:
145
+ lo, hi = self.bounds
146
+ clamped = tuple(min(max(x, a), b) for x, a, b in zip(p, lo, hi, strict=True))
147
+ v = tuple(0.0 if c != x else vel for c, x, vel in zip(clamped, p, v, strict=True)) # type: ignore[assignment]
148
+ p = clamped
149
+ self.position = (p[0], p[1], p[2])
150
+ self._servo_velocity = (v[0], v[1], v[2])
151
+ self.speed = math.hypot(*v)
152
+
153
+ def _advance(self, distance: float) -> None:
154
+ self._travelled += distance
155
+ d = _direction(self._start, self._target or self._start, self._length)
156
+ p = self.position
157
+ self.position = (p[0] + d[0] * distance, p[1] + d[1] * distance, p[2] + d[2] * distance)
158
+
159
+
160
+ def _direction(a: Vec3, b: Vec3, length: float) -> Vec3:
161
+ if length == 0:
162
+ return (0.0, 0.0, 0.0)
163
+ return ((b[0] - a[0]) / length, (b[1] - a[1]) / length, (b[2] - a[2]) / length)