agentspec-sdk 0.5.0__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.
- agentspec_sdk/__init__.py +19 -0
- agentspec_sdk/agentspec_contract.py +522 -0
- agentspec_sdk/evidence_points.py +385 -0
- agentspec_sdk/manifest.py +36 -0
- agentspec_sdk/manifest_hash.py +52 -0
- agentspec_sdk/memory_points.py +359 -0
- agentspec_sdk/reporter.py +319 -0
- agentspec_sdk/types.py +33 -0
- agentspec_sdk-0.5.0.dist-info/METADATA +75 -0
- agentspec_sdk-0.5.0.dist-info/RECORD +11 -0
- agentspec_sdk-0.5.0.dist-info/WHEEL +4 -0
agentspec_sdk/types.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Pydantic models matching the AgentSpec TypeScript SDK HealthReport shape.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from typing import Dict, List, Literal, Optional
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel, ConfigDict
|
|
10
|
+
from pydantic.alias_generators import to_camel
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class _CamelModel(BaseModel):
|
|
14
|
+
"""Python attribute names, TypeScript JSON keys (agentName, latencyMs)."""
|
|
15
|
+
|
|
16
|
+
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True, serialize_by_alias=True)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class HealthCheck(_CamelModel):
|
|
20
|
+
id: str
|
|
21
|
+
category: str
|
|
22
|
+
status: Literal["pass", "fail", "warn", "skip"]
|
|
23
|
+
severity: Literal["error", "warning", "info"]
|
|
24
|
+
latency_ms: Optional[int] = None
|
|
25
|
+
message: Optional[str] = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class HealthReport(_CamelModel):
|
|
29
|
+
agent_name: str
|
|
30
|
+
timestamp: str
|
|
31
|
+
status: Literal["healthy", "degraded", "unhealthy"]
|
|
32
|
+
summary: Dict[str, int]
|
|
33
|
+
checks: List[HealthCheck]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agentspec-sdk
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Universal Agent Manifest SDK for Python agents
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Requires-Dist: httpx>=0.28.1
|
|
7
|
+
Requires-Dist: pydantic>=2.14.1
|
|
8
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Requires-Dist: langchain-core>=1.0.0; extra == 'dev'
|
|
11
|
+
Requires-Dist: langgraph-checkpoint>=4.0.0; extra == 'dev'
|
|
12
|
+
Requires-Dist: pytest-asyncio>=1.4.1; extra == 'dev'
|
|
13
|
+
Requires-Dist: pytest>=9.1.1; extra == 'dev'
|
|
14
|
+
Requires-Dist: respx>=0.23.1; extra == 'dev'
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# agentspec-sdk
|
|
18
|
+
|
|
19
|
+
Python runtime SDK for [AgentSpec](https://github.com/agents-oss/agentspec): serves `GET /agentspec/health` and pushes state to the control plane from an agent described by `agent.yaml`.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install agentspec-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from agentspec_sdk import AgentSpecReporter
|
|
27
|
+
|
|
28
|
+
reporter = AgentSpecReporter.from_yaml("agent.yaml")
|
|
29
|
+
|
|
30
|
+
# WSGI app answering GET /agentspec/health with the TypeScript HealthReport keys
|
|
31
|
+
# (agentName, checks[].latencyMs), so the sidecar sees the SDK. Mount it in your framework.
|
|
32
|
+
app = reporter.wsgi_app()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Mount the app so the full request path is `/agentspec/health`. At the root it answers that path directly. Under a
|
|
36
|
+
prefix, the dispatcher moves the prefix into `SCRIPT_NAME`; the app compares `SCRIPT_NAME + PATH_INFO`, so
|
|
37
|
+
mounting it at `/agentspec` (for example `DispatcherMiddleware(fallback, {"/agentspec": reporter.wsgi_app()})`)
|
|
38
|
+
serves `/agentspec/health` too.
|
|
39
|
+
|
|
40
|
+
## Evidence points
|
|
41
|
+
|
|
42
|
+
The SDK is the Python runtime SDK of ADR-0038: framework-agnostic, the same evidence points and record shapes as `@agentspec/sdk/runtime` in TypeScript. Create the reporter first, then wrap the operations the rules are about:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import agentspec_sdk
|
|
46
|
+
from agentspec_sdk import AgentSpecReporter
|
|
47
|
+
|
|
48
|
+
reporter = AgentSpecReporter.from_yaml("agent.yaml")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@agentspec_sdk.guardrail("input") # SEC-LLM-01; "output" for SEC-LLM-02
|
|
52
|
+
def run_input_guardrails(text: str) -> str:
|
|
53
|
+
return text
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@agentspec_sdk.tool("search-web") # TOOL-01
|
|
57
|
+
def search_web(query: str) -> list[str]:
|
|
58
|
+
return []
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
reporter.start_push_mode(api_key="<agent token>") # heartbeat with each evidence point's state and records
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
| Helper | Contract name | Wraps |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| `guardrail("input" \| "output")` | `guardrail` | A guardrail function (decorator) or block (`with`) |
|
|
67
|
+
| `tool(name)` | `tool` | A local tool function |
|
|
68
|
+
| `mcp_client(session, server)` | `mcpClient` | A stdio MCP client session |
|
|
69
|
+
| `memory_write(backend)` | `memoryWrite` | A LangGraph checkpointer or Store: scrubs, applies the TTL, audits |
|
|
70
|
+
| `vector_store(client, namespace=None)` | `vectorStore` | A vector store client |
|
|
71
|
+
| `structured_logging(logger=None)` | `logging` | The logger's stream handlers: JSON lines |
|
|
72
|
+
|
|
73
|
+
Each applicable evidence point is reported `fired`, `wired` or `not_wired`; `not_wired` never passes. See the [runtime SDK concept page](../../docs/concepts/runtime-sdk.md) and the [evidence wiring guide](../../docs/guides/wire-evidence-points.md).
|
|
74
|
+
|
|
75
|
+
The distribution is `agentspec-sdk` and the import is `agentspec_sdk`. The PyPI name `agentspec` belongs to an unrelated project.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
agentspec_sdk/__init__.py,sha256=t_UN05giDkkoBJlTjLTvwowcExEA4eHXCVhokASAuso,722
|
|
2
|
+
agentspec_sdk/agentspec_contract.py,sha256=KCln1Ure203E-I6ZL0KxoYYPwrRHc7Jw9COEnPVd8cA,28259
|
|
3
|
+
agentspec_sdk/evidence_points.py,sha256=qBI9pOkVyQkvwiJe3j3S83QN05e2oQ_dAgCWgKno1-Q,17167
|
|
4
|
+
agentspec_sdk/manifest.py,sha256=8Xnb_VVoV39KiPFMqcYtBXXLc1qfPxoYg7RQd2KabpQ,1204
|
|
5
|
+
agentspec_sdk/manifest_hash.py,sha256=E-jueF-1WLrd8Z_YEoitsdMewfoKc7dZFf8v8ODP8nc,2020
|
|
6
|
+
agentspec_sdk/memory_points.py,sha256=lrekX_dLKNtgI-d8RGM_DRnoRWYTT0kUdXI5VFqrfXA,17345
|
|
7
|
+
agentspec_sdk/reporter.py,sha256=9sJPnplGWUKOa3NtFeB3ngMuRIb_ZqvPmsJ2TEI7esE,12914
|
|
8
|
+
agentspec_sdk/types.py,sha256=m1VZ_wL33JVBylXzgs92Uc0jthu8MTV3u2LmMJ2SdBE,900
|
|
9
|
+
agentspec_sdk-0.5.0.dist-info/METADATA,sha256=csrjabwWMQm2o6DOLVO03z9OeflSlYmZYNPDvkikSOI,3152
|
|
10
|
+
agentspec_sdk-0.5.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
11
|
+
agentspec_sdk-0.5.0.dist-info/RECORD,,
|