agentgovern 0.1.0b1__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.

Potentially problematic release.


This version of agentgovern might be problematic. Click here for more details.

@@ -0,0 +1,23 @@
1
+ node_modules/
2
+ .env
3
+ .env.local
4
+ .env.production
5
+ .env.development
6
+ .next/
7
+ dist/
8
+ build/
9
+ *.log
10
+ .DS_Store
11
+ __pycache__/
12
+ *.pyc
13
+ *.pyo
14
+ .venv/
15
+ .uv/
16
+ coverage/
17
+ .turbo/
18
+ .vercel/
19
+ .playwright/
20
+ playwright-report/
21
+ test-results/
22
+ *.tsbuildinfo
23
+ .drizzle/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zirahn
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,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentgovern
3
+ Version: 0.1.0b1
4
+ Summary: Compliance-as-code middleware for agentic AI workflows.
5
+ Project-URL: Homepage, https://agentgovern.zirahn.com
6
+ Project-URL: Repository, https://github.com/ahmedkhan-zirahn/agentgovern
7
+ Project-URL: Issues, https://github.com/ahmedkhan-zirahn/agentgovern/issues
8
+ Author-email: Azhar Khan <ahmed.khan@zirahn.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: agent-governance,agents,ai,compliance,eu-ai-act,governance,langchain,nist
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: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: System :: Monitoring
22
+ Requires-Python: >=3.9
23
+ Requires-Dist: httpx>=0.27.0
24
+ Requires-Dist: pydantic>=2.10.0
25
+ Requires-Dist: python-dotenv>=1.0.0
26
+ Provides-Extra: crewai
27
+ Requires-Dist: crewai>=0.80.0; extra == 'crewai'
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
30
+ Requires-Dist: pytest-cov>=6.0.0; extra == 'dev'
31
+ Requires-Dist: pytest>=8.3.0; extra == 'dev'
32
+ Requires-Dist: respx>=0.21.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.8.0; extra == 'dev'
34
+ Provides-Extra: langchain
35
+ Requires-Dist: langchain-core>=0.3.0; extra == 'langchain'
36
+ Provides-Extra: openai
37
+ Requires-Dist: openai>=1.50.0; extra == 'openai'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # AgentGovern Python SDK
41
+
42
+ **Compliance-as-code for agentic AI workflows.**
43
+
44
+ > **Beta** — API may change before 1.0. [Report issues](https://github.com/ahmedkhan-zirahn/agentgovern/issues).
45
+
46
+ AgentGovern intercepts AI agent actions, evaluates them against configurable compliance policies (EU AI Act, NIST AI RMF, ISO 42001), and generates audit-ready evidence — in real-time. This SDK instruments your LangChain, CrewAI, or OpenAI Agents code with minimal changes.
47
+
48
+ ## Install
49
+
50
+ ```bash
51
+ pip install agentgovern
52
+ ```
53
+
54
+ ## Quickstart — LangChain
55
+
56
+ ```python
57
+ import agentgovern
58
+ from langchain.agents import AgentExecutor, create_openai_tools_agent
59
+ from langchain_openai import ChatOpenAI
60
+
61
+ # 1. Initialize once at startup
62
+ agentgovern.init(
63
+ api_key="ag_prod_...", # from https://agentgovern.zirahn.com/settings/api-keys
64
+ base_url="https://agentgovern.zirahn.com",
65
+ environment="development", # "production" | "staging" | "development"
66
+ )
67
+
68
+ # 2. Register your agent
69
+ agentgovern.register_agent(
70
+ "credit-scoring-agent-01",
71
+ name="Credit Scoring Agent",
72
+ framework="langchain",
73
+ )
74
+
75
+ # 3. Get the callback handler
76
+ handler = agentgovern.instrument_langchain()
77
+
78
+ # 4. Pass it to your AgentExecutor — no other changes needed
79
+ llm = ChatOpenAI(model="gpt-4o")
80
+ agent = create_openai_tools_agent(llm, tools, prompt)
81
+ executor = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])
82
+
83
+ result = executor.invoke({"input": "Evaluate loan application for customer #12345"})
84
+ ```
85
+
86
+ Every tool call, LLM invocation, and agent step is automatically captured, evaluated against your enabled compliance policies, and visible in the dashboard.
87
+
88
+ ## Manual instrumentation (all frameworks)
89
+
90
+ ```python
91
+ from agentgovern.types import ActionType, ActionStatus
92
+
93
+ agentgovern.track_action(
94
+ agent_external_id="my-agent-id",
95
+ action_type=ActionType.TOOL_CALL,
96
+ action_name="fetch_credit_bureau_data",
97
+ status=ActionStatus.COMPLETED,
98
+ duration_ms=312,
99
+ input_payload={"bureau": "experian", "customer_id": "..."},
100
+ output_payload={"fico_score": 720},
101
+ )
102
+ ```
103
+
104
+ ## Supported frameworks
105
+
106
+ | Framework | Auto-instrumentation | Status |
107
+ |-----------|---------------------|--------|
108
+ | LangChain | `instrument_langchain()` — wraps tool and LLM callbacks | Stable |
109
+ | CrewAI | Manual via `track_action()` | Beta |
110
+ | OpenAI Agents API | Manual via `track_action()` | Beta |
111
+
112
+ Auto-instrumentation for CrewAI and OpenAI Agents is on the roadmap.
113
+
114
+ ## Compliance frameworks
115
+
116
+ | Framework | Status |
117
+ |-----------|--------|
118
+ | EU AI Act (High-Risk Systems) | Available |
119
+ | NIST AI RMF | Coming soon |
120
+ | ISO 42001 | Coming soon |
121
+
122
+ Enable policy packs from the [AgentGovern dashboard](https://agentgovern.zirahn.com).
123
+
124
+ ## Configuration
125
+
126
+ | Parameter | Default | Description |
127
+ |-----------|---------|-------------|
128
+ | `api_key` | required | SDK ingest key from the dashboard |
129
+ | `base_url` | `https://agentgovern.zirahn.com` | API endpoint |
130
+ | `environment` | `"production"` | `"production"` \| `"staging"` \| `"development"` |
131
+ | `fail_silently` | `True` | If `True`, SDK errors never raise into your agent |
132
+
133
+ ## Design guarantees
134
+
135
+ - `track_action()` returns in **< 5 ms** — all I/O is async in a background thread
136
+ - Buffer cap: 10,000 actions; oldest dropped when full
137
+ - Retry: 3 attempts with exponential backoff (1 s → 30 s max)
138
+ - If AgentGovern is unreachable, your agent continues unaffected
139
+
140
+ ## Links
141
+
142
+ - **Dashboard:** https://agentgovern.zirahn.com
143
+ - **Documentation:** https://github.com/ahmedkhan-zirahn/agentgovern
144
+ - **Issues:** https://github.com/ahmedkhan-zirahn/agentgovern/issues
145
+
146
+ ## License
147
+
148
+ MIT — Copyright (c) 2026 Zirahn
@@ -0,0 +1,109 @@
1
+ # AgentGovern Python SDK
2
+
3
+ **Compliance-as-code for agentic AI workflows.**
4
+
5
+ > **Beta** — API may change before 1.0. [Report issues](https://github.com/ahmedkhan-zirahn/agentgovern/issues).
6
+
7
+ AgentGovern intercepts AI agent actions, evaluates them against configurable compliance policies (EU AI Act, NIST AI RMF, ISO 42001), and generates audit-ready evidence — in real-time. This SDK instruments your LangChain, CrewAI, or OpenAI Agents code with minimal changes.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install agentgovern
13
+ ```
14
+
15
+ ## Quickstart — LangChain
16
+
17
+ ```python
18
+ import agentgovern
19
+ from langchain.agents import AgentExecutor, create_openai_tools_agent
20
+ from langchain_openai import ChatOpenAI
21
+
22
+ # 1. Initialize once at startup
23
+ agentgovern.init(
24
+ api_key="ag_prod_...", # from https://agentgovern.zirahn.com/settings/api-keys
25
+ base_url="https://agentgovern.zirahn.com",
26
+ environment="development", # "production" | "staging" | "development"
27
+ )
28
+
29
+ # 2. Register your agent
30
+ agentgovern.register_agent(
31
+ "credit-scoring-agent-01",
32
+ name="Credit Scoring Agent",
33
+ framework="langchain",
34
+ )
35
+
36
+ # 3. Get the callback handler
37
+ handler = agentgovern.instrument_langchain()
38
+
39
+ # 4. Pass it to your AgentExecutor — no other changes needed
40
+ llm = ChatOpenAI(model="gpt-4o")
41
+ agent = create_openai_tools_agent(llm, tools, prompt)
42
+ executor = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])
43
+
44
+ result = executor.invoke({"input": "Evaluate loan application for customer #12345"})
45
+ ```
46
+
47
+ Every tool call, LLM invocation, and agent step is automatically captured, evaluated against your enabled compliance policies, and visible in the dashboard.
48
+
49
+ ## Manual instrumentation (all frameworks)
50
+
51
+ ```python
52
+ from agentgovern.types import ActionType, ActionStatus
53
+
54
+ agentgovern.track_action(
55
+ agent_external_id="my-agent-id",
56
+ action_type=ActionType.TOOL_CALL,
57
+ action_name="fetch_credit_bureau_data",
58
+ status=ActionStatus.COMPLETED,
59
+ duration_ms=312,
60
+ input_payload={"bureau": "experian", "customer_id": "..."},
61
+ output_payload={"fico_score": 720},
62
+ )
63
+ ```
64
+
65
+ ## Supported frameworks
66
+
67
+ | Framework | Auto-instrumentation | Status |
68
+ |-----------|---------------------|--------|
69
+ | LangChain | `instrument_langchain()` — wraps tool and LLM callbacks | Stable |
70
+ | CrewAI | Manual via `track_action()` | Beta |
71
+ | OpenAI Agents API | Manual via `track_action()` | Beta |
72
+
73
+ Auto-instrumentation for CrewAI and OpenAI Agents is on the roadmap.
74
+
75
+ ## Compliance frameworks
76
+
77
+ | Framework | Status |
78
+ |-----------|--------|
79
+ | EU AI Act (High-Risk Systems) | Available |
80
+ | NIST AI RMF | Coming soon |
81
+ | ISO 42001 | Coming soon |
82
+
83
+ Enable policy packs from the [AgentGovern dashboard](https://agentgovern.zirahn.com).
84
+
85
+ ## Configuration
86
+
87
+ | Parameter | Default | Description |
88
+ |-----------|---------|-------------|
89
+ | `api_key` | required | SDK ingest key from the dashboard |
90
+ | `base_url` | `https://agentgovern.zirahn.com` | API endpoint |
91
+ | `environment` | `"production"` | `"production"` \| `"staging"` \| `"development"` |
92
+ | `fail_silently` | `True` | If `True`, SDK errors never raise into your agent |
93
+
94
+ ## Design guarantees
95
+
96
+ - `track_action()` returns in **< 5 ms** — all I/O is async in a background thread
97
+ - Buffer cap: 10,000 actions; oldest dropped when full
98
+ - Retry: 3 attempts with exponential backoff (1 s → 30 s max)
99
+ - If AgentGovern is unreachable, your agent continues unaffected
100
+
101
+ ## Links
102
+
103
+ - **Dashboard:** https://agentgovern.zirahn.com
104
+ - **Documentation:** https://github.com/ahmedkhan-zirahn/agentgovern
105
+ - **Issues:** https://github.com/ahmedkhan-zirahn/agentgovern/issues
106
+
107
+ ## License
108
+
109
+ MIT — Copyright (c) 2026 Zirahn
@@ -0,0 +1,165 @@
1
+ """
2
+ AgentGovern SDK — Compliance instrumentation for agentic AI workflows.
3
+
4
+ Quickstart::
5
+
6
+ import agentgovern
7
+
8
+ agentgovern.init(api_key="ag_prod_...")
9
+ agentgovern.register_agent("my-credit-scoring-agent", name="Credit Scoring Agent")
10
+
11
+ # Then instrument LangChain:
12
+ agentgovern.instrument_langchain()
13
+
14
+ # Or track actions manually:
15
+ from agentgovern.types import ActionType
16
+ agentgovern.track_action(
17
+ agent_external_id="my-credit-scoring-agent",
18
+ action_type=ActionType.TOOL_CALL,
19
+ action_name="fetch_bureau_data",
20
+ )
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ from typing import Any
26
+
27
+ from agentgovern.client import AgentGovernClient
28
+ from agentgovern.exceptions import PolicyViolation
29
+ from agentgovern.types import ActionStatus, ActionType, Environment
30
+
31
+ _client: AgentGovernClient | None = None
32
+
33
+
34
+ def init(
35
+ api_key: str,
36
+ *,
37
+ environment: str = "production",
38
+ base_url: str = "https://agentgovern.zirahn.com",
39
+ fail_silently: bool = True,
40
+ ) -> AgentGovernClient:
41
+ """
42
+ Initialize the AgentGovern SDK.
43
+
44
+ Must be called once at application startup before any other SDK calls.
45
+ The SDK is designed to never break the customer's agent — if AgentGovern
46
+ is unreachable, all errors are silently discarded.
47
+ """
48
+ global _client # noqa: PLW0603
49
+ _client = AgentGovernClient(
50
+ api_key=api_key,
51
+ environment=environment,
52
+ base_url=base_url,
53
+ fail_silently=fail_silently,
54
+ )
55
+ return _client
56
+
57
+
58
+ def register_agent(
59
+ external_id: str,
60
+ name: str,
61
+ *,
62
+ description: str | None = None,
63
+ framework: str = "custom",
64
+ framework_version: str | None = None,
65
+ owner_email: str | None = None,
66
+ tags: list[str] | None = None,
67
+ metadata: dict[str, Any] | None = None,
68
+ ) -> None:
69
+ """Fire-and-forget agent registration. No-op if SDK is not initialized."""
70
+ if _client is None:
71
+ return
72
+ _client.register_agent(
73
+ external_id,
74
+ name,
75
+ description=description,
76
+ framework=framework,
77
+ framework_version=framework_version,
78
+ owner_email=owner_email,
79
+ tags=tags,
80
+ metadata=metadata,
81
+ )
82
+
83
+
84
+ def track_action(
85
+ agent_external_id: str,
86
+ action_type: ActionType,
87
+ action_name: str,
88
+ *,
89
+ status: ActionStatus = ActionStatus.COMPLETED,
90
+ duration_ms: int | None = None,
91
+ input_payload: dict[str, Any] | None = None,
92
+ output_payload: dict[str, Any] | None = None,
93
+ model_id: str | None = None,
94
+ token_count: int | None = None,
95
+ trace_id: str | None = None,
96
+ span_id: str | None = None,
97
+ metadata: dict[str, Any] | None = None,
98
+ ) -> None:
99
+ """Enqueue an action for async ingest. No-op if SDK is not initialized."""
100
+ if _client is None:
101
+ return
102
+ _client.track_action(
103
+ agent_external_id,
104
+ action_type,
105
+ action_name,
106
+ status=status,
107
+ duration_ms=duration_ms,
108
+ input_payload=input_payload,
109
+ output_payload=output_payload,
110
+ model_id=model_id,
111
+ token_count=token_count,
112
+ trace_id=trace_id,
113
+ span_id=span_id,
114
+ metadata=metadata,
115
+ )
116
+
117
+
118
+ def instrument_langchain(agent_external_id: str | None = None) -> Any:
119
+ """
120
+ Attach AgentGovern to LangChain callbacks.
121
+
122
+ Returns the callback handler instance. Requires the 'langchain' extra:
123
+ ``pip install agentgovern[langchain]``
124
+ """
125
+ if _client is None:
126
+ raise RuntimeError("Call agentgovern.init() before instrument_langchain()")
127
+ from agentgovern.instrumentors.langchain import AgentGovernCallbackHandler
128
+
129
+ return AgentGovernCallbackHandler(client=_client, agent_external_id=agent_external_id)
130
+
131
+
132
+ def heartbeat() -> dict[str, Any]:
133
+ """POST /v1/ingest/heartbeat — returns status dict. No-op dict if not initialized."""
134
+ if _client is None:
135
+ return {"status": "not_initialized"}
136
+ return _client.heartbeat()
137
+
138
+
139
+ def status() -> dict[str, Any]:
140
+ """Return SDK health status."""
141
+ if _client is None:
142
+ return {"initialized": False}
143
+ return _client.status()
144
+
145
+
146
+ def shutdown(timeout: float = 5.0) -> None:
147
+ """Flush remaining actions and stop the background thread."""
148
+ if _client is not None:
149
+ _client.shutdown(timeout=timeout)
150
+
151
+
152
+ __all__ = [
153
+ "init",
154
+ "register_agent",
155
+ "track_action",
156
+ "instrument_langchain",
157
+ "heartbeat",
158
+ "status",
159
+ "shutdown",
160
+ "AgentGovernClient",
161
+ "PolicyViolation",
162
+ "ActionType",
163
+ "ActionStatus",
164
+ "Environment",
165
+ ]