pactspec 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.
- pactspec-0.1.0/LICENSE +21 -0
- pactspec-0.1.0/PKG-INFO +177 -0
- pactspec-0.1.0/README.md +147 -0
- pactspec-0.1.0/pactspec/__init__.py +83 -0
- pactspec-0.1.0/pactspec/client.py +481 -0
- pactspec-0.1.0/pactspec/py.typed +0 -0
- pactspec-0.1.0/pactspec/schema.json +100 -0
- pactspec-0.1.0/pactspec/types.py +193 -0
- pactspec-0.1.0/pactspec/validate.py +72 -0
- pactspec-0.1.0/pactspec.egg-info/PKG-INFO +177 -0
- pactspec-0.1.0/pactspec.egg-info/SOURCES.txt +14 -0
- pactspec-0.1.0/pactspec.egg-info/dependency_links.txt +1 -0
- pactspec-0.1.0/pactspec.egg-info/requires.txt +2 -0
- pactspec-0.1.0/pactspec.egg-info/top_level.txt +1 -0
- pactspec-0.1.0/pyproject.toml +46 -0
- pactspec-0.1.0/setup.cfg +4 -0
pactspec-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 PactSpec Contributors
|
|
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.
|
pactspec-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pactspec
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for PactSpec — validate, publish, and verify AI agent capability specs
|
|
5
|
+
Author-email: PactSpec Contributors <hello@pactspec.dev>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://pactspec.dev
|
|
8
|
+
Project-URL: Repository, https://github.com/Grumpy254/pactspec
|
|
9
|
+
Project-URL: Documentation, https://pactspec.dev/docs
|
|
10
|
+
Project-URL: Issues, https://github.com/Grumpy254/pactspec/issues
|
|
11
|
+
Keywords: pactspec,ai-agents,sdk,registry,attestation,agent-spec
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: jsonschema>=4.0.0
|
|
28
|
+
Requires-Dist: httpx>=0.24.0
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# pactspec
|
|
32
|
+
|
|
33
|
+
Official Python SDK for [PactSpec](https://pactspec.dev) -- validate, publish, and verify AI agent capability specs.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install pactspec
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
### Validate a spec offline
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from pactspec import validate_spec
|
|
47
|
+
|
|
48
|
+
spec = {
|
|
49
|
+
"specVersion": "1.0.0",
|
|
50
|
+
"id": "urn:pactspec:acme:summarizer",
|
|
51
|
+
"name": "Summarizer Agent",
|
|
52
|
+
"version": "1.0.0",
|
|
53
|
+
"provider": {"name": "Acme Corp"},
|
|
54
|
+
"endpoint": {"url": "https://api.acme.com/summarize"},
|
|
55
|
+
"skills": [
|
|
56
|
+
{
|
|
57
|
+
"id": "summarize",
|
|
58
|
+
"name": "Summarize Text",
|
|
59
|
+
"description": "Summarizes input text",
|
|
60
|
+
"inputSchema": {"type": "object", "properties": {"text": {"type": "string"}}},
|
|
61
|
+
"outputSchema": {"type": "object", "properties": {"summary": {"type": "string"}}},
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
result = validate_spec(spec)
|
|
67
|
+
if result.valid:
|
|
68
|
+
print("Spec is valid!")
|
|
69
|
+
else:
|
|
70
|
+
for err in result.errors:
|
|
71
|
+
print(f" - {err}")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Publish to the registry
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from pactspec import PactSpecClient
|
|
78
|
+
|
|
79
|
+
client = PactSpecClient(agent_id="my-agent@acme.com")
|
|
80
|
+
pub = client.publish(spec)
|
|
81
|
+
print(f"Published: {pub.id} (spec_id: {pub.spec_id})")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Verify a skill
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
verification = client.verify(pub.id, "summarize")
|
|
88
|
+
print(f"Status: {verification.status}")
|
|
89
|
+
for tr in verification.results:
|
|
90
|
+
status = "PASS" if tr.passed else "FAIL"
|
|
91
|
+
print(f" [{status}] {tr.test_id} ({tr.duration_ms}ms)")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Search the registry
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from pactspec import search
|
|
98
|
+
|
|
99
|
+
results = search(q="summarize", verified_only=True)
|
|
100
|
+
for agent in results.agents:
|
|
101
|
+
print(f"{agent.name} v{agent.version} - {agent.spec_id}")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## API reference
|
|
105
|
+
|
|
106
|
+
### `validate_spec(spec) -> ValidateResult`
|
|
107
|
+
|
|
108
|
+
Validate a PactSpec document against the v1 JSON schema. Offline, no network calls.
|
|
109
|
+
|
|
110
|
+
- **Returns:** `ValidateResult` with `.valid` (bool) and `.errors` (list of strings).
|
|
111
|
+
|
|
112
|
+
### `PactSpecClient`
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
client = PactSpecClient(
|
|
116
|
+
agent_id="my-agent@acme.com", # default agent ID for publish
|
|
117
|
+
registry="https://pactspec.dev", # registry URL (default)
|
|
118
|
+
publish_token="tok_...", # optional auth token
|
|
119
|
+
timeout=30, # HTTP timeout in seconds
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
| Method | Description |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `client.validate(spec)` | Validate a spec offline |
|
|
126
|
+
| `client.publish(spec)` | Validate + publish to the registry |
|
|
127
|
+
| `client.verify(agent_id, skill_id)` | Trigger a verification run |
|
|
128
|
+
| `client.get_agent(agent_id)` | Fetch an agent by UUID or spec URN |
|
|
129
|
+
| `client.search(q=..., verified_only=...)` | Search the registry |
|
|
130
|
+
|
|
131
|
+
### Module-level functions
|
|
132
|
+
|
|
133
|
+
The same operations are available as standalone functions:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from pactspec import publish, verify, get_agent, search
|
|
137
|
+
|
|
138
|
+
result = publish(spec, agent_id="my-agent@acme.com")
|
|
139
|
+
verification = verify(result.id, "my-skill")
|
|
140
|
+
agent = get_agent(result.id)
|
|
141
|
+
results = search(q="coding", verified_only=True)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Exceptions
|
|
145
|
+
|
|
146
|
+
| Exception | When |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `PactSpecError` | Base class for all SDK errors |
|
|
149
|
+
| `PactSpecValidationError` | Spec fails local schema validation |
|
|
150
|
+
| `PactSpecAPIError` | Registry API returns an error |
|
|
151
|
+
| `PactSpecNotFoundError` | Agent not found (404) |
|
|
152
|
+
|
|
153
|
+
All exceptions include `.status_code` (int or None) and `.details` (list of strings).
|
|
154
|
+
|
|
155
|
+
### Types
|
|
156
|
+
|
|
157
|
+
The `pactspec.types` module provides TypedDict definitions matching the canonical TypeScript types:
|
|
158
|
+
|
|
159
|
+
- `PactSpec`, `PactSpecSkill`, `PactSpecPricing`, `PactSpecProvider`, `PactSpecEndpoint`
|
|
160
|
+
- `PactSpecAuth`, `PactSpecTestSuite`, `PactSpecExample`, `PactSpecLinks`, `PactSpecDelegation`
|
|
161
|
+
- `Benchmark`, `BenchmarkResult`
|
|
162
|
+
|
|
163
|
+
These are useful for type checking with mypy or pyright.
|
|
164
|
+
|
|
165
|
+
## SDK vs CLI
|
|
166
|
+
|
|
167
|
+
| | Python SDK | CLI (`pactspec`) |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| **Use when** | Building Python apps, CI pipelines, programmatic access | Quick one-off commands, shell scripts |
|
|
170
|
+
| **Install** | `pip install pactspec` | `npm i -g pactspec` |
|
|
171
|
+
| **Validation** | `validate_spec(spec)` | `pactspec validate spec.json` |
|
|
172
|
+
| **Publishing** | `client.publish(spec)` | `pactspec publish spec.json` |
|
|
173
|
+
| **Output** | Python objects | JSON / human-readable text |
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT
|
pactspec-0.1.0/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# pactspec
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [PactSpec](https://pactspec.dev) -- validate, publish, and verify AI agent capability specs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install pactspec
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
### Validate a spec offline
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from pactspec import validate_spec
|
|
17
|
+
|
|
18
|
+
spec = {
|
|
19
|
+
"specVersion": "1.0.0",
|
|
20
|
+
"id": "urn:pactspec:acme:summarizer",
|
|
21
|
+
"name": "Summarizer Agent",
|
|
22
|
+
"version": "1.0.0",
|
|
23
|
+
"provider": {"name": "Acme Corp"},
|
|
24
|
+
"endpoint": {"url": "https://api.acme.com/summarize"},
|
|
25
|
+
"skills": [
|
|
26
|
+
{
|
|
27
|
+
"id": "summarize",
|
|
28
|
+
"name": "Summarize Text",
|
|
29
|
+
"description": "Summarizes input text",
|
|
30
|
+
"inputSchema": {"type": "object", "properties": {"text": {"type": "string"}}},
|
|
31
|
+
"outputSchema": {"type": "object", "properties": {"summary": {"type": "string"}}},
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
result = validate_spec(spec)
|
|
37
|
+
if result.valid:
|
|
38
|
+
print("Spec is valid!")
|
|
39
|
+
else:
|
|
40
|
+
for err in result.errors:
|
|
41
|
+
print(f" - {err}")
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Publish to the registry
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from pactspec import PactSpecClient
|
|
48
|
+
|
|
49
|
+
client = PactSpecClient(agent_id="my-agent@acme.com")
|
|
50
|
+
pub = client.publish(spec)
|
|
51
|
+
print(f"Published: {pub.id} (spec_id: {pub.spec_id})")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Verify a skill
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
verification = client.verify(pub.id, "summarize")
|
|
58
|
+
print(f"Status: {verification.status}")
|
|
59
|
+
for tr in verification.results:
|
|
60
|
+
status = "PASS" if tr.passed else "FAIL"
|
|
61
|
+
print(f" [{status}] {tr.test_id} ({tr.duration_ms}ms)")
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Search the registry
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from pactspec import search
|
|
68
|
+
|
|
69
|
+
results = search(q="summarize", verified_only=True)
|
|
70
|
+
for agent in results.agents:
|
|
71
|
+
print(f"{agent.name} v{agent.version} - {agent.spec_id}")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## API reference
|
|
75
|
+
|
|
76
|
+
### `validate_spec(spec) -> ValidateResult`
|
|
77
|
+
|
|
78
|
+
Validate a PactSpec document against the v1 JSON schema. Offline, no network calls.
|
|
79
|
+
|
|
80
|
+
- **Returns:** `ValidateResult` with `.valid` (bool) and `.errors` (list of strings).
|
|
81
|
+
|
|
82
|
+
### `PactSpecClient`
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
client = PactSpecClient(
|
|
86
|
+
agent_id="my-agent@acme.com", # default agent ID for publish
|
|
87
|
+
registry="https://pactspec.dev", # registry URL (default)
|
|
88
|
+
publish_token="tok_...", # optional auth token
|
|
89
|
+
timeout=30, # HTTP timeout in seconds
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
| Method | Description |
|
|
94
|
+
|---|---|
|
|
95
|
+
| `client.validate(spec)` | Validate a spec offline |
|
|
96
|
+
| `client.publish(spec)` | Validate + publish to the registry |
|
|
97
|
+
| `client.verify(agent_id, skill_id)` | Trigger a verification run |
|
|
98
|
+
| `client.get_agent(agent_id)` | Fetch an agent by UUID or spec URN |
|
|
99
|
+
| `client.search(q=..., verified_only=...)` | Search the registry |
|
|
100
|
+
|
|
101
|
+
### Module-level functions
|
|
102
|
+
|
|
103
|
+
The same operations are available as standalone functions:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from pactspec import publish, verify, get_agent, search
|
|
107
|
+
|
|
108
|
+
result = publish(spec, agent_id="my-agent@acme.com")
|
|
109
|
+
verification = verify(result.id, "my-skill")
|
|
110
|
+
agent = get_agent(result.id)
|
|
111
|
+
results = search(q="coding", verified_only=True)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Exceptions
|
|
115
|
+
|
|
116
|
+
| Exception | When |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `PactSpecError` | Base class for all SDK errors |
|
|
119
|
+
| `PactSpecValidationError` | Spec fails local schema validation |
|
|
120
|
+
| `PactSpecAPIError` | Registry API returns an error |
|
|
121
|
+
| `PactSpecNotFoundError` | Agent not found (404) |
|
|
122
|
+
|
|
123
|
+
All exceptions include `.status_code` (int or None) and `.details` (list of strings).
|
|
124
|
+
|
|
125
|
+
### Types
|
|
126
|
+
|
|
127
|
+
The `pactspec.types` module provides TypedDict definitions matching the canonical TypeScript types:
|
|
128
|
+
|
|
129
|
+
- `PactSpec`, `PactSpecSkill`, `PactSpecPricing`, `PactSpecProvider`, `PactSpecEndpoint`
|
|
130
|
+
- `PactSpecAuth`, `PactSpecTestSuite`, `PactSpecExample`, `PactSpecLinks`, `PactSpecDelegation`
|
|
131
|
+
- `Benchmark`, `BenchmarkResult`
|
|
132
|
+
|
|
133
|
+
These are useful for type checking with mypy or pyright.
|
|
134
|
+
|
|
135
|
+
## SDK vs CLI
|
|
136
|
+
|
|
137
|
+
| | Python SDK | CLI (`pactspec`) |
|
|
138
|
+
|---|---|---|
|
|
139
|
+
| **Use when** | Building Python apps, CI pipelines, programmatic access | Quick one-off commands, shell scripts |
|
|
140
|
+
| **Install** | `pip install pactspec` | `npm i -g pactspec` |
|
|
141
|
+
| **Validation** | `validate_spec(spec)` | `pactspec validate spec.json` |
|
|
142
|
+
| **Publishing** | `client.publish(spec)` | `pactspec publish spec.json` |
|
|
143
|
+
| **Output** | Python objects | JSON / human-readable text |
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""PactSpec Python SDK — validate, publish, and verify AI agent capability specs.
|
|
2
|
+
|
|
3
|
+
Quick start::
|
|
4
|
+
|
|
5
|
+
from pactspec import validate_spec, PactSpecClient
|
|
6
|
+
|
|
7
|
+
# Validate locally
|
|
8
|
+
result = validate_spec(my_spec)
|
|
9
|
+
|
|
10
|
+
# Publish to registry
|
|
11
|
+
client = PactSpecClient(agent_id="my-agent@acme.com")
|
|
12
|
+
pub = client.publish(my_spec)
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from .validate import validate_spec, validate, ValidateResult
|
|
16
|
+
from .client import (
|
|
17
|
+
PactSpecClient,
|
|
18
|
+
publish,
|
|
19
|
+
verify,
|
|
20
|
+
get_agent,
|
|
21
|
+
search,
|
|
22
|
+
PublishResult,
|
|
23
|
+
VerifyResult,
|
|
24
|
+
AgentRecord,
|
|
25
|
+
SearchResult,
|
|
26
|
+
TestResult,
|
|
27
|
+
PactSpecError,
|
|
28
|
+
PactSpecValidationError,
|
|
29
|
+
PactSpecAPIError,
|
|
30
|
+
PactSpecNotFoundError,
|
|
31
|
+
)
|
|
32
|
+
from .types import (
|
|
33
|
+
PactSpec,
|
|
34
|
+
PactSpecSkill,
|
|
35
|
+
PactSpecPricing,
|
|
36
|
+
PactSpecProvider,
|
|
37
|
+
PactSpecEndpoint,
|
|
38
|
+
PactSpecAuth,
|
|
39
|
+
PactSpecTestSuite,
|
|
40
|
+
PactSpecExample,
|
|
41
|
+
PactSpecLinks,
|
|
42
|
+
PactSpecDelegation,
|
|
43
|
+
Benchmark,
|
|
44
|
+
BenchmarkResult,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
__version__ = "0.1.0"
|
|
48
|
+
__all__ = [
|
|
49
|
+
# Validation
|
|
50
|
+
"validate_spec",
|
|
51
|
+
"validate",
|
|
52
|
+
"ValidateResult",
|
|
53
|
+
# Client
|
|
54
|
+
"PactSpecClient",
|
|
55
|
+
"publish",
|
|
56
|
+
"verify",
|
|
57
|
+
"get_agent",
|
|
58
|
+
"search",
|
|
59
|
+
# Result types
|
|
60
|
+
"PublishResult",
|
|
61
|
+
"VerifyResult",
|
|
62
|
+
"AgentRecord",
|
|
63
|
+
"SearchResult",
|
|
64
|
+
"TestResult",
|
|
65
|
+
# Exceptions
|
|
66
|
+
"PactSpecError",
|
|
67
|
+
"PactSpecValidationError",
|
|
68
|
+
"PactSpecAPIError",
|
|
69
|
+
"PactSpecNotFoundError",
|
|
70
|
+
# Spec types
|
|
71
|
+
"PactSpec",
|
|
72
|
+
"PactSpecSkill",
|
|
73
|
+
"PactSpecPricing",
|
|
74
|
+
"PactSpecProvider",
|
|
75
|
+
"PactSpecEndpoint",
|
|
76
|
+
"PactSpecAuth",
|
|
77
|
+
"PactSpecTestSuite",
|
|
78
|
+
"PactSpecExample",
|
|
79
|
+
"PactSpecLinks",
|
|
80
|
+
"PactSpecDelegation",
|
|
81
|
+
"Benchmark",
|
|
82
|
+
"BenchmarkResult",
|
|
83
|
+
]
|