a2a-agent-checker 0.4.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.
- a2a_agent_checker-0.4.0/LICENSE +202 -0
- a2a_agent_checker-0.4.0/PKG-INFO +120 -0
- a2a_agent_checker-0.4.0/README.md +100 -0
- a2a_agent_checker-0.4.0/pyproject.toml +35 -0
- a2a_agent_checker-0.4.0/setup.cfg +4 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker/__init__.py +6 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker/card.py +194 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker/check.py +206 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker/cli.py +54 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker/fetch.py +143 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker/report.schema.json +31 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker/signatures.py +205 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker.egg-info/PKG-INFO +120 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker.egg-info/SOURCES.txt +20 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker.egg-info/dependency_links.txt +1 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker.egg-info/entry_points.txt +2 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker.egg-info/requires.txt +4 -0
- a2a_agent_checker-0.4.0/src/a2a_agent_checker.egg-info/top_level.txt +1 -0
- a2a_agent_checker-0.4.0/tests/test_checker.py +325 -0
- a2a_agent_checker-0.4.0/tests/test_extensions.py +40 -0
- a2a_agent_checker-0.4.0/tests/test_report_schema.py +89 -0
- a2a_agent_checker-0.4.0/tests/test_signatures.py +160 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: a2a-agent-checker
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Check a domain's A2A Agent Card against the v1.0 specification.
|
|
5
|
+
Author: Viktor Lyaskov
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/vix-io/a2a-agent-checker
|
|
8
|
+
Project-URL: Online checker, https://stillopen.work/agents/check
|
|
9
|
+
Keywords: a2a,agent2agent,agent-card,ai-agents,validator
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Software Development :: Testing
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: httpx>=0.27
|
|
17
|
+
Provides-Extra: signatures
|
|
18
|
+
Requires-Dist: cryptography>=42; extra == "signatures"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# a2a-agent-checker
|
|
22
|
+
|
|
23
|
+
[](https://github.com/vix-io/a2a-agent-checker/actions/workflows/test.yml)
|
|
24
|
+
|
|
25
|
+
Check a domain's [A2A](https://a2a-protocol.org) Agent Card against the v1.0
|
|
26
|
+
specification.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
$ a2a-check stillopen.work --probe
|
|
30
|
+
stillopen.work: PASS (StillOpen)
|
|
31
|
+
https://stillopen.work/.well-known/agent-card.json
|
|
32
|
+
info endpoint https://stillopen.work/api/v1/a2a answers JSON-RPC and reports an unknown task correctly (-32001)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
pip install a2a-agent-checker # card and endpoint checks
|
|
39
|
+
pip install "a2a-agent-checker[signatures]" # also verifies card signatures
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
There is also an online version at https://stillopen.work/agents/check.
|
|
43
|
+
|
|
44
|
+
## What it checks
|
|
45
|
+
|
|
46
|
+
- The card exists at `/.well-known/agent-card.json`, over HTTPS, as JSON.
|
|
47
|
+
- Every field v1.0 requires is present and the right type: `name`,
|
|
48
|
+
`description`, `supportedInterfaces`, `version`, `capabilities`,
|
|
49
|
+
`defaultInputModes`, `defaultOutputModes`, `skills`.
|
|
50
|
+
- Each interface is HTTPS, names a known binding (`JSONRPC`, `GRPC`,
|
|
51
|
+
`HTTP+JSON`) and a protocol version.
|
|
52
|
+
- Each skill has an `id`, `name`, `description` and `tags`; ids are unique.
|
|
53
|
+
- Common mistakes: a 0.3-era card (top-level `url`, `preferredTransport`),
|
|
54
|
+
snake_case keys, an endpoint on a different host from the card.
|
|
55
|
+
|
|
56
|
+
With `--probe` it also asks each endpoint on the card's own host for a task
|
|
57
|
+
that cannot exist (`GetTask` with a random id):
|
|
58
|
+
|
|
59
|
+
- **JSONRPC**: a conforming agent answers error `-32001` (TaskNotFound).
|
|
60
|
+
- **HTTP+JSON**: `GET {url}/tasks/{id}` (with the interface's `tenant`
|
|
61
|
+
prefixed when set); a conforming agent answers HTTP 404 with a
|
|
62
|
+
`google.rpc.Status` body whose `ErrorInfo.reason` is `TASK_NOT_FOUND`. A
|
|
63
|
+
bare 404 is reported as a warning, since it is also what a server returns
|
|
64
|
+
for a route that does not exist.
|
|
65
|
+
- **GRPC** is not probed.
|
|
66
|
+
|
|
67
|
+
This is the most harmless call A2A defines: nothing is created or run on the
|
|
68
|
+
other side. The checker never sends `SendMessage`, and never probes an
|
|
69
|
+
endpoint on a different host from the card.
|
|
70
|
+
|
|
71
|
+
Card signatures (spec 8.4) are verified when `cryptography` is installed
|
|
72
|
+
(`pip install "a2a-agent-checker[signatures]"`): the key is fetched from the
|
|
73
|
+
`jku` in each signature's header, and each signature is reported as valid,
|
|
74
|
+
invalid or unverifiable. EdDSA, ES256/384/512, RS256/384/512 and
|
|
75
|
+
PS256/384/512. A key published on the card's own host proves the card is
|
|
76
|
+
unaltered, not who signed it, and the finding says so.
|
|
77
|
+
|
|
78
|
+
Declared extensions (spec 4.6) are listed, and a declaration with no
|
|
79
|
+
absolute `uri`, or a non-boolean `required`, is a warning. A URI with no
|
|
80
|
+
version in its path is pointed out, since a breaking change then has no new
|
|
81
|
+
URI to move to.
|
|
82
|
+
|
|
83
|
+
## Results
|
|
84
|
+
|
|
85
|
+
Each finding is `fail` (a v1.0 client cannot use the card), `warn` (usable,
|
|
86
|
+
but something will trip a client or a person) or `info`. The exit status is
|
|
87
|
+
1 if any domain fails, otherwise 0. `--json` prints machine-readable output,
|
|
88
|
+
described by the JSON Schema that `a2a-check --schema` prints
|
|
89
|
+
(`src/a2a_agent_checker/report.schema.json`). Finding codes are stable
|
|
90
|
+
identifiers; new ones may appear in a minor release, so treat an unknown code
|
|
91
|
+
by its level.
|
|
92
|
+
|
|
93
|
+
## Library
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from a2a_agent_checker import check, validate
|
|
97
|
+
|
|
98
|
+
report = check("example.com", probe=True)
|
|
99
|
+
print(report.verdict, [f.message for f in report.findings])
|
|
100
|
+
|
|
101
|
+
findings = validate(card_dict, "https://example.com/.well-known/agent-card.json")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Safe to run on untrusted input
|
|
105
|
+
|
|
106
|
+
The checker is built to sit behind a public web form, so every URL is
|
|
107
|
+
treated as hostile:
|
|
108
|
+
|
|
109
|
+
- HTTPS on port 443 only; no IP literals, no credentials in URLs.
|
|
110
|
+
- The name is resolved once, every address must be public, and the
|
|
111
|
+
connection goes to that checked address (the name is kept for TLS). This
|
|
112
|
+
closes the DNS-rebinding gap where a second lookup returns `127.0.0.1`.
|
|
113
|
+
- Redirects are followed by hand, each hop re-checked, at most 3.
|
|
114
|
+
- 10-second timeouts and a 256 KB response cap.
|
|
115
|
+
|
|
116
|
+
Rate-limiting visitors is the host application's job.
|
|
117
|
+
|
|
118
|
+
## Licence
|
|
119
|
+
|
|
120
|
+
Apache 2.0.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# a2a-agent-checker
|
|
2
|
+
|
|
3
|
+
[](https://github.com/vix-io/a2a-agent-checker/actions/workflows/test.yml)
|
|
4
|
+
|
|
5
|
+
Check a domain's [A2A](https://a2a-protocol.org) Agent Card against the v1.0
|
|
6
|
+
specification.
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
$ a2a-check stillopen.work --probe
|
|
10
|
+
stillopen.work: PASS (StillOpen)
|
|
11
|
+
https://stillopen.work/.well-known/agent-card.json
|
|
12
|
+
info endpoint https://stillopen.work/api/v1/a2a answers JSON-RPC and reports an unknown task correctly (-32001)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
pip install a2a-agent-checker # card and endpoint checks
|
|
19
|
+
pip install "a2a-agent-checker[signatures]" # also verifies card signatures
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
There is also an online version at https://stillopen.work/agents/check.
|
|
23
|
+
|
|
24
|
+
## What it checks
|
|
25
|
+
|
|
26
|
+
- The card exists at `/.well-known/agent-card.json`, over HTTPS, as JSON.
|
|
27
|
+
- Every field v1.0 requires is present and the right type: `name`,
|
|
28
|
+
`description`, `supportedInterfaces`, `version`, `capabilities`,
|
|
29
|
+
`defaultInputModes`, `defaultOutputModes`, `skills`.
|
|
30
|
+
- Each interface is HTTPS, names a known binding (`JSONRPC`, `GRPC`,
|
|
31
|
+
`HTTP+JSON`) and a protocol version.
|
|
32
|
+
- Each skill has an `id`, `name`, `description` and `tags`; ids are unique.
|
|
33
|
+
- Common mistakes: a 0.3-era card (top-level `url`, `preferredTransport`),
|
|
34
|
+
snake_case keys, an endpoint on a different host from the card.
|
|
35
|
+
|
|
36
|
+
With `--probe` it also asks each endpoint on the card's own host for a task
|
|
37
|
+
that cannot exist (`GetTask` with a random id):
|
|
38
|
+
|
|
39
|
+
- **JSONRPC**: a conforming agent answers error `-32001` (TaskNotFound).
|
|
40
|
+
- **HTTP+JSON**: `GET {url}/tasks/{id}` (with the interface's `tenant`
|
|
41
|
+
prefixed when set); a conforming agent answers HTTP 404 with a
|
|
42
|
+
`google.rpc.Status` body whose `ErrorInfo.reason` is `TASK_NOT_FOUND`. A
|
|
43
|
+
bare 404 is reported as a warning, since it is also what a server returns
|
|
44
|
+
for a route that does not exist.
|
|
45
|
+
- **GRPC** is not probed.
|
|
46
|
+
|
|
47
|
+
This is the most harmless call A2A defines: nothing is created or run on the
|
|
48
|
+
other side. The checker never sends `SendMessage`, and never probes an
|
|
49
|
+
endpoint on a different host from the card.
|
|
50
|
+
|
|
51
|
+
Card signatures (spec 8.4) are verified when `cryptography` is installed
|
|
52
|
+
(`pip install "a2a-agent-checker[signatures]"`): the key is fetched from the
|
|
53
|
+
`jku` in each signature's header, and each signature is reported as valid,
|
|
54
|
+
invalid or unverifiable. EdDSA, ES256/384/512, RS256/384/512 and
|
|
55
|
+
PS256/384/512. A key published on the card's own host proves the card is
|
|
56
|
+
unaltered, not who signed it, and the finding says so.
|
|
57
|
+
|
|
58
|
+
Declared extensions (spec 4.6) are listed, and a declaration with no
|
|
59
|
+
absolute `uri`, or a non-boolean `required`, is a warning. A URI with no
|
|
60
|
+
version in its path is pointed out, since a breaking change then has no new
|
|
61
|
+
URI to move to.
|
|
62
|
+
|
|
63
|
+
## Results
|
|
64
|
+
|
|
65
|
+
Each finding is `fail` (a v1.0 client cannot use the card), `warn` (usable,
|
|
66
|
+
but something will trip a client or a person) or `info`. The exit status is
|
|
67
|
+
1 if any domain fails, otherwise 0. `--json` prints machine-readable output,
|
|
68
|
+
described by the JSON Schema that `a2a-check --schema` prints
|
|
69
|
+
(`src/a2a_agent_checker/report.schema.json`). Finding codes are stable
|
|
70
|
+
identifiers; new ones may appear in a minor release, so treat an unknown code
|
|
71
|
+
by its level.
|
|
72
|
+
|
|
73
|
+
## Library
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from a2a_agent_checker import check, validate
|
|
77
|
+
|
|
78
|
+
report = check("example.com", probe=True)
|
|
79
|
+
print(report.verdict, [f.message for f in report.findings])
|
|
80
|
+
|
|
81
|
+
findings = validate(card_dict, "https://example.com/.well-known/agent-card.json")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Safe to run on untrusted input
|
|
85
|
+
|
|
86
|
+
The checker is built to sit behind a public web form, so every URL is
|
|
87
|
+
treated as hostile:
|
|
88
|
+
|
|
89
|
+
- HTTPS on port 443 only; no IP literals, no credentials in URLs.
|
|
90
|
+
- The name is resolved once, every address must be public, and the
|
|
91
|
+
connection goes to that checked address (the name is kept for TLS). This
|
|
92
|
+
closes the DNS-rebinding gap where a second lookup returns `127.0.0.1`.
|
|
93
|
+
- Redirects are followed by hand, each hop re-checked, at most 3.
|
|
94
|
+
- 10-second timeouts and a 256 KB response cap.
|
|
95
|
+
|
|
96
|
+
Rate-limiting visitors is the host application's job.
|
|
97
|
+
|
|
98
|
+
## Licence
|
|
99
|
+
|
|
100
|
+
Apache 2.0.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "a2a-agent-checker"
|
|
7
|
+
version = "0.4.0"
|
|
8
|
+
description = "Check a domain's A2A Agent Card against the v1.0 specification."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
dependencies = ["httpx>=0.27"]
|
|
13
|
+
authors = [{name = "Viktor Lyaskov"}]
|
|
14
|
+
keywords = ["a2a", "agent2agent", "agent-card", "ai-agents", "validator"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: Software Development :: Testing",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
signatures = ["cryptography>=42"]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://github.com/vix-io/a2a-agent-checker"
|
|
26
|
+
"Online checker" = "https://stillopen.work/agents/check"
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
a2a-check = "a2a_agent_checker.cli:main"
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.packages.find]
|
|
32
|
+
where = ["src"]
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.package-data]
|
|
35
|
+
a2a_agent_checker = ["report.schema.json"]
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""Validating an Agent Card against A2A v1.0.
|
|
2
|
+
|
|
3
|
+
Pure and offline: `validate(card, card_url)` takes parsed JSON and returns
|
|
4
|
+
findings. Nothing here touches the network, so every rule is testable against
|
|
5
|
+
a fixture.
|
|
6
|
+
|
|
7
|
+
Three levels, and the line between them is the point:
|
|
8
|
+
|
|
9
|
+
* **fail** - a v1.0 client cannot use the card (a required field missing or
|
|
10
|
+
the wrong type).
|
|
11
|
+
* **warn** - usable, but something a client or a person will trip on: a
|
|
12
|
+
0.3-era field, an interface on another host, a duplicate skill id.
|
|
13
|
+
* **info** - true and worth saying, and not a fault: a signature present
|
|
14
|
+
an optional field absent. Signatures are verified in `signatures.py`,
|
|
15
|
+
which needs the network to fetch the key.
|
|
16
|
+
"""
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import re
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from urllib.parse import urlsplit
|
|
22
|
+
|
|
23
|
+
PROTOCOL_VERSION = "1.0"
|
|
24
|
+
BINDINGS = {"JSONRPC", "GRPC", "HTTP+JSON"}
|
|
25
|
+
REQUIRED = ("name", "description", "supportedInterfaces", "version",
|
|
26
|
+
"capabilities", "defaultInputModes", "defaultOutputModes", "skills")
|
|
27
|
+
# Fields a 0.3 card carried at the top level and v1.0 moved into
|
|
28
|
+
# supportedInterfaces. Their presence is how an older card is recognised.
|
|
29
|
+
LEGACY_FIELDS = ("url", "preferredTransport", "additionalInterfaces", "protocolVersion")
|
|
30
|
+
SNAKE = re.compile(r"^[a-z]+(_[a-z0-9]+)+$")
|
|
31
|
+
MEDIA_TYPE = re.compile(r"^[\w.+-]+/[\w.+-]+$")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass(frozen=True)
|
|
35
|
+
class Finding:
|
|
36
|
+
level: str # fail | warn | info
|
|
37
|
+
code: str
|
|
38
|
+
message: str
|
|
39
|
+
|
|
40
|
+
def as_dict(self) -> dict:
|
|
41
|
+
return {"level": self.level, "code": self.code, "message": self.message}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _is_text(v) -> bool:
|
|
45
|
+
return isinstance(v, str) and v.strip() != ""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _string_list(v) -> bool:
|
|
49
|
+
return isinstance(v, list) and len(v) > 0 and all(_is_text(x) for x in v)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _snake_keys(obj, path="") -> list[str]:
|
|
53
|
+
found = []
|
|
54
|
+
if isinstance(obj, dict):
|
|
55
|
+
for k, v in obj.items():
|
|
56
|
+
if SNAKE.match(k):
|
|
57
|
+
found.append(path + k)
|
|
58
|
+
found += _snake_keys(v, f"{path}{k}.")
|
|
59
|
+
elif isinstance(obj, list):
|
|
60
|
+
for i, v in enumerate(obj):
|
|
61
|
+
found += _snake_keys(v, f"{path}[{i}].")
|
|
62
|
+
return found
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
VERSIONED = re.compile(r"/v\d+(\.\d+)*/?$")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _extensions(exts, warn, info) -> None:
|
|
69
|
+
"""Spec 4.6: each declaration names its extension by URI, and a breaking
|
|
70
|
+
change must get a new URI, so the version belongs in it (4.6.3)."""
|
|
71
|
+
if not isinstance(exts, list):
|
|
72
|
+
warn("extension-malformed", "'capabilities.extensions' must be a list")
|
|
73
|
+
return
|
|
74
|
+
for i, ext in enumerate(exts, 1):
|
|
75
|
+
if not isinstance(ext, dict):
|
|
76
|
+
warn("extension-malformed", f"extension {i} is not an object")
|
|
77
|
+
continue
|
|
78
|
+
uri = ext.get("uri")
|
|
79
|
+
p = urlsplit(uri) if isinstance(uri, str) else None
|
|
80
|
+
if not p or not p.scheme or not (p.netloc or p.scheme == "urn"):
|
|
81
|
+
warn("extension-malformed", f"extension {i} has no absolute 'uri'")
|
|
82
|
+
continue
|
|
83
|
+
if "required" in ext and not isinstance(ext["required"], bool):
|
|
84
|
+
warn("extension-malformed", f"{uri}: 'required' must be true or false")
|
|
85
|
+
if not VERSIONED.search(p.path or ""):
|
|
86
|
+
info("extension-unversioned", f"{uri} carries no version in its path; "
|
|
87
|
+
"a breaking change then has no new URI to move to (4.6.3)")
|
|
88
|
+
req = " (required)" if ext.get("required") is True else ""
|
|
89
|
+
info("extension", f"declares {uri}{req}")
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def validate(card, card_url: str | None = None) -> list[Finding]:
|
|
93
|
+
out: list[Finding] = []
|
|
94
|
+
fail = lambda c, m: out.append(Finding("fail", c, m))
|
|
95
|
+
warn = lambda c, m: out.append(Finding("warn", c, m))
|
|
96
|
+
info = lambda c, m: out.append(Finding("info", c, m))
|
|
97
|
+
|
|
98
|
+
if not isinstance(card, dict):
|
|
99
|
+
fail("not-an-object", "the Agent Card is not a JSON object")
|
|
100
|
+
return out
|
|
101
|
+
|
|
102
|
+
missing = [k for k in REQUIRED if k not in card]
|
|
103
|
+
for k in missing:
|
|
104
|
+
fail("missing-field", f"required field '{k}' is missing")
|
|
105
|
+
|
|
106
|
+
legacy = [k for k in LEGACY_FIELDS if k in card]
|
|
107
|
+
if legacy:
|
|
108
|
+
(fail if "supportedInterfaces" in missing else warn)(
|
|
109
|
+
"legacy-card",
|
|
110
|
+
"looks like an A2A 0.3 card (top-level " + ", ".join(legacy)
|
|
111
|
+
+ "); v1.0 lists endpoints in 'supportedInterfaces'")
|
|
112
|
+
|
|
113
|
+
for k in ("name", "description", "version"):
|
|
114
|
+
if k in card and not _is_text(card[k]):
|
|
115
|
+
fail("bad-type", f"'{k}' must be a non-empty string")
|
|
116
|
+
|
|
117
|
+
if "capabilities" in card and not isinstance(card["capabilities"], dict):
|
|
118
|
+
fail("bad-type", "'capabilities' must be an object")
|
|
119
|
+
elif isinstance(card.get("capabilities"), dict) and "extensions" in card["capabilities"]:
|
|
120
|
+
_extensions(card["capabilities"]["extensions"], warn, info)
|
|
121
|
+
|
|
122
|
+
for k in ("defaultInputModes", "defaultOutputModes"):
|
|
123
|
+
if k in card:
|
|
124
|
+
if not _string_list(card[k]):
|
|
125
|
+
fail("bad-type", f"'{k}' must be a non-empty list of media types")
|
|
126
|
+
else:
|
|
127
|
+
odd = [m for m in card[k] if not MEDIA_TYPE.match(m)]
|
|
128
|
+
if odd:
|
|
129
|
+
warn("media-type", f"'{k}' has values that are not media types: {odd}")
|
|
130
|
+
|
|
131
|
+
host = (urlsplit(card_url).hostname or "").lower() if card_url else ""
|
|
132
|
+
ifaces = card.get("supportedInterfaces")
|
|
133
|
+
if "supportedInterfaces" in card:
|
|
134
|
+
if not isinstance(ifaces, list) or not ifaces:
|
|
135
|
+
fail("bad-type", "'supportedInterfaces' must be a non-empty list")
|
|
136
|
+
ifaces = []
|
|
137
|
+
for i, iface in enumerate(ifaces):
|
|
138
|
+
where = f"supportedInterfaces[{i}]"
|
|
139
|
+
if not isinstance(iface, dict):
|
|
140
|
+
fail("bad-type", f"{where} must be an object")
|
|
141
|
+
continue
|
|
142
|
+
url = iface.get("url")
|
|
143
|
+
if not _is_text(url):
|
|
144
|
+
fail("missing-field", f"{where}.url is missing")
|
|
145
|
+
else:
|
|
146
|
+
parts = urlsplit(url)
|
|
147
|
+
if parts.scheme != "https":
|
|
148
|
+
fail("insecure-url", f"{where}.url is not https: {url}")
|
|
149
|
+
elif host and (parts.hostname or "").lower() != host:
|
|
150
|
+
warn("other-host", f"{where}.url is on {parts.hostname}, not {host}"
|
|
151
|
+
" - fine if intended, but a client cannot tell it apart from a"
|
|
152
|
+
" card pointing somewhere it should not")
|
|
153
|
+
binding = iface.get("protocolBinding")
|
|
154
|
+
if binding not in BINDINGS:
|
|
155
|
+
fail("bad-binding", f"{where}.protocolBinding is {binding!r}; expected one of "
|
|
156
|
+
+ ", ".join(sorted(BINDINGS)))
|
|
157
|
+
version = iface.get("protocolVersion")
|
|
158
|
+
if not _is_text(version):
|
|
159
|
+
fail("missing-field", f"{where}.protocolVersion is missing")
|
|
160
|
+
elif version.split(".")[0] != PROTOCOL_VERSION.split(".")[0]:
|
|
161
|
+
warn("old-version", f"{where}.protocolVersion is {version}; current is {PROTOCOL_VERSION}")
|
|
162
|
+
|
|
163
|
+
skills = card.get("skills")
|
|
164
|
+
if "skills" in card:
|
|
165
|
+
if not isinstance(skills, list) or not skills:
|
|
166
|
+
fail("bad-type", "'skills' must be a non-empty list")
|
|
167
|
+
skills = []
|
|
168
|
+
ids = []
|
|
169
|
+
for i, skill in enumerate(skills):
|
|
170
|
+
where = f"skills[{i}]"
|
|
171
|
+
if not isinstance(skill, dict):
|
|
172
|
+
fail("bad-type", f"{where} must be an object")
|
|
173
|
+
continue
|
|
174
|
+
for k in ("id", "name", "description"):
|
|
175
|
+
if not _is_text(skill.get(k)):
|
|
176
|
+
fail("missing-field", f"{where}.{k} is missing or empty")
|
|
177
|
+
if not isinstance(skill.get("tags"), list):
|
|
178
|
+
fail("missing-field", f"{where}.tags must be a list")
|
|
179
|
+
if _is_text(skill.get("id")):
|
|
180
|
+
ids.append(skill["id"])
|
|
181
|
+
dupes = sorted({s for s in ids if ids.count(s) > 1})
|
|
182
|
+
if dupes:
|
|
183
|
+
warn("duplicate-skill", f"skill ids appear more than once: {dupes}")
|
|
184
|
+
|
|
185
|
+
snake = _snake_keys(card)
|
|
186
|
+
if snake:
|
|
187
|
+
warn("snake-case", "v1.0 JSON uses camelCase; these keys are snake_case: "
|
|
188
|
+
+ ", ".join(snake[:6]) + (" ..." if len(snake) > 6 else ""))
|
|
189
|
+
|
|
190
|
+
if "provider" not in card:
|
|
191
|
+
info("no-provider", "no 'provider' - nothing says who operates this agent")
|
|
192
|
+
if "documentationUrl" not in card:
|
|
193
|
+
info("no-docs", "no 'documentationUrl'")
|
|
194
|
+
return out
|