nodus-a2a-wire 0.1.0__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.
- nodus_a2a_wire-0.1.0/.gitignore +9 -0
- nodus_a2a_wire-0.1.0/CHANGELOG.md +97 -0
- nodus_a2a_wire-0.1.0/LICENSE +21 -0
- nodus_a2a_wire-0.1.0/PKG-INFO +303 -0
- nodus_a2a_wire-0.1.0/README.md +256 -0
- nodus_a2a_wire-0.1.0/docs/design/00-decisions.md +170 -0
- nodus_a2a_wire-0.1.0/docs/design/01-adapter-mapping.md +254 -0
- nodus_a2a_wire-0.1.0/docs/design/02-message-model.md +407 -0
- nodus_a2a_wire-0.1.0/docs/design/03-transport-http.md +323 -0
- nodus_a2a_wire-0.1.0/docs/design/04-discovery.md +267 -0
- nodus_a2a_wire-0.1.0/docs/design/05-deferred-features.md +229 -0
- nodus_a2a_wire-0.1.0/docs/governance/TECH_DEBT.md +109 -0
- nodus_a2a_wire-0.1.0/pyproject.toml +60 -0
- nodus_a2a_wire-0.1.0/src/nodus_a2a_wire/__init__.py +53 -0
- nodus_a2a_wire-0.1.0/src/nodus_a2a_wire/__main__.py +118 -0
- nodus_a2a_wire-0.1.0/src/nodus_a2a_wire/card.py +112 -0
- nodus_a2a_wire-0.1.0/src/nodus_a2a_wire/codec.py +232 -0
- nodus_a2a_wire-0.1.0/src/nodus_a2a_wire/config.py +19 -0
- nodus_a2a_wire-0.1.0/src/nodus_a2a_wire/errors.py +52 -0
- nodus_a2a_wire-0.1.0/src/nodus_a2a_wire/handler.py +145 -0
- nodus_a2a_wire-0.1.0/src/nodus_a2a_wire/message.py +75 -0
- nodus_a2a_wire-0.1.0/src/nodus_a2a_wire/transport.py +265 -0
- nodus_a2a_wire-0.1.0/tests/__init__.py +0 -0
- nodus_a2a_wire-0.1.0/tests/test_card.py +242 -0
- nodus_a2a_wire-0.1.0/tests/test_handler.py +315 -0
- nodus_a2a_wire-0.1.0/tests/test_integration.py +636 -0
- nodus_a2a_wire-0.1.0/tests/test_invariants.py +509 -0
- nodus_a2a_wire-0.1.0/tests/test_transport.py +449 -0
- nodus_a2a_wire-0.1.0/tests/test_transport_backend.py +286 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to nodus-a2a-wire are documented here.
|
|
4
|
+
|
|
5
|
+
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
|
+
Versioning: [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [Unreleased]
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## [0.1.0] — 2026-08-26
|
|
15
|
+
|
|
16
|
+
First publish. The package existed and was complete since 2026-05-29 but **could
|
|
17
|
+
not be published**: it declared the distribution name `nodus-a2a`, which is taken
|
|
18
|
+
by a different first-party package.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **Distribution renamed `nodus-a2a` -> `nodus-a2a-wire`**, matching the repo.
|
|
23
|
+
|
|
24
|
+
- **Python module renamed `nodus_a2a` -> `nodus_a2a_wire`.** Renaming the
|
|
25
|
+
distribution alone was not enough: the published `nodus-a2a` coordinator ships
|
|
26
|
+
a module *also* called `nodus_a2a`, so installing both wrote one over the
|
|
27
|
+
other. Measured before the fix — installing this package on top of the
|
|
28
|
+
published coordinator left `AgentCoordinator`, `AgentRegistry` and
|
|
29
|
+
`DeadLetterService` gone, with pip reporting success. Both now coexist.
|
|
30
|
+
|
|
31
|
+
- **`nodus-lang` removed from `dependencies`.** Nothing here imports it: a host
|
|
32
|
+
constructs `A2AHttpServer` and wires it to their own
|
|
33
|
+
`NodusRuntime.tool_registry`, so the runtime arrives by injection. Verified by
|
|
34
|
+
installing with `--no-deps` into a clean venv and importing the full API with
|
|
35
|
+
nodus-lang absent. It is now a `dev` extra, for the one test that needs it.
|
|
36
|
+
|
|
37
|
+
The declaration had also pinned `nodus-lang>=4.0.0,<5.0.0`, which would have
|
|
38
|
+
excluded every 5.x release and violated the no-caps policy. The suite passes
|
|
39
|
+
188/188 against nodus-lang 5.5.0.
|
|
40
|
+
|
|
41
|
+
- **Project URLs** now point at `Masterplanner25/nodus-a2a-wire` rather than the
|
|
42
|
+
coordinator's repo.
|
|
43
|
+
|
|
44
|
+
See [nodus-lang#477](https://github.com/Masterplanner25/Nodus/issues/477).
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## [0.1.0-unpublished] — 2026-05-29
|
|
49
|
+
|
|
50
|
+
Initial release — prepare-not-publish (coordinated three-artifact launch with
|
|
51
|
+
nodus-lang 4.0.0 and nodus-mcp 0.1.0).
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- **A2A 1.0.0 message-only server** over HTTP+JSON/REST (`A2AHttpServer`).
|
|
56
|
+
- **std:tool → AgentSkill projection** (`project_skill`, `build_agent_card`):
|
|
57
|
+
tool name, description, tags, and metadata examples projected to AgentSkill;
|
|
58
|
+
deprecated tools excluded.
|
|
59
|
+
- **Agent Card serving** at `/.well-known/agent-card.json` (1.0 well-known URI;
|
|
60
|
+
`agent.json` 0.3-era path returns 404).
|
|
61
|
+
- **Part type dispatch**: tool results automatically dispatched to the correct
|
|
62
|
+
A2A Part variant — `str` → TextPart, `bytes` → RawPart (base64), all other
|
|
63
|
+
JSON-serializable values → DataPart.
|
|
64
|
+
- **Tool-call-envelope dispatch** via `DataPart(data={"tool": "<name>",
|
|
65
|
+
"args": {...}})` with single-tool fallback for single-tool agents.
|
|
66
|
+
- **Bearer auth** (`HTTPAuthSecurityScheme`) — token validator callable in
|
|
67
|
+
`ServerConfig`; dev mode allows all requests when validator is not set.
|
|
68
|
+
- **A2A-Version negotiation** — lenient on missing header, strict on mismatch
|
|
69
|
+
(`VersionNotSupportedError` → HTTP 400); matches Major.Minor, accepts patch.
|
|
70
|
+
- **Error packaging** — tool exceptions are returned as an error DataPart in an
|
|
71
|
+
HTTP 200 response (application errors never become HTTP 5xx).
|
|
72
|
+
- **snake_case ↔ camelCase codec** throughout (`mediaType`, `messageId`,
|
|
73
|
+
`contextId`, `protocolBinding`, etc.); proto field names never leak to wire.
|
|
74
|
+
- **8 standing assertions** (`test_invariants.py`) covering no-new-opcodes,
|
|
75
|
+
no-task-emitted, no-kind-discriminator, no-legacy-wellknown, version-
|
|
76
|
+
negotiation, codec-name-mapping, capability-honesty, and inversion-note.
|
|
77
|
+
- **169 tests** (unit, transport, integration) with 93% source coverage.
|
|
78
|
+
- **CLI entry-point** (`python -m nodus_a2a_wire serve`) for smoke-testing
|
|
79
|
+
connectivity and Agent Card serving.
|
|
80
|
+
|
|
81
|
+
### Design decisions
|
|
82
|
+
|
|
83
|
+
- **D5 (message-only archetype)**: server never emits a Task in v0.1. All
|
|
84
|
+
task-management operations return `UnsupportedOperationError` (HTTP 501).
|
|
85
|
+
- **D6 (inversion note)**: A2A `INPUT_REQUIRED` is the park-and-resume model.
|
|
86
|
+
The nodus-mcp no-thread-parks rule must NOT be imported into a2a v0.2 Task
|
|
87
|
+
lifecycle. This is documented in `docs/design/05-deferred-features.md §2`.
|
|
88
|
+
- **BYTECODE_VERSION**: stays 4. Zero new nodus-lang opcodes introduced.
|
|
89
|
+
|
|
90
|
+
### Deferred to v0.2+
|
|
91
|
+
|
|
92
|
+
Task lifecycle, streaming (`SendStreamingMessage`), push notifications, Agent
|
|
93
|
+
Card signing (D8a), extended/authenticated card (D8b), JSON-RPC binding,
|
|
94
|
+
gRPC, OAuth2/OIDC/mTLS, tenant routing, 0.3 wire-dialect compatibility.
|
|
95
|
+
See `docs/design/05-deferred-features.md` for the full inventory.
|
|
96
|
+
|
|
97
|
+
[0.1.0]: https://github.com/Masterplanner25/nodus-a2a-wire/releases/tag/v0.1.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Masterplanner25
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: nodus-a2a-wire
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A2A 1.0.0 (LF) wire-protocol adapter: agent cards, HTTP+JSON transport, handler dispatch
|
|
5
|
+
Project-URL: Homepage, https://github.com/Masterplanner25/nodus-a2a-wire
|
|
6
|
+
Project-URL: Repository, https://github.com/Masterplanner25/nodus-a2a-wire
|
|
7
|
+
Project-URL: Changelog, https://github.com/Masterplanner25/nodus-a2a-wire/blob/main/CHANGELOG.md
|
|
8
|
+
Author: Shawn Knight
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 Masterplanner25
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
38
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
39
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
40
|
+
Requires-Python: >=3.11
|
|
41
|
+
Provides-Extra: dev
|
|
42
|
+
Requires-Dist: nodus-lang>=4.0.0; extra == 'dev'
|
|
43
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
44
|
+
Provides-Extra: flask
|
|
45
|
+
Requires-Dist: flask>=3.0; extra == 'flask'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# nodus-a2a-wire
|
|
49
|
+
|
|
50
|
+
**A2A 1.0.0 (Linux Foundation) wire-protocol adapter for the [Nodus](https://github.com/Masterplanner25/Nodus) scripting language.**
|
|
51
|
+
|
|
52
|
+
`nodus-a2a-wire` exposes `std:tool`-registered tools from a Nodus runtime as an
|
|
53
|
+
A2A message-only agent over HTTP+JSON/REST — agent cards, transport, and handler
|
|
54
|
+
dispatch.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install nodus-a2a-wire
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Not to be confused with `nodus-a2a`
|
|
61
|
+
|
|
62
|
+
Two different packages, and the names are close:
|
|
63
|
+
|
|
64
|
+
| | What it is |
|
|
65
|
+
|---|---|
|
|
66
|
+
| **`nodus-a2a-wire`** (this one) | the **wire protocol** — `A2AHttpServer`, agent cards, HTTP+JSON transport |
|
|
67
|
+
| [`nodus-a2a`](https://pypi.org/project/nodus-a2a/) | **coordination primitives** — `AgentRegistry`, `AgentCoordinator`, `DeadLetterService`, `StuckRunWatchdog` |
|
|
68
|
+
|
|
69
|
+
They share no code and neither depends on the other. **Both can be installed
|
|
70
|
+
together**: this package's Python module is `nodus_a2a_wire`, the other's is
|
|
71
|
+
`nodus_a2a`.
|
|
72
|
+
|
|
73
|
+
Until 0.1.0 was published this project declared the distribution name
|
|
74
|
+
`nodus-a2a` *and* the module name `nodus_a2a`, which is why it could not be
|
|
75
|
+
published at all — and why installing it alongside the coordinator would have
|
|
76
|
+
silently replaced that package's API. See
|
|
77
|
+
[nodus-lang#477](https://github.com/Masterplanner25/Nodus/issues/477).
|
|
78
|
+
|
|
79
|
+
## Requirements
|
|
80
|
+
|
|
81
|
+
**No runtime dependencies**, including nodus-lang. A host constructs
|
|
82
|
+
`A2AHttpServer` in Python and wires it to their own `NodusRuntime.tool_registry`,
|
|
83
|
+
so the runtime arrives by injection rather than by import.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install nodus-a2a-wire[flask] # optional alternative transport backend
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Production authentication warning
|
|
92
|
+
|
|
93
|
+
**Without a `token_validator`, the server runs in dev mode and accepts all requests.**
|
|
94
|
+
Production deployments must configure a validator:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
config = ServerConfig(
|
|
98
|
+
...
|
|
99
|
+
token_validator=lambda token: token == os.environ["MY_SECRET_TOKEN"],
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Do not expose a nodus-a2a-wire server to the internet without configuring `token_validator`.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## v0.1 scope
|
|
108
|
+
|
|
109
|
+
This is a message-only implementation (D5 decision). The server **never creates A2A Tasks**.
|
|
110
|
+
All task-management operations return HTTP 501. Deferred to v0.2+:
|
|
111
|
+
- Task lifecycle and state machine
|
|
112
|
+
- SSE streaming (`SendStreamingMessage`)
|
|
113
|
+
- Push notification webhooks
|
|
114
|
+
- JSON-RPC and gRPC bindings
|
|
115
|
+
- OAuth 2.0 / OIDC / mTLS auth
|
|
116
|
+
|
|
117
|
+
See `docs/design/05-deferred-features.md` for the full inventory.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Quick start
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from nodus.runtime.embedding import NodusRuntime
|
|
127
|
+
from nodus_a2a_wire import A2AHttpServer, ServerConfig
|
|
128
|
+
|
|
129
|
+
# 1. Create a NodusRuntime and register tools via tool_registry
|
|
130
|
+
runtime = NodusRuntime()
|
|
131
|
+
runtime.tool_registry.register({
|
|
132
|
+
"name": "myapp.greet", # must use dotted namespace: "prefix.name"
|
|
133
|
+
"description": "Greet someone by name",
|
|
134
|
+
"handler": lambda args: f"Hello, {args.get('name', 'world')}!",
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
# 2. Configure the server
|
|
138
|
+
config = ServerConfig(
|
|
139
|
+
base_url="https://myagent.example.com",
|
|
140
|
+
agent_name="My Greeter Agent",
|
|
141
|
+
agent_description="Greets people by name via A2A",
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# 3. Build the tool list and start the server
|
|
145
|
+
tools = runtime.tool_registry.list_tools()
|
|
146
|
+
tool_names = [t["name"] for t in tools if not t.get("deprecated")]
|
|
147
|
+
|
|
148
|
+
server = A2AHttpServer(
|
|
149
|
+
config=config,
|
|
150
|
+
invoke=runtime.tool_registry.invoke,
|
|
151
|
+
tool_names=tool_names,
|
|
152
|
+
tools=tools,
|
|
153
|
+
)
|
|
154
|
+
server.serve() # blocks; use serve_in_thread() for background use
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Calling the agent
|
|
158
|
+
|
|
159
|
+
Send a tool-call envelope in a DataPart:
|
|
160
|
+
|
|
161
|
+
```http
|
|
162
|
+
POST /message:send HTTP/1.1
|
|
163
|
+
Content-Type: application/a2a+json
|
|
164
|
+
A2A-Version: 1.0
|
|
165
|
+
|
|
166
|
+
{
|
|
167
|
+
"message": {
|
|
168
|
+
"messageId": "msg-001",
|
|
169
|
+
"role": "ROLE_USER",
|
|
170
|
+
"parts": [{"data": {"tool": "myapp.greet", "args": {"name": "Alice"}}}]
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Response:
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"message": {
|
|
180
|
+
"messageId": "...",
|
|
181
|
+
"role": "ROLE_AGENT",
|
|
182
|
+
"contextId": "...",
|
|
183
|
+
"parts": [{"text": "Hello, Alice!", "mediaType": "text/plain"}]
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Single-tool shortcut
|
|
189
|
+
|
|
190
|
+
If the agent has exactly one tool registered, any `Message` (even a plain `TextPart`)
|
|
191
|
+
dispatches to that tool with empty args:
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{"message": {"messageId": "m1", "role": "ROLE_USER", "parts": [{"text": "hello"}]}}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Agent Card discovery
|
|
198
|
+
|
|
199
|
+
The Agent Card is served at `/.well-known/agent-card.json` (A2A 1.0 URI).
|
|
200
|
+
No authentication required.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Authentication
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
config = ServerConfig(
|
|
208
|
+
...
|
|
209
|
+
token_validator=lambda token: token == "my-secret-token",
|
|
210
|
+
)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Without a `token_validator`, the server runs in dev mode and accepts all requests.
|
|
214
|
+
**Production deployments must configure a validator.**
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Part type dispatch
|
|
219
|
+
|
|
220
|
+
Tool return values are mapped to A2A Part variants automatically:
|
|
221
|
+
|
|
222
|
+
| Python type | A2A Part | `mediaType` |
|
|
223
|
+
|-------------|----------|-------------|
|
|
224
|
+
| `str` | TextPart | `text/plain` |
|
|
225
|
+
| `bytes` | RawPart (base64) | `application/octet-stream` |
|
|
226
|
+
| dict / list / int / float / bool / None | DataPart | `application/json` |
|
|
227
|
+
|
|
228
|
+
The `url` Part variant is not used in automatic dispatch (reserved for v0.2+).
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Error handling
|
|
233
|
+
|
|
234
|
+
Tool exceptions are returned as an error DataPart in an HTTP 200 response:
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"message": {
|
|
239
|
+
"role": "ROLE_AGENT",
|
|
240
|
+
"parts": [{"data": {"error": "tool exploded", "type": "RuntimeError"},
|
|
241
|
+
"mediaType": "application/json"}]
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Protocol errors (malformed JSON, invalid A2A-Version, missing auth) return
|
|
247
|
+
HTTP 4xx with a structured error body.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Design notes
|
|
252
|
+
|
|
253
|
+
### v0.1 is message-only (D5)
|
|
254
|
+
|
|
255
|
+
The server never creates or persists A2A Tasks. All task-management operations
|
|
256
|
+
(`GetTask`, `ListTasks`, `CancelTask`, streaming, push notifications) return
|
|
257
|
+
HTTP 501 `UnsupportedOperationError`. The Agent Card declares:
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
"capabilities": {"streaming": false, "pushNotifications": false, "extendedAgentCard": false}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### v0.2 Task lifecycle: D6 inversion warning
|
|
264
|
+
|
|
265
|
+
A2A `INPUT_REQUIRED` / `AUTH_REQUIRED` are **park-and-resume** states — the
|
|
266
|
+
opposite of nodus-mcp's no-thread-parks rule. When implementing Task lifecycle
|
|
267
|
+
in v0.2, do **not** import the nodus-mcp no-park assertion. See
|
|
268
|
+
`docs/design/05-deferred-features.md §2` for the full inversion note.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## CLI
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
python -m nodus_a2a_wire --version
|
|
276
|
+
python -m nodus_a2a_wire serve --name "My Agent" --description "..." --port 8080
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
The `serve` command starts a server with no tools — useful for smoke-testing
|
|
280
|
+
network connectivity and verifying the Agent Card format.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Wire format
|
|
285
|
+
|
|
286
|
+
- **Spec:** A2A 1.0.0 / `lf.a2a.v1` (proto package)
|
|
287
|
+
- **Transport:** HTTP+JSON/REST only (`protocolBinding: "HTTP+JSON"`)
|
|
288
|
+
- **Content-Type:** `application/a2a+json`
|
|
289
|
+
- **Discovery:** `/.well-known/agent-card.json`
|
|
290
|
+
- **Version negotiation:** `A2A-Version` request header; mismatch → HTTP 400
|
|
291
|
+
- **Codec:** proto `snake_case` ↔ wire `camelCase` (ProtoJSON)
|
|
292
|
+
- **Signing:** unsigned (v0.1); JWS signing planned for v0.2
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Deferred features (v0.2+)
|
|
297
|
+
|
|
298
|
+
Task lifecycle and state machine, streaming (`SendStreamingMessage`),
|
|
299
|
+
push notification webhooks, Agent Card signing (JWS/RFC 7515), extended
|
|
300
|
+
authenticated card, JSON-RPC binding, gRPC binding, OAuth2/OIDC/mTLS,
|
|
301
|
+
tenant routing, 0.3 wire-dialect compatibility.
|
|
302
|
+
|
|
303
|
+
See `docs/design/05-deferred-features.md` for the full inventory.
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# nodus-a2a-wire
|
|
2
|
+
|
|
3
|
+
**A2A 1.0.0 (Linux Foundation) wire-protocol adapter for the [Nodus](https://github.com/Masterplanner25/Nodus) scripting language.**
|
|
4
|
+
|
|
5
|
+
`nodus-a2a-wire` exposes `std:tool`-registered tools from a Nodus runtime as an
|
|
6
|
+
A2A message-only agent over HTTP+JSON/REST — agent cards, transport, and handler
|
|
7
|
+
dispatch.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install nodus-a2a-wire
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Not to be confused with `nodus-a2a`
|
|
14
|
+
|
|
15
|
+
Two different packages, and the names are close:
|
|
16
|
+
|
|
17
|
+
| | What it is |
|
|
18
|
+
|---|---|
|
|
19
|
+
| **`nodus-a2a-wire`** (this one) | the **wire protocol** — `A2AHttpServer`, agent cards, HTTP+JSON transport |
|
|
20
|
+
| [`nodus-a2a`](https://pypi.org/project/nodus-a2a/) | **coordination primitives** — `AgentRegistry`, `AgentCoordinator`, `DeadLetterService`, `StuckRunWatchdog` |
|
|
21
|
+
|
|
22
|
+
They share no code and neither depends on the other. **Both can be installed
|
|
23
|
+
together**: this package's Python module is `nodus_a2a_wire`, the other's is
|
|
24
|
+
`nodus_a2a`.
|
|
25
|
+
|
|
26
|
+
Until 0.1.0 was published this project declared the distribution name
|
|
27
|
+
`nodus-a2a` *and* the module name `nodus_a2a`, which is why it could not be
|
|
28
|
+
published at all — and why installing it alongside the coordinator would have
|
|
29
|
+
silently replaced that package's API. See
|
|
30
|
+
[nodus-lang#477](https://github.com/Masterplanner25/Nodus/issues/477).
|
|
31
|
+
|
|
32
|
+
## Requirements
|
|
33
|
+
|
|
34
|
+
**No runtime dependencies**, including nodus-lang. A host constructs
|
|
35
|
+
`A2AHttpServer` in Python and wires it to their own `NodusRuntime.tool_registry`,
|
|
36
|
+
so the runtime arrives by injection rather than by import.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install nodus-a2a-wire[flask] # optional alternative transport backend
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Production authentication warning
|
|
45
|
+
|
|
46
|
+
**Without a `token_validator`, the server runs in dev mode and accepts all requests.**
|
|
47
|
+
Production deployments must configure a validator:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
config = ServerConfig(
|
|
51
|
+
...
|
|
52
|
+
token_validator=lambda token: token == os.environ["MY_SECRET_TOKEN"],
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Do not expose a nodus-a2a-wire server to the internet without configuring `token_validator`.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## v0.1 scope
|
|
61
|
+
|
|
62
|
+
This is a message-only implementation (D5 decision). The server **never creates A2A Tasks**.
|
|
63
|
+
All task-management operations return HTTP 501. Deferred to v0.2+:
|
|
64
|
+
- Task lifecycle and state machine
|
|
65
|
+
- SSE streaming (`SendStreamingMessage`)
|
|
66
|
+
- Push notification webhooks
|
|
67
|
+
- JSON-RPC and gRPC bindings
|
|
68
|
+
- OAuth 2.0 / OIDC / mTLS auth
|
|
69
|
+
|
|
70
|
+
See `docs/design/05-deferred-features.md` for the full inventory.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Quick start
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from nodus.runtime.embedding import NodusRuntime
|
|
80
|
+
from nodus_a2a_wire import A2AHttpServer, ServerConfig
|
|
81
|
+
|
|
82
|
+
# 1. Create a NodusRuntime and register tools via tool_registry
|
|
83
|
+
runtime = NodusRuntime()
|
|
84
|
+
runtime.tool_registry.register({
|
|
85
|
+
"name": "myapp.greet", # must use dotted namespace: "prefix.name"
|
|
86
|
+
"description": "Greet someone by name",
|
|
87
|
+
"handler": lambda args: f"Hello, {args.get('name', 'world')}!",
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
# 2. Configure the server
|
|
91
|
+
config = ServerConfig(
|
|
92
|
+
base_url="https://myagent.example.com",
|
|
93
|
+
agent_name="My Greeter Agent",
|
|
94
|
+
agent_description="Greets people by name via A2A",
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# 3. Build the tool list and start the server
|
|
98
|
+
tools = runtime.tool_registry.list_tools()
|
|
99
|
+
tool_names = [t["name"] for t in tools if not t.get("deprecated")]
|
|
100
|
+
|
|
101
|
+
server = A2AHttpServer(
|
|
102
|
+
config=config,
|
|
103
|
+
invoke=runtime.tool_registry.invoke,
|
|
104
|
+
tool_names=tool_names,
|
|
105
|
+
tools=tools,
|
|
106
|
+
)
|
|
107
|
+
server.serve() # blocks; use serve_in_thread() for background use
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Calling the agent
|
|
111
|
+
|
|
112
|
+
Send a tool-call envelope in a DataPart:
|
|
113
|
+
|
|
114
|
+
```http
|
|
115
|
+
POST /message:send HTTP/1.1
|
|
116
|
+
Content-Type: application/a2a+json
|
|
117
|
+
A2A-Version: 1.0
|
|
118
|
+
|
|
119
|
+
{
|
|
120
|
+
"message": {
|
|
121
|
+
"messageId": "msg-001",
|
|
122
|
+
"role": "ROLE_USER",
|
|
123
|
+
"parts": [{"data": {"tool": "myapp.greet", "args": {"name": "Alice"}}}]
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Response:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"message": {
|
|
133
|
+
"messageId": "...",
|
|
134
|
+
"role": "ROLE_AGENT",
|
|
135
|
+
"contextId": "...",
|
|
136
|
+
"parts": [{"text": "Hello, Alice!", "mediaType": "text/plain"}]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Single-tool shortcut
|
|
142
|
+
|
|
143
|
+
If the agent has exactly one tool registered, any `Message` (even a plain `TextPart`)
|
|
144
|
+
dispatches to that tool with empty args:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{"message": {"messageId": "m1", "role": "ROLE_USER", "parts": [{"text": "hello"}]}}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Agent Card discovery
|
|
151
|
+
|
|
152
|
+
The Agent Card is served at `/.well-known/agent-card.json` (A2A 1.0 URI).
|
|
153
|
+
No authentication required.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Authentication
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
config = ServerConfig(
|
|
161
|
+
...
|
|
162
|
+
token_validator=lambda token: token == "my-secret-token",
|
|
163
|
+
)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Without a `token_validator`, the server runs in dev mode and accepts all requests.
|
|
167
|
+
**Production deployments must configure a validator.**
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Part type dispatch
|
|
172
|
+
|
|
173
|
+
Tool return values are mapped to A2A Part variants automatically:
|
|
174
|
+
|
|
175
|
+
| Python type | A2A Part | `mediaType` |
|
|
176
|
+
|-------------|----------|-------------|
|
|
177
|
+
| `str` | TextPart | `text/plain` |
|
|
178
|
+
| `bytes` | RawPart (base64) | `application/octet-stream` |
|
|
179
|
+
| dict / list / int / float / bool / None | DataPart | `application/json` |
|
|
180
|
+
|
|
181
|
+
The `url` Part variant is not used in automatic dispatch (reserved for v0.2+).
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Error handling
|
|
186
|
+
|
|
187
|
+
Tool exceptions are returned as an error DataPart in an HTTP 200 response:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"message": {
|
|
192
|
+
"role": "ROLE_AGENT",
|
|
193
|
+
"parts": [{"data": {"error": "tool exploded", "type": "RuntimeError"},
|
|
194
|
+
"mediaType": "application/json"}]
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Protocol errors (malformed JSON, invalid A2A-Version, missing auth) return
|
|
200
|
+
HTTP 4xx with a structured error body.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Design notes
|
|
205
|
+
|
|
206
|
+
### v0.1 is message-only (D5)
|
|
207
|
+
|
|
208
|
+
The server never creates or persists A2A Tasks. All task-management operations
|
|
209
|
+
(`GetTask`, `ListTasks`, `CancelTask`, streaming, push notifications) return
|
|
210
|
+
HTTP 501 `UnsupportedOperationError`. The Agent Card declares:
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
"capabilities": {"streaming": false, "pushNotifications": false, "extendedAgentCard": false}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### v0.2 Task lifecycle: D6 inversion warning
|
|
217
|
+
|
|
218
|
+
A2A `INPUT_REQUIRED` / `AUTH_REQUIRED` are **park-and-resume** states — the
|
|
219
|
+
opposite of nodus-mcp's no-thread-parks rule. When implementing Task lifecycle
|
|
220
|
+
in v0.2, do **not** import the nodus-mcp no-park assertion. See
|
|
221
|
+
`docs/design/05-deferred-features.md §2` for the full inversion note.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## CLI
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
python -m nodus_a2a_wire --version
|
|
229
|
+
python -m nodus_a2a_wire serve --name "My Agent" --description "..." --port 8080
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The `serve` command starts a server with no tools — useful for smoke-testing
|
|
233
|
+
network connectivity and verifying the Agent Card format.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Wire format
|
|
238
|
+
|
|
239
|
+
- **Spec:** A2A 1.0.0 / `lf.a2a.v1` (proto package)
|
|
240
|
+
- **Transport:** HTTP+JSON/REST only (`protocolBinding: "HTTP+JSON"`)
|
|
241
|
+
- **Content-Type:** `application/a2a+json`
|
|
242
|
+
- **Discovery:** `/.well-known/agent-card.json`
|
|
243
|
+
- **Version negotiation:** `A2A-Version` request header; mismatch → HTTP 400
|
|
244
|
+
- **Codec:** proto `snake_case` ↔ wire `camelCase` (ProtoJSON)
|
|
245
|
+
- **Signing:** unsigned (v0.1); JWS signing planned for v0.2
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Deferred features (v0.2+)
|
|
250
|
+
|
|
251
|
+
Task lifecycle and state machine, streaming (`SendStreamingMessage`),
|
|
252
|
+
push notification webhooks, Agent Card signing (JWS/RFC 7515), extended
|
|
253
|
+
authenticated card, JSON-RPC binding, gRPC binding, OAuth2/OIDC/mTLS,
|
|
254
|
+
tenant routing, 0.3 wire-dialect compatibility.
|
|
255
|
+
|
|
256
|
+
See `docs/design/05-deferred-features.md` for the full inventory.
|