acl-core-py 1.75__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.
- acl_core_py-1.75/.gitignore +24 -0
- acl_core_py-1.75/LICENSE +24 -0
- acl_core_py-1.75/PKG-INFO +194 -0
- acl_core_py-1.75/README.md +128 -0
- acl_core_py-1.75/acl/__init__.py +44 -0
- acl_core_py-1.75/acl/client.py +764 -0
- acl_core_py-1.75/acl/config.py +73 -0
- acl_core_py-1.75/acl/exceptions.py +112 -0
- acl_core_py-1.75/acl/http.py +174 -0
- acl_core_py-1.75/acl/middlewares/base.py +16 -0
- acl_core_py-1.75/acl/middlewares/loop_detection.py +132 -0
- acl_core_py-1.75/acl/middlewares/normalization.py +50 -0
- acl_core_py-1.75/acl/middlewares/recovery.py +219 -0
- acl_core_py-1.75/acl/middlewares/retry.py +52 -0
- acl_core_py-1.75/acl/providers/__init__.py +33 -0
- acl_core_py-1.75/acl/providers/anthropic.py +110 -0
- acl_core_py-1.75/acl/providers/base.py +45 -0
- acl_core_py-1.75/acl/providers/google.py +132 -0
- acl_core_py-1.75/acl/providers/openai.py +128 -0
- acl_core_py-1.75/acl/security.py +18 -0
- acl_core_py-1.75/acl/session/manager.py +173 -0
- acl_core_py-1.75/acl/similarity/engine.py +157 -0
- acl_core_py-1.75/acl/types.py +98 -0
- acl_core_py-1.75/pyproject.toml +241 -0
- acl_core_py-1.75/tests/test_complete_contract.py +86 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Environment files
|
|
2
|
+
.env
|
|
3
|
+
.env.development
|
|
4
|
+
.env.production
|
|
5
|
+
|
|
6
|
+
# Python
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.pyc
|
|
9
|
+
*.pyo
|
|
10
|
+
*.pyd
|
|
11
|
+
venv/
|
|
12
|
+
.venv/
|
|
13
|
+
|
|
14
|
+
# Logs & telemetry
|
|
15
|
+
logs/
|
|
16
|
+
*.log
|
|
17
|
+
telemetry/*.jsonl
|
|
18
|
+
|
|
19
|
+
# Misc
|
|
20
|
+
.DS_Store
|
|
21
|
+
node_modules/
|
|
22
|
+
*.egg-info/
|
|
23
|
+
dist/
|
|
24
|
+
build/
|
acl_core_py-1.75/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
ACL SDK PROPRIETARY LICENSE
|
|
2
|
+
Copyright (c) 2026 ACL Team. All rights reserved.
|
|
3
|
+
|
|
4
|
+
This SDK is proprietary software and is licensed, not sold.
|
|
5
|
+
|
|
6
|
+
Permitted use:
|
|
7
|
+
- Use only to access ACL services with a valid ACL-issued API key.
|
|
8
|
+
- Internal use by authorized users and systems under your organization.
|
|
9
|
+
|
|
10
|
+
Not permitted without prior written permission from ACL Team:
|
|
11
|
+
- Redistribute, sublicense, resell, rent, lease, or transfer this SDK.
|
|
12
|
+
- Modify, create derivative works, reverse engineer, decompile, or disassemble this SDK.
|
|
13
|
+
- Use this SDK to build or operate a competing service.
|
|
14
|
+
|
|
15
|
+
No open-source grant:
|
|
16
|
+
- No rights are granted under any open-source license.
|
|
17
|
+
|
|
18
|
+
Termination:
|
|
19
|
+
- Any violation of these terms immediately terminates your license to use this SDK.
|
|
20
|
+
|
|
21
|
+
Disclaimer:
|
|
22
|
+
- The SDK is provided "as is" without warranties of any kind, to the maximum extent permitted by law.
|
|
23
|
+
|
|
24
|
+
For commercial or redistribution permissions, contact: support@fridayaicore.in
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: acl-core-py
|
|
3
|
+
Version: 1.75
|
|
4
|
+
Summary: Official Python client for the Adaptive Context Layer (ACL)
|
|
5
|
+
Project-URL: Homepage, https://github.com/acl-team/acl-core-py
|
|
6
|
+
Project-URL: Documentation, https://docs.fridayaicore.in/python-sdk
|
|
7
|
+
Project-URL: Repository, https://github.com/acl-team/acl-core-py
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/acl-team/acl-core-py/issues
|
|
9
|
+
Project-URL: API Documentation, https://docs.fridayaicore.in
|
|
10
|
+
Author-email: ACL Team <support@fridayaicore.in>
|
|
11
|
+
Maintainer-email: ACL Team <support@fridayaicore.in>
|
|
12
|
+
License: ACL SDK PROPRIETARY LICENSE
|
|
13
|
+
Copyright (c) 2026 ACL Team. All rights reserved.
|
|
14
|
+
|
|
15
|
+
This SDK is proprietary software and is licensed, not sold.
|
|
16
|
+
|
|
17
|
+
Permitted use:
|
|
18
|
+
- Use only to access ACL services with a valid ACL-issued API key.
|
|
19
|
+
- Internal use by authorized users and systems under your organization.
|
|
20
|
+
|
|
21
|
+
Not permitted without prior written permission from ACL Team:
|
|
22
|
+
- Redistribute, sublicense, resell, rent, lease, or transfer this SDK.
|
|
23
|
+
- Modify, create derivative works, reverse engineer, decompile, or disassemble this SDK.
|
|
24
|
+
- Use this SDK to build or operate a competing service.
|
|
25
|
+
|
|
26
|
+
No open-source grant:
|
|
27
|
+
- No rights are granted under any open-source license.
|
|
28
|
+
|
|
29
|
+
Termination:
|
|
30
|
+
- Any violation of these terms immediately terminates your license to use this SDK.
|
|
31
|
+
|
|
32
|
+
Disclaimer:
|
|
33
|
+
- The SDK is provided "as is" without warranties of any kind, to the maximum extent permitted by law.
|
|
34
|
+
|
|
35
|
+
For commercial or redistribution permissions, contact: support@fridayaicore.in
|
|
36
|
+
License-File: LICENSE
|
|
37
|
+
Keywords: acl,adaptive,ai,context,llm,machine-learning,optimization,token,window
|
|
38
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
39
|
+
Classifier: Intended Audience :: Developers
|
|
40
|
+
Classifier: License :: Other/Proprietary License
|
|
41
|
+
Classifier: Operating System :: OS Independent
|
|
42
|
+
Classifier: Programming Language :: Python :: 3
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
45
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
46
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
47
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
48
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
49
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
50
|
+
Requires-Python: >=3.8
|
|
51
|
+
Requires-Dist: requests>=2.25.0
|
|
52
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
53
|
+
Requires-Dist: urllib3>=1.26.0
|
|
54
|
+
Provides-Extra: dev
|
|
55
|
+
Requires-Dist: black>=21.0.0; extra == 'dev'
|
|
56
|
+
Requires-Dist: flake8>=3.8.0; extra == 'dev'
|
|
57
|
+
Requires-Dist: isort>=5.0.0; extra == 'dev'
|
|
58
|
+
Requires-Dist: mypy>=0.800; extra == 'dev'
|
|
59
|
+
Requires-Dist: pytest-cov>=2.10.0; extra == 'dev'
|
|
60
|
+
Requires-Dist: pytest>=6.0.0; extra == 'dev'
|
|
61
|
+
Provides-Extra: test
|
|
62
|
+
Requires-Dist: pytest-cov>=2.10.0; extra == 'test'
|
|
63
|
+
Requires-Dist: pytest>=6.0.0; extra == 'test'
|
|
64
|
+
Requires-Dist: responses>=0.12.0; extra == 'test'
|
|
65
|
+
Description-Content-Type: text/markdown
|
|
66
|
+
|
|
67
|
+
# ACL Python SDK (`acl-core-py`)
|
|
68
|
+
|
|
69
|
+
Official Python SDK for Adaptive Context Layer (ACL).
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install acl-core-py
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## AI Agent Install And Infra Setup
|
|
78
|
+
|
|
79
|
+
Use this flow when agents/dev tools install and run ACL in production:
|
|
80
|
+
|
|
81
|
+
1. Install SDK
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install --upgrade acl-core-py
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
2. Set environment variables (domain only, never raw server IP)
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Public ACL endpoint behind your domain/reverse proxy
|
|
91
|
+
export ACL_BASE_URL="https://backend.yourcompany.com"
|
|
92
|
+
|
|
93
|
+
# Org-scoped ACL key from ACL dashboard
|
|
94
|
+
export ACL_API_KEY="acl_live_xxx"
|
|
95
|
+
|
|
96
|
+
# Provider key stays only with your app/agent runtime
|
|
97
|
+
export OPENAI_API_KEY="sk-xxx"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
3. Initialize client using env vars
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
import os
|
|
104
|
+
from acl import ACLClient
|
|
105
|
+
|
|
106
|
+
client = ACLClient(
|
|
107
|
+
api_key=os.environ["ACL_API_KEY"],
|
|
108
|
+
base_url=os.environ["ACL_BASE_URL"],
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Security notes:
|
|
113
|
+
- Do not hardcode keys in source code.
|
|
114
|
+
- Do not expose EC2/public IP in SDK config; always use DNS/domain.
|
|
115
|
+
- Rotate keys immediately if logs/screenshots accidentally leak them.
|
|
116
|
+
- Keep backend behind TLS (`https`) and firewall to trusted ports only.
|
|
117
|
+
|
|
118
|
+
## Quick Start
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from acl import ACLClient
|
|
122
|
+
|
|
123
|
+
client = ACLClient(api_key="acl_live_...")
|
|
124
|
+
|
|
125
|
+
result = client.complete(
|
|
126
|
+
prompt="Summarize this incident report.",
|
|
127
|
+
model="gpt-4o",
|
|
128
|
+
llm_api_key="sk-...",
|
|
129
|
+
max_retries=3,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
if result["success"]:
|
|
133
|
+
print(result["response"])
|
|
134
|
+
else:
|
|
135
|
+
print(f"{result['error_code']}: {result['error_message']}")
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Latency Controls (v1.75)
|
|
139
|
+
|
|
140
|
+
`ACLClient(...)` supports these runtime options:
|
|
141
|
+
|
|
142
|
+
- `emit_post_completion_telemetry` (default: `True`): post-completion telemetry is now non-blocking.
|
|
143
|
+
- `precheck_cache_ttl_s` (default: `20.0`): short TTL cache for adaptive precheck calls.
|
|
144
|
+
- `precheck_cache_max_entries` (default: `256`): max in-memory precheck cache entries.
|
|
145
|
+
|
|
146
|
+
Every `complete()` response now includes timing metadata under `metadata.acl_timing`:
|
|
147
|
+
|
|
148
|
+
- `precheck_ms`
|
|
149
|
+
- `provider_ms`
|
|
150
|
+
- `post_telemetry_ms`
|
|
151
|
+
- `wall_clock_ms`
|
|
152
|
+
|
|
153
|
+
## Runtime Contract
|
|
154
|
+
|
|
155
|
+
`complete()` always returns a stable top-level response shape on both success and failure:
|
|
156
|
+
|
|
157
|
+
- `success`
|
|
158
|
+
- `error_code`
|
|
159
|
+
- `error_message`
|
|
160
|
+
- `provider`
|
|
161
|
+
- `model`
|
|
162
|
+
- `text` and `response`
|
|
163
|
+
|
|
164
|
+
## Validation and Safety
|
|
165
|
+
|
|
166
|
+
- Fail-fast validation for invalid/missing `prompt`, unresolved `model`, missing keys, and malformed provider key formats.
|
|
167
|
+
- Strict provider payload allowlist prevents internal ACL params from leaking to provider APIs.
|
|
168
|
+
- Secrets are redacted from surfaced error messages by default.
|
|
169
|
+
- Default ACL backend base URL: `http://backend.fridayaicore.in`.
|
|
170
|
+
|
|
171
|
+
## Retry Behavior
|
|
172
|
+
|
|
173
|
+
- Retries happen in SDK provider execution middleware (`complete()` path).
|
|
174
|
+
- Exponential backoff with jitter and cap:
|
|
175
|
+
- attempt 1: random delay `0-0.5s`
|
|
176
|
+
- attempt 2: random delay `0-1s`
|
|
177
|
+
- attempt 3: random delay `0-2s`
|
|
178
|
+
- max cap per attempt: `8s`
|
|
179
|
+
|
|
180
|
+
## Compatibility Policy
|
|
181
|
+
|
|
182
|
+
- Python: `>=3.8`
|
|
183
|
+
- Runtime dependencies: `requests`, `urllib3`, `typing_extensions`
|
|
184
|
+
- Release policy: include migration notes whenever response contract or validation behavior changes.
|
|
185
|
+
|
|
186
|
+
## Usage Terms
|
|
187
|
+
|
|
188
|
+
- This SDK is proprietary and licensed for ACL service access only.
|
|
189
|
+
- A valid ACL API key is required.
|
|
190
|
+
- Redistribution, resale, sublicensing, and derivative redistribution are not permitted without written approval from ACL Team.
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
UNLICENSED / Proprietary. See `LICENSE`.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# ACL Python SDK (`acl-core-py`)
|
|
2
|
+
|
|
3
|
+
Official Python SDK for Adaptive Context Layer (ACL).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install acl-core-py
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## AI Agent Install And Infra Setup
|
|
12
|
+
|
|
13
|
+
Use this flow when agents/dev tools install and run ACL in production:
|
|
14
|
+
|
|
15
|
+
1. Install SDK
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install --upgrade acl-core-py
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
2. Set environment variables (domain only, never raw server IP)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Public ACL endpoint behind your domain/reverse proxy
|
|
25
|
+
export ACL_BASE_URL="https://backend.yourcompany.com"
|
|
26
|
+
|
|
27
|
+
# Org-scoped ACL key from ACL dashboard
|
|
28
|
+
export ACL_API_KEY="acl_live_xxx"
|
|
29
|
+
|
|
30
|
+
# Provider key stays only with your app/agent runtime
|
|
31
|
+
export OPENAI_API_KEY="sk-xxx"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
3. Initialize client using env vars
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import os
|
|
38
|
+
from acl import ACLClient
|
|
39
|
+
|
|
40
|
+
client = ACLClient(
|
|
41
|
+
api_key=os.environ["ACL_API_KEY"],
|
|
42
|
+
base_url=os.environ["ACL_BASE_URL"],
|
|
43
|
+
)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Security notes:
|
|
47
|
+
- Do not hardcode keys in source code.
|
|
48
|
+
- Do not expose EC2/public IP in SDK config; always use DNS/domain.
|
|
49
|
+
- Rotate keys immediately if logs/screenshots accidentally leak them.
|
|
50
|
+
- Keep backend behind TLS (`https`) and firewall to trusted ports only.
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from acl import ACLClient
|
|
56
|
+
|
|
57
|
+
client = ACLClient(api_key="acl_live_...")
|
|
58
|
+
|
|
59
|
+
result = client.complete(
|
|
60
|
+
prompt="Summarize this incident report.",
|
|
61
|
+
model="gpt-4o",
|
|
62
|
+
llm_api_key="sk-...",
|
|
63
|
+
max_retries=3,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
if result["success"]:
|
|
67
|
+
print(result["response"])
|
|
68
|
+
else:
|
|
69
|
+
print(f"{result['error_code']}: {result['error_message']}")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Latency Controls (v1.75)
|
|
73
|
+
|
|
74
|
+
`ACLClient(...)` supports these runtime options:
|
|
75
|
+
|
|
76
|
+
- `emit_post_completion_telemetry` (default: `True`): post-completion telemetry is now non-blocking.
|
|
77
|
+
- `precheck_cache_ttl_s` (default: `20.0`): short TTL cache for adaptive precheck calls.
|
|
78
|
+
- `precheck_cache_max_entries` (default: `256`): max in-memory precheck cache entries.
|
|
79
|
+
|
|
80
|
+
Every `complete()` response now includes timing metadata under `metadata.acl_timing`:
|
|
81
|
+
|
|
82
|
+
- `precheck_ms`
|
|
83
|
+
- `provider_ms`
|
|
84
|
+
- `post_telemetry_ms`
|
|
85
|
+
- `wall_clock_ms`
|
|
86
|
+
|
|
87
|
+
## Runtime Contract
|
|
88
|
+
|
|
89
|
+
`complete()` always returns a stable top-level response shape on both success and failure:
|
|
90
|
+
|
|
91
|
+
- `success`
|
|
92
|
+
- `error_code`
|
|
93
|
+
- `error_message`
|
|
94
|
+
- `provider`
|
|
95
|
+
- `model`
|
|
96
|
+
- `text` and `response`
|
|
97
|
+
|
|
98
|
+
## Validation and Safety
|
|
99
|
+
|
|
100
|
+
- Fail-fast validation for invalid/missing `prompt`, unresolved `model`, missing keys, and malformed provider key formats.
|
|
101
|
+
- Strict provider payload allowlist prevents internal ACL params from leaking to provider APIs.
|
|
102
|
+
- Secrets are redacted from surfaced error messages by default.
|
|
103
|
+
- Default ACL backend base URL: `http://backend.fridayaicore.in`.
|
|
104
|
+
|
|
105
|
+
## Retry Behavior
|
|
106
|
+
|
|
107
|
+
- Retries happen in SDK provider execution middleware (`complete()` path).
|
|
108
|
+
- Exponential backoff with jitter and cap:
|
|
109
|
+
- attempt 1: random delay `0-0.5s`
|
|
110
|
+
- attempt 2: random delay `0-1s`
|
|
111
|
+
- attempt 3: random delay `0-2s`
|
|
112
|
+
- max cap per attempt: `8s`
|
|
113
|
+
|
|
114
|
+
## Compatibility Policy
|
|
115
|
+
|
|
116
|
+
- Python: `>=3.8`
|
|
117
|
+
- Runtime dependencies: `requests`, `urllib3`, `typing_extensions`
|
|
118
|
+
- Release policy: include migration notes whenever response contract or validation behavior changes.
|
|
119
|
+
|
|
120
|
+
## Usage Terms
|
|
121
|
+
|
|
122
|
+
- This SDK is proprietary and licensed for ACL service access only.
|
|
123
|
+
- A valid ACL API key is required.
|
|
124
|
+
- Redistribution, resale, sublicensing, and derivative redistribution are not permitted without written approval from ACL Team.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
UNLICENSED / Proprietary. See `LICENSE`.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ACL Python SDK
|
|
3
|
+
|
|
4
|
+
A thin, predictable Python SDK for the Adaptive Context Window API.
|
|
5
|
+
|
|
6
|
+
The SDK provides enterprise-grade error handling and telemetry while delegating
|
|
7
|
+
all intelligence and processing to the ACL backend.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from .client import ACLClient
|
|
11
|
+
from .exceptions import (
|
|
12
|
+
ACLBaseError,
|
|
13
|
+
ACLAuthError,
|
|
14
|
+
ACLPermissionError,
|
|
15
|
+
ACLRateLimitError,
|
|
16
|
+
ACLValidationError,
|
|
17
|
+
ACLServerError,
|
|
18
|
+
)
|
|
19
|
+
from .types import (
|
|
20
|
+
AdaptiveResponse,
|
|
21
|
+
TelemetryData,
|
|
22
|
+
ActivityInfo,
|
|
23
|
+
WindowInfo,
|
|
24
|
+
ModelAdaptation,
|
|
25
|
+
TokenSavings,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__version__ = "1.75"
|
|
29
|
+
__all__ = [
|
|
30
|
+
"ACLClient",
|
|
31
|
+
"ACLBaseError",
|
|
32
|
+
"ACLAuthError",
|
|
33
|
+
"ACLPermissionError",
|
|
34
|
+
"ACLRateLimitError",
|
|
35
|
+
"ACLValidationError",
|
|
36
|
+
"ACLServerError",
|
|
37
|
+
"AdaptiveResponse",
|
|
38
|
+
"TelemetryData",
|
|
39
|
+
"ActivityInfo",
|
|
40
|
+
"WindowInfo",
|
|
41
|
+
"ModelAdaptation",
|
|
42
|
+
"TokenSavings",
|
|
43
|
+
]
|
|
44
|
+
|