aicomply 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.
@@ -0,0 +1,23 @@
1
+ # Secrets / credentials (defense-in-depth; this subtree ships no secrets)
2
+ .env
3
+ .env.*
4
+ !.env.example
5
+ *.pem
6
+ *.key
7
+ *.p12
8
+ *.pfx
9
+ secrets.json
10
+ credentials.json
11
+
12
+ # Python build / cache artifacts
13
+ __pycache__/
14
+ *.py[cod]
15
+ *.egg-info/
16
+ .eggs/
17
+ build/
18
+ dist/
19
+ .pytest_cache/
20
+ .mypy_cache/
21
+ .ruff_cache/
22
+ .venv/
23
+ venv/
aicomply-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 OpenA2A
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing
201
+ permissions and limitations under the License.
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: aicomply
3
+ Version: 0.1.0
4
+ Summary: Inline PII, credential, and regulated-data classifier for AI agent I/O. Dual-layer: deterministic regex + optional semantic Guard. Library + CLI. Python port of @opena2a/aicomply.
5
+ Project-URL: Homepage, https://github.com/opena2a-org/aicomply
6
+ Project-URL: Repository, https://github.com/opena2a-org/aicomply
7
+ Project-URL: Issues, https://github.com/opena2a-org/aicomply/issues
8
+ Author: OpenA2A
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: ai-agent,ai-safety,compliance,credentials,data-loss-prevention,dlp,gdpr,guardrails,hipaa,langchain,llm,llm-security,pci,pii,pii-detection,prompt-injection,redaction,secret-detection
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Security
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.9
19
+ Provides-Extra: dev
20
+ Requires-Dist: mypy>=1.0; extra == 'dev'
21
+ Requires-Dist: pytest>=7.0; extra == 'dev'
22
+ Requires-Dist: ruff>=0.4; extra == 'dev'
23
+ Provides-Extra: langchain
24
+ Requires-Dist: langchain-core>=0.1.0; extra == 'langchain'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # aicomply (Python)
28
+
29
+ Inline PII, credential, and regulated-data classifier for AI agent I/O. Catch
30
+ sensitive content **before** your agent forwards it to a hosted LLM.
31
+
32
+ Dual-layer by design: a deterministic regex layer (PII, credentials, controlled
33
+ markings) that runs always, plus an optional semantic Guard layer when a local
34
+ [nanomind-daemon](https://github.com/opena2a-org) is reachable. The regex layer
35
+ sees through common evasions — Unicode homoglyphs (NFKC), zero-width characters,
36
+ intra-token whitespace, and bounded Base64 / URL-encoded payloads — by normalizing
37
+ the input before matching.
38
+
39
+ This is the Python port of [`@opena2a/aicomply`](https://www.npmjs.com/package/@opena2a/aicomply).
40
+ It reproduces the TypeScript detection baseline against the same shared corpus
41
+ (`bench/corpus`), so verdicts agree across languages.
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ pip install aicomply
47
+ ```
48
+
49
+ ## Try it (CLI)
50
+
51
+ No integration code required — point it at a file or pipe content in:
52
+
53
+ ```bash
54
+ echo "My SSN is 123-45-6789" | aicomply scan
55
+ aicomply scan ./support-ticket.txt
56
+ cat transcript.log | aicomply scan --json
57
+ ```
58
+
59
+ Exit codes make it a drop-in CI gate: `0` CLEAN, `1` findings present, `2` usage error.
60
+
61
+ ## Library API
62
+
63
+ ```python
64
+ from aicomply import comply
65
+
66
+ result = comply("Customer SSN is 516-81-3086, card 5544939082323438.")
67
+
68
+ print(result.verdict) # "VIOLATION"
69
+ for v in result.violations:
70
+ print(v.type, v.value, v.confidence) # SSN 516...86 0.95 (value is masked)
71
+ ```
72
+
73
+ `comply()` returns a `ComplyResult` with:
74
+
75
+ - `verdict` — `"CLEAN"`, `"VIOLATION"`, or `"DENY"`
76
+ - `violations` — each with `type`, masked `value`, `confidence`, `classifier`,
77
+ `view` (which content view caught it), and best-effort `original_start/end`
78
+ - `original_content` / `normalized_content` / `normalizations` — an audit trail
79
+ (omitted on `DENY`, where the input is treated as untrusted bytes)
80
+ - `.to_dict()` — camelCase JSON wire-compatible with the npm package
81
+
82
+ Empty string short-circuits to `CLEAN`; non-`str` input raises `TypeError`.
83
+
84
+ ## Guard an agent's output
85
+
86
+ Drop one decorator above any function that emits text bound for an LLM or a user:
87
+
88
+ ```python
89
+ from aicomply.integrations import guard_output, ComplianceViolation
90
+
91
+ @guard_output() # raise on any PII/credential egress
92
+ def answer(user_msg: str) -> str:
93
+ return call_llm(user_msg)
94
+
95
+ @guard_output(on_violation="redact") # or mask findings in place
96
+ def answer_redacted(user_msg: str) -> str:
97
+ return call_llm(user_msg)
98
+ ```
99
+
100
+ `guard_io()` additionally scans string inputs on the way in.
101
+
102
+ ## LangChain
103
+
104
+ ```bash
105
+ pip install 'aicomply[langchain]'
106
+ ```
107
+
108
+ ```python
109
+ from langchain_openai import ChatOpenAI
110
+ from aicomply.integrations.langchain import AIComplyCallbackHandler
111
+
112
+ llm = ChatOpenAI(callbacks=[AIComplyCallbackHandler()])
113
+ llm.invoke("Summarize this support ticket: ...") # raises if the LLM emits PII
114
+ ```
115
+
116
+ ## Semantic Guard layer
117
+
118
+ The regex layer is deterministic and always on. For prompt-injection /
119
+ exfiltration patterns that regex cannot see, run a local `nanomind-daemon`; when
120
+ it is reachable on `127.0.0.1:47200` the dual-layer classifier consults it and
121
+ merges the verdict (highest severity wins). Its absence never fails a request —
122
+ the classifier silently falls back to regex-only.
123
+
124
+ ## Detection classes
125
+
126
+ SSN, PAN (Luhn + IIN), credentials (AWS keys, GitHub tokens, Bearer tokens,
127
+ `api_key=` patterns), CUI / controlled markings, IBAN (mod-97), passport
128
+ numbers, MRN, NPI (Luhn with `80840` prefix).
129
+
130
+ ## Scope
131
+
132
+ This port covers the deterministic detection layer (regex + normalization +
133
+ dual-layer merge + verdict) plus the daemon Guard client. The TypeScript
134
+ package's Registry-L2, ARP-signature, policy-pack, and session-vault features are
135
+ not yet ported.
136
+
137
+ ## License
138
+
139
+ Apache-2.0.
@@ -0,0 +1,113 @@
1
+ # aicomply (Python)
2
+
3
+ Inline PII, credential, and regulated-data classifier for AI agent I/O. Catch
4
+ sensitive content **before** your agent forwards it to a hosted LLM.
5
+
6
+ Dual-layer by design: a deterministic regex layer (PII, credentials, controlled
7
+ markings) that runs always, plus an optional semantic Guard layer when a local
8
+ [nanomind-daemon](https://github.com/opena2a-org) is reachable. The regex layer
9
+ sees through common evasions — Unicode homoglyphs (NFKC), zero-width characters,
10
+ intra-token whitespace, and bounded Base64 / URL-encoded payloads — by normalizing
11
+ the input before matching.
12
+
13
+ This is the Python port of [`@opena2a/aicomply`](https://www.npmjs.com/package/@opena2a/aicomply).
14
+ It reproduces the TypeScript detection baseline against the same shared corpus
15
+ (`bench/corpus`), so verdicts agree across languages.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pip install aicomply
21
+ ```
22
+
23
+ ## Try it (CLI)
24
+
25
+ No integration code required — point it at a file or pipe content in:
26
+
27
+ ```bash
28
+ echo "My SSN is 123-45-6789" | aicomply scan
29
+ aicomply scan ./support-ticket.txt
30
+ cat transcript.log | aicomply scan --json
31
+ ```
32
+
33
+ Exit codes make it a drop-in CI gate: `0` CLEAN, `1` findings present, `2` usage error.
34
+
35
+ ## Library API
36
+
37
+ ```python
38
+ from aicomply import comply
39
+
40
+ result = comply("Customer SSN is 516-81-3086, card 5544939082323438.")
41
+
42
+ print(result.verdict) # "VIOLATION"
43
+ for v in result.violations:
44
+ print(v.type, v.value, v.confidence) # SSN 516...86 0.95 (value is masked)
45
+ ```
46
+
47
+ `comply()` returns a `ComplyResult` with:
48
+
49
+ - `verdict` — `"CLEAN"`, `"VIOLATION"`, or `"DENY"`
50
+ - `violations` — each with `type`, masked `value`, `confidence`, `classifier`,
51
+ `view` (which content view caught it), and best-effort `original_start/end`
52
+ - `original_content` / `normalized_content` / `normalizations` — an audit trail
53
+ (omitted on `DENY`, where the input is treated as untrusted bytes)
54
+ - `.to_dict()` — camelCase JSON wire-compatible with the npm package
55
+
56
+ Empty string short-circuits to `CLEAN`; non-`str` input raises `TypeError`.
57
+
58
+ ## Guard an agent's output
59
+
60
+ Drop one decorator above any function that emits text bound for an LLM or a user:
61
+
62
+ ```python
63
+ from aicomply.integrations import guard_output, ComplianceViolation
64
+
65
+ @guard_output() # raise on any PII/credential egress
66
+ def answer(user_msg: str) -> str:
67
+ return call_llm(user_msg)
68
+
69
+ @guard_output(on_violation="redact") # or mask findings in place
70
+ def answer_redacted(user_msg: str) -> str:
71
+ return call_llm(user_msg)
72
+ ```
73
+
74
+ `guard_io()` additionally scans string inputs on the way in.
75
+
76
+ ## LangChain
77
+
78
+ ```bash
79
+ pip install 'aicomply[langchain]'
80
+ ```
81
+
82
+ ```python
83
+ from langchain_openai import ChatOpenAI
84
+ from aicomply.integrations.langchain import AIComplyCallbackHandler
85
+
86
+ llm = ChatOpenAI(callbacks=[AIComplyCallbackHandler()])
87
+ llm.invoke("Summarize this support ticket: ...") # raises if the LLM emits PII
88
+ ```
89
+
90
+ ## Semantic Guard layer
91
+
92
+ The regex layer is deterministic and always on. For prompt-injection /
93
+ exfiltration patterns that regex cannot see, run a local `nanomind-daemon`; when
94
+ it is reachable on `127.0.0.1:47200` the dual-layer classifier consults it and
95
+ merges the verdict (highest severity wins). Its absence never fails a request —
96
+ the classifier silently falls back to regex-only.
97
+
98
+ ## Detection classes
99
+
100
+ SSN, PAN (Luhn + IIN), credentials (AWS keys, GitHub tokens, Bearer tokens,
101
+ `api_key=` patterns), CUI / controlled markings, IBAN (mod-97), passport
102
+ numbers, MRN, NPI (Luhn with `80840` prefix).
103
+
104
+ ## Scope
105
+
106
+ This port covers the deterministic detection layer (regex + normalization +
107
+ dual-layer merge + verdict) plus the daemon Guard client. The TypeScript
108
+ package's Registry-L2, ARP-signature, policy-pack, and session-vault features are
109
+ not yet ported.
110
+
111
+ ## License
112
+
113
+ Apache-2.0.
@@ -0,0 +1,69 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "aicomply"
7
+ version = "0.1.0"
8
+ description = "Inline PII, credential, and regulated-data classifier for AI agent I/O. Dual-layer: deterministic regex + optional semantic Guard. Library + CLI. Python port of @opena2a/aicomply."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ requires-python = ">=3.9"
12
+ authors = [{ name = "OpenA2A" }]
13
+ keywords = [
14
+ "pii",
15
+ "pii-detection",
16
+ "compliance",
17
+ "redaction",
18
+ "credentials",
19
+ "secret-detection",
20
+ "data-loss-prevention",
21
+ "dlp",
22
+ "llm",
23
+ "llm-security",
24
+ "ai-agent",
25
+ "ai-safety",
26
+ "prompt-injection",
27
+ "guardrails",
28
+ "langchain",
29
+ "hipaa",
30
+ "pci",
31
+ "gdpr",
32
+ ]
33
+ classifiers = [
34
+ "Development Status :: 4 - Beta",
35
+ "Intended Audience :: Developers",
36
+ "License :: OSI Approved :: Apache Software License",
37
+ "Programming Language :: Python :: 3",
38
+ "Topic :: Security",
39
+ "Topic :: Software Development :: Libraries :: Python Modules",
40
+ ]
41
+ dependencies = []
42
+
43
+ [project.optional-dependencies]
44
+ langchain = ["langchain-core>=0.1.0"]
45
+ dev = ["pytest>=7.0", "ruff>=0.4", "mypy>=1.0"]
46
+
47
+ [project.urls]
48
+ Homepage = "https://github.com/opena2a-org/aicomply"
49
+ Repository = "https://github.com/opena2a-org/aicomply"
50
+ Issues = "https://github.com/opena2a-org/aicomply/issues"
51
+
52
+ [project.scripts]
53
+ aicomply = "aicomply.cli:main"
54
+
55
+ [tool.hatch.build.targets.wheel]
56
+ packages = ["src/aicomply"]
57
+
58
+ [tool.hatch.build.targets.sdist]
59
+ include = ["src/aicomply", "README.md", "LICENSE"]
60
+
61
+ [tool.ruff]
62
+ line-length = 100
63
+ src = ["src", "tests"]
64
+
65
+ [tool.ruff.lint]
66
+ select = ["E", "F", "I", "UP", "B"]
67
+
68
+ [tool.pytest.ini_options]
69
+ testpaths = ["tests"]
@@ -0,0 +1,94 @@
1
+ """aicomply -- dual-layer compliance classifier for AI agent I/O (Python port).
2
+
3
+ Public API: ``comply()`` is the main entry point. Pass content and get back a
4
+ verdict with violations.
5
+
6
+ from aicomply import comply
7
+
8
+ result = comply("My SSN is 516-81-3086")
9
+ if result.verdict != "CLEAN":
10
+ ... # block, redact, or log before this reaches an LLM
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from .classifier.dual_layer import DualLayerOptions, classify_dual_layer
16
+ from .classifier.guard_client import (
17
+ DEFAULT_NANOMIND_DAEMON_URL,
18
+ NanoMindAdapterOptions,
19
+ classify_with_nanomind_daemon,
20
+ is_nanomind_daemon_available,
21
+ )
22
+ from .classifier.regex import classify_with_regex, luhn_check, scan_patterns
23
+ from .normalize import normalize
24
+ from .types import (
25
+ ClassifierResult,
26
+ ComplyResult,
27
+ NormalizationStep,
28
+ Verdict,
29
+ Violation,
30
+ ViolationView,
31
+ )
32
+
33
+ __version__ = "0.1.0"
34
+
35
+ __all__ = [
36
+ "comply",
37
+ "ComplyResult",
38
+ "Violation",
39
+ "ClassifierResult",
40
+ "Verdict",
41
+ "ViolationView",
42
+ "NormalizationStep",
43
+ "DualLayerOptions",
44
+ "normalize",
45
+ "classify_with_regex",
46
+ "classify_dual_layer",
47
+ "scan_patterns",
48
+ "luhn_check",
49
+ "classify_with_nanomind_daemon",
50
+ "is_nanomind_daemon_available",
51
+ "NanoMindAdapterOptions",
52
+ "DEFAULT_NANOMIND_DAEMON_URL",
53
+ "__version__",
54
+ ]
55
+
56
+
57
+ def comply(
58
+ content: str,
59
+ *,
60
+ use_guard: bool = True,
61
+ guard_options: NanoMindAdapterOptions | None = None,
62
+ ) -> ComplyResult:
63
+ """Run compliance classification on ``content``.
64
+
65
+ Runs the dual-layer classifier (deterministic regex over normalized +
66
+ decoded views, plus an optional semantic Guard when a local nanomind-daemon
67
+ is reachable) and returns a verdict.
68
+
69
+ :param content: The text to classify. Must be a ``str``. Empty string
70
+ short-circuits to a CLEAN result with populated audit fields.
71
+ :param use_guard: When True (default) attempt the Guard daemon, silently
72
+ falling back to regex-only if it is unreachable.
73
+ :param guard_options: Optional daemon connection overrides.
74
+ :raises TypeError: if ``content`` is not a ``str``.
75
+ """
76
+ if not isinstance(content, str):
77
+ raise TypeError(f"comply: content must be a string (got {type(content).__name__})")
78
+
79
+ if not content:
80
+ # Empty content: populate audit fields per the ComplyResult contract.
81
+ return ComplyResult(
82
+ verdict="CLEAN",
83
+ violations=[],
84
+ classifier_results={
85
+ "regex": ClassifierResult(classifier="regex", verdict="CLEAN", violations=[])
86
+ },
87
+ original_content="",
88
+ normalized_content="",
89
+ normalizations=[],
90
+ )
91
+
92
+ return classify_dual_layer(
93
+ content, DualLayerOptions(use_guard=use_guard, guard_options=guard_options)
94
+ )
@@ -0,0 +1,6 @@
1
+ """Enable ``python -m aicomply ...`` to invoke the CLI (parity with the docstring)."""
2
+
3
+ from .cli import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1 @@
1
+ """Classifier package: regex layer, guard-daemon client, dual-layer merge."""