acp-ai 0.2.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.
Files changed (109) hide show
  1. acp_ai-0.2.0/LICENSE +21 -0
  2. acp_ai-0.2.0/MANIFEST.in +1 -0
  3. acp_ai-0.2.0/PKG-INFO +154 -0
  4. acp_ai-0.2.0/README.md +126 -0
  5. acp_ai-0.2.0/acp/__init__.py +16 -0
  6. acp_ai-0.2.0/acp/bundle/dashboard/app.js +1431 -0
  7. acp_ai-0.2.0/acp/bundle/dashboard/index.html +123 -0
  8. acp_ai-0.2.0/acp/bundle/dashboard/styles.css +1114 -0
  9. acp_ai-0.2.0/acp/bundle/docker-compose.yml +82 -0
  10. acp_ai-0.2.0/acp/bundle/interceptor/Dockerfile +16 -0
  11. acp_ai-0.2.0/acp/bundle/interceptor/README.md +89 -0
  12. acp_ai-0.2.0/acp/bundle/interceptor/api/openapi.yaml +183 -0
  13. acp_ai-0.2.0/acp/bundle/interceptor/cmd/server/main.go +41 -0
  14. acp_ai-0.2.0/acp/bundle/interceptor/go.mod +47 -0
  15. acp_ai-0.2.0/acp/bundle/interceptor/go.sum +111 -0
  16. acp_ai-0.2.0/acp/bundle/interceptor/internal/approval/errors.go +10 -0
  17. acp_ai-0.2.0/acp/bundle/interceptor/internal/approval/repository.go +12 -0
  18. acp_ai-0.2.0/acp/bundle/interceptor/internal/approval/store.go +221 -0
  19. acp_ai-0.2.0/acp/bundle/interceptor/internal/approval/store_test.go +47 -0
  20. acp_ai-0.2.0/acp/bundle/interceptor/internal/approval/sync.go +48 -0
  21. acp_ai-0.2.0/acp/bundle/interceptor/internal/approval/sync_test.go +53 -0
  22. acp_ai-0.2.0/acp/bundle/interceptor/internal/audit/events.go +6 -0
  23. acp_ai-0.2.0/acp/bundle/interceptor/internal/audit/logger.go +52 -0
  24. acp_ai-0.2.0/acp/bundle/interceptor/internal/audit/store.go +97 -0
  25. acp_ai-0.2.0/acp/bundle/interceptor/internal/audit/store_iface.go +8 -0
  26. acp_ai-0.2.0/acp/bundle/interceptor/internal/auth/context.go +41 -0
  27. acp_ai-0.2.0/acp/bundle/interceptor/internal/auth/load.go +42 -0
  28. acp_ai-0.2.0/acp/bundle/interceptor/internal/auth/principal.go +9 -0
  29. acp_ai-0.2.0/acp/bundle/interceptor/internal/auth/validator.go +168 -0
  30. acp_ai-0.2.0/acp/bundle/interceptor/internal/auth/validator_test.go +61 -0
  31. acp_ai-0.2.0/acp/bundle/interceptor/internal/config/config.go +24 -0
  32. acp_ai-0.2.0/acp/bundle/interceptor/internal/config/env.go +83 -0
  33. acp_ai-0.2.0/acp/bundle/interceptor/internal/gateway/bootstrap.go +51 -0
  34. acp_ai-0.2.0/acp/bundle/interceptor/internal/gateway/router.go +35 -0
  35. acp_ai-0.2.0/acp/bundle/interceptor/internal/gateway/routes.go +38 -0
  36. acp_ai-0.2.0/acp/bundle/interceptor/internal/gateway/server.go +87 -0
  37. acp_ai-0.2.0/acp/bundle/interceptor/internal/handlers/agent_handler.go +94 -0
  38. acp_ai-0.2.0/acp/bundle/interceptor/internal/handlers/approval_handler.go +122 -0
  39. acp_ai-0.2.0/acp/bundle/interceptor/internal/handlers/insights_handler.go +37 -0
  40. acp_ai-0.2.0/acp/bundle/interceptor/internal/handlers/policy_catalog_handler.go +35 -0
  41. acp_ai-0.2.0/acp/bundle/interceptor/internal/handlers/tool_handler.go +51 -0
  42. acp_ai-0.2.0/acp/bundle/interceptor/internal/middleware/auth.go +29 -0
  43. acp_ai-0.2.0/acp/bundle/interceptor/internal/middleware/cors.go +60 -0
  44. acp_ai-0.2.0/acp/bundle/interceptor/internal/middleware/jwt.go +47 -0
  45. acp_ai-0.2.0/acp/bundle/interceptor/internal/middleware/logging.go +35 -0
  46. acp_ai-0.2.0/acp/bundle/interceptor/internal/middleware/recovery.go +27 -0
  47. acp_ai-0.2.0/acp/bundle/interceptor/internal/middleware/tracing.go +15 -0
  48. acp_ai-0.2.0/acp/bundle/interceptor/internal/models/policy.go +38 -0
  49. acp_ai-0.2.0/acp/bundle/interceptor/internal/models/request.go +11 -0
  50. acp_ai-0.2.0/acp/bundle/interceptor/internal/models/response.go +8 -0
  51. acp_ai-0.2.0/acp/bundle/interceptor/internal/policy/evaluator.go +64 -0
  52. acp_ai-0.2.0/acp/bundle/interceptor/internal/policy/mapper.go +33 -0
  53. acp_ai-0.2.0/acp/bundle/interceptor/internal/policy/opa_client.go +83 -0
  54. acp_ai-0.2.0/acp/bundle/interceptor/internal/policycatalog/rules.go +242 -0
  55. acp_ai-0.2.0/acp/bundle/interceptor/internal/policycatalog/rules_test.go +80 -0
  56. acp_ai-0.2.0/acp/bundle/interceptor/internal/policycatalog/scanner.go +126 -0
  57. acp_ai-0.2.0/acp/bundle/interceptor/internal/policycatalog/scanner_test.go +54 -0
  58. acp_ai-0.2.0/acp/bundle/interceptor/internal/registry/agent.go +53 -0
  59. acp_ai-0.2.0/acp/bundle/interceptor/internal/registry/memory.go +154 -0
  60. acp_ai-0.2.0/acp/bundle/interceptor/internal/services/audit_service.go +18 -0
  61. acp_ai-0.2.0/acp/bundle/interceptor/internal/services/interceptor_service.go +183 -0
  62. acp_ai-0.2.0/acp/bundle/interceptor/internal/services/policy_service.go +23 -0
  63. acp_ai-0.2.0/acp/bundle/interceptor/internal/storage/postgres/agents.go +153 -0
  64. acp_ai-0.2.0/acp/bundle/interceptor/internal/storage/postgres/approval.go +171 -0
  65. acp_ai-0.2.0/acp/bundle/interceptor/internal/storage/postgres/audit.go +127 -0
  66. acp_ai-0.2.0/acp/bundle/interceptor/internal/storage/postgres/db.go +62 -0
  67. acp_ai-0.2.0/acp/bundle/interceptor/internal/storage/postgres/migrations/001_schema.sql +55 -0
  68. acp_ai-0.2.0/acp/bundle/interceptor/internal/storage/postgres/migrations/002_seed_agents.sql +7 -0
  69. acp_ai-0.2.0/acp/bundle/interceptor/internal/tracing/context.go +24 -0
  70. acp_ai-0.2.0/acp/bundle/interceptor/internal/tracing/trace.go +34 -0
  71. acp_ai-0.2.0/acp/bundle/interceptor/internal/utils/errors.go +13 -0
  72. acp_ai-0.2.0/acp/bundle/interceptor/internal/utils/response.go +28 -0
  73. acp_ai-0.2.0/acp/bundle/interceptor/internal/utils/validation.go +21 -0
  74. acp_ai-0.2.0/acp/bundle/interceptor/policies/README.md +102 -0
  75. acp_ai-0.2.0/acp/bundle/interceptor/policies/mortgage_application.rego +25 -0
  76. acp_ai-0.2.0/acp/bundle/interceptor/policies/mortgage_underwriting.rego +34 -0
  77. acp_ai-0.2.0/acp/bundle/interceptor/policies/rbac.rego +50 -0
  78. acp_ai-0.2.0/acp/bundle/interceptor/policies/router.rego +30 -0
  79. acp_ai-0.2.0/acp/bundle/interceptor/scripts/generate-jwt-keys.sh +35 -0
  80. acp_ai-0.2.0/acp/bundle/interceptor/scripts/run-local.sh +24 -0
  81. acp_ai-0.2.0/acp/bundle/jwt/public.pem +9 -0
  82. acp_ai-0.2.0/acp/bundle/nginx-dashboard.conf +26 -0
  83. acp_ai-0.2.0/acp/bundle/nginx-gateway.conf +36 -0
  84. acp_ai-0.2.0/acp/bundle/policies/README.md +102 -0
  85. acp_ai-0.2.0/acp/bundle/policies/mortgage_application.rego +25 -0
  86. acp_ai-0.2.0/acp/bundle/policies/mortgage_underwriting.rego +34 -0
  87. acp_ai-0.2.0/acp/bundle/policies/rbac.rego +50 -0
  88. acp_ai-0.2.0/acp/bundle/policies/router.rego +30 -0
  89. acp_ai-0.2.0/acp/bundle/public/index.html +12 -0
  90. acp_ai-0.2.0/acp/cli.py +176 -0
  91. acp_ai-0.2.0/acp/client.py +215 -0
  92. acp_ai-0.2.0/acp/config.py +19 -0
  93. acp_ai-0.2.0/acp/decorators.py +61 -0
  94. acp_ai-0.2.0/acp/exceptions.py +30 -0
  95. acp_ai-0.2.0/acp/policies.py +104 -0
  96. acp_ai-0.2.0/acp/policy-starter/mortgage_application.rego +25 -0
  97. acp_ai-0.2.0/acp/policy-starter/mortgage_underwriting.rego +34 -0
  98. acp_ai-0.2.0/acp/policy-starter/rbac.rego +50 -0
  99. acp_ai-0.2.0/acp/policy-starter/router.rego +30 -0
  100. acp_ai-0.2.0/acp/runtime.py +93 -0
  101. acp_ai-0.2.0/acp_ai.egg-info/PKG-INFO +154 -0
  102. acp_ai-0.2.0/acp_ai.egg-info/SOURCES.txt +107 -0
  103. acp_ai-0.2.0/acp_ai.egg-info/dependency_links.txt +1 -0
  104. acp_ai-0.2.0/acp_ai.egg-info/entry_points.txt +2 -0
  105. acp_ai-0.2.0/acp_ai.egg-info/requires.txt +6 -0
  106. acp_ai-0.2.0/acp_ai.egg-info/top_level.txt +1 -0
  107. acp_ai-0.2.0/pyproject.toml +47 -0
  108. acp_ai-0.2.0/setup.cfg +4 -0
  109. acp_ai-0.2.0/tests/test_decorator.py +41 -0
acp_ai-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Raja Datascientist
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 @@
1
+ recursive-include acp/bundle *
acp_ai-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: acp-ai
3
+ Version: 0.2.0
4
+ Summary: Agent Control Plane — SDK and CLI for governed agent execution with a local Docker stack.
5
+ Author: Raja Datascientist
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/raja-datascientist/ACP
8
+ Project-URL: Documentation, https://github.com/raja-datascientist/ACP/tree/main/sdk/python
9
+ Project-URL: Repository, https://github.com/raja-datascientist/ACP
10
+ Project-URL: Issues, https://github.com/raja-datascientist/ACP/issues
11
+ Keywords: ai,agents,governance,policy,opa,control-plane
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests>=2.31
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7.0; extra == "dev"
25
+ Requires-Dist: build>=1.0; extra == "dev"
26
+ Requires-Dist: twine>=5.0; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # ACP Control Plane — Python SDK + CLI
30
+
31
+ **PyPI:** `acp-ai` · **Import:** `acp`
32
+
33
+ One pip install gives you a **local governance stack**: intercept tool calls, evaluate **your** OPA/Rego rules, persist audit + agent registry in Postgres, and view everything in the dashboard.
34
+
35
+ **Requires:** [Docker Desktop](https://docs.docker.com/get-docker/) (Compose v2). All `acp` commands run in your **terminal** (Terminal.app, iTerm, or the IDE integrated terminal).
36
+
37
+ ---
38
+
39
+ ## Install (terminal)
40
+
41
+ ```bash
42
+ pip install acp-ai
43
+ acp doctor
44
+ ```
45
+
46
+ ---
47
+
48
+ ## First-time setup (terminal)
49
+
50
+ Run these in order from **any directory** (home folder is fine):
51
+
52
+ ```bash
53
+ # 1. Create your editable policy folder (~/.acp/policies)
54
+ acp init
55
+
56
+ # 2. Start local stack: Postgres + OPA + interceptor + dashboard
57
+ acp up --build
58
+
59
+ # 3. Open governance dashboard in browser
60
+ acp dashboard
61
+ ```
62
+
63
+ | Command | What it does | Where it runs |
64
+ |---------|--------------|---------------|
65
+ | **`acp init`** | Creates `~/.acp/policies/` with starter `.rego` files + `HOW_TO_ADD_RULES.md` | **Your terminal** |
66
+ | **`acp up --build`** | Starts Docker containers (first time builds interceptor image) | **Your terminal** (needs Docker running) |
67
+ | **`acp up`** | Starts stack without rebuild (after first `--build`) | **Your terminal** |
68
+ | **`acp down`** | Stops containers | **Your terminal** |
69
+ | **`acp status`** | Container + health check status | **Your terminal** |
70
+ | **`acp dashboard`** | Opens http://localhost:3090/dashboard/ | **Your terminal** |
71
+ | **`acp doctor`** | Checks Docker + package install | **Your terminal** |
72
+
73
+ ---
74
+
75
+ ## Your rules (editable after pip install)
76
+
77
+ Policies are **yours**, not locked inside the package:
78
+
79
+ ```
80
+ ~/.acp/policies/
81
+ ├── HOW_TO_ADD_RULES.md
82
+ ├── router.rego ← route tools → policies
83
+ ├── rbac.rego ← JWT roles → tools
84
+ ├── mortgage_application.rego ← commented sample (loan submit)
85
+ └── mortgage_underwriting.rego ← commented sample (score_loan / escalate)
86
+ ```
87
+
88
+ Edit files in `~/.acp/policies/`, then restart:
89
+
90
+ ```bash
91
+ acp down && acp up
92
+ ```
93
+
94
+ Custom policy path (optional):
95
+
96
+ ```bash
97
+ export ACP_POLICIES_DIR=/path/to/my/policies
98
+ acp up
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Use in your agent project (any framework)
104
+
105
+ In **your project folder** (separate from ACP), activate a venv and use the SDK:
106
+
107
+ ```python
108
+ import os
109
+ from acp import governed_tool
110
+
111
+ os.environ.setdefault("ACP_INTERCEPTOR_URL", "http://localhost:8080")
112
+
113
+ @governed_tool(agent_id="my-agent", tool="my_tool_api", action="run_action")
114
+ def my_tool(amount: int) -> str:
115
+ return f"ok:{amount}"
116
+ ```
117
+
118
+ Works with CrewAI, Strands, LangGraph, or plain Python.
119
+
120
+ Register agents via dashboard **Agent Registry** or `POST /api/v1/agents`.
121
+
122
+ ---
123
+
124
+ ## Local URLs
125
+
126
+ | URL | Purpose |
127
+ |-----|---------|
128
+ | http://localhost:3090/dashboard/ | **Dashboard** (events, policies, registry, approvals) |
129
+ | http://localhost:8080 | Interceptor API (`/tool-call`, `/api/v1/*`) |
130
+
131
+ ---
132
+
133
+ ## What Docker starts
134
+
135
+ | Service | Role |
136
+ |---------|------|
137
+ | **Postgres** | Audit log, agent registry, approvals |
138
+ | **OPA** | Evaluates your Rego from `~/.acp/policies/` |
139
+ | **Interceptor** | PEP — `POST /tool-call`, JWT, registry |
140
+ | **Dashboard** | Governance UI |
141
+ | **Gateway** | Single origin on `:3090` |
142
+
143
+ Also on disk: `~/.acp/jwt/` (dev RS256 keys), `~/.acp/runtime/` (compose + images).
144
+
145
+ ---
146
+
147
+ ## Maintainers (ACP monorepo)
148
+
149
+ ```bash
150
+ cd sdk/python
151
+ ./scripts/sync_bundle.sh
152
+ ./scripts/publish_pypi.sh
153
+ twine upload dist/*
154
+ ```
acp_ai-0.2.0/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # ACP Control Plane — Python SDK + CLI
2
+
3
+ **PyPI:** `acp-ai` · **Import:** `acp`
4
+
5
+ One pip install gives you a **local governance stack**: intercept tool calls, evaluate **your** OPA/Rego rules, persist audit + agent registry in Postgres, and view everything in the dashboard.
6
+
7
+ **Requires:** [Docker Desktop](https://docs.docker.com/get-docker/) (Compose v2). All `acp` commands run in your **terminal** (Terminal.app, iTerm, or the IDE integrated terminal).
8
+
9
+ ---
10
+
11
+ ## Install (terminal)
12
+
13
+ ```bash
14
+ pip install acp-ai
15
+ acp doctor
16
+ ```
17
+
18
+ ---
19
+
20
+ ## First-time setup (terminal)
21
+
22
+ Run these in order from **any directory** (home folder is fine):
23
+
24
+ ```bash
25
+ # 1. Create your editable policy folder (~/.acp/policies)
26
+ acp init
27
+
28
+ # 2. Start local stack: Postgres + OPA + interceptor + dashboard
29
+ acp up --build
30
+
31
+ # 3. Open governance dashboard in browser
32
+ acp dashboard
33
+ ```
34
+
35
+ | Command | What it does | Where it runs |
36
+ |---------|--------------|---------------|
37
+ | **`acp init`** | Creates `~/.acp/policies/` with starter `.rego` files + `HOW_TO_ADD_RULES.md` | **Your terminal** |
38
+ | **`acp up --build`** | Starts Docker containers (first time builds interceptor image) | **Your terminal** (needs Docker running) |
39
+ | **`acp up`** | Starts stack without rebuild (after first `--build`) | **Your terminal** |
40
+ | **`acp down`** | Stops containers | **Your terminal** |
41
+ | **`acp status`** | Container + health check status | **Your terminal** |
42
+ | **`acp dashboard`** | Opens http://localhost:3090/dashboard/ | **Your terminal** |
43
+ | **`acp doctor`** | Checks Docker + package install | **Your terminal** |
44
+
45
+ ---
46
+
47
+ ## Your rules (editable after pip install)
48
+
49
+ Policies are **yours**, not locked inside the package:
50
+
51
+ ```
52
+ ~/.acp/policies/
53
+ ├── HOW_TO_ADD_RULES.md
54
+ ├── router.rego ← route tools → policies
55
+ ├── rbac.rego ← JWT roles → tools
56
+ ├── mortgage_application.rego ← commented sample (loan submit)
57
+ └── mortgage_underwriting.rego ← commented sample (score_loan / escalate)
58
+ ```
59
+
60
+ Edit files in `~/.acp/policies/`, then restart:
61
+
62
+ ```bash
63
+ acp down && acp up
64
+ ```
65
+
66
+ Custom policy path (optional):
67
+
68
+ ```bash
69
+ export ACP_POLICIES_DIR=/path/to/my/policies
70
+ acp up
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Use in your agent project (any framework)
76
+
77
+ In **your project folder** (separate from ACP), activate a venv and use the SDK:
78
+
79
+ ```python
80
+ import os
81
+ from acp import governed_tool
82
+
83
+ os.environ.setdefault("ACP_INTERCEPTOR_URL", "http://localhost:8080")
84
+
85
+ @governed_tool(agent_id="my-agent", tool="my_tool_api", action="run_action")
86
+ def my_tool(amount: int) -> str:
87
+ return f"ok:{amount}"
88
+ ```
89
+
90
+ Works with CrewAI, Strands, LangGraph, or plain Python.
91
+
92
+ Register agents via dashboard **Agent Registry** or `POST /api/v1/agents`.
93
+
94
+ ---
95
+
96
+ ## Local URLs
97
+
98
+ | URL | Purpose |
99
+ |-----|---------|
100
+ | http://localhost:3090/dashboard/ | **Dashboard** (events, policies, registry, approvals) |
101
+ | http://localhost:8080 | Interceptor API (`/tool-call`, `/api/v1/*`) |
102
+
103
+ ---
104
+
105
+ ## What Docker starts
106
+
107
+ | Service | Role |
108
+ |---------|------|
109
+ | **Postgres** | Audit log, agent registry, approvals |
110
+ | **OPA** | Evaluates your Rego from `~/.acp/policies/` |
111
+ | **Interceptor** | PEP — `POST /tool-call`, JWT, registry |
112
+ | **Dashboard** | Governance UI |
113
+ | **Gateway** | Single origin on `:3090` |
114
+
115
+ Also on disk: `~/.acp/jwt/` (dev RS256 keys), `~/.acp/runtime/` (compose + images).
116
+
117
+ ---
118
+
119
+ ## Maintainers (ACP monorepo)
120
+
121
+ ```bash
122
+ cd sdk/python
123
+ ./scripts/sync_bundle.sh
124
+ ./scripts/publish_pypi.sh
125
+ twine upload dist/*
126
+ ```
@@ -0,0 +1,16 @@
1
+ """ACP Python SDK + CLI — governed execution client for the interceptor."""
2
+
3
+ __version__ = "0.2.0"
4
+
5
+ from acp.client import ACPClient, ToolCallResponse
6
+ from acp.decorators import governed_tool
7
+ from acp.exceptions import ACPSDKError, PolicyDenied, PolicyEscalated
8
+
9
+ __all__ = [
10
+ "ACPClient",
11
+ "ToolCallResponse",
12
+ "governed_tool",
13
+ "ACPSDKError",
14
+ "PolicyDenied",
15
+ "PolicyEscalated",
16
+ ]