ai-lls-lib 2.0.0rc2__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.
@@ -0,0 +1,301 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai-lls-lib
3
+ Version: 2.0.0rc2
4
+ Summary: Landline Scrubber core library - phone verification and DNC checking
5
+ Author: LandlineScrubber Team
6
+ Requires-Python: >=3.12,<4.0
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Classifier: Programming Language :: Python :: 3.14
11
+ Requires-Dist: aws-lambda-powertools (>=2.30.0,<3.0.0)
12
+ Requires-Dist: boto3 (>=1.34.0,<2.0.0)
13
+ Requires-Dist: click (>=8.1.0,<9.0.0)
14
+ Requires-Dist: httpx (>=0.25.0,<0.26.0)
15
+ Requires-Dist: phonenumbers (>=8.13.0,<9.0.0)
16
+ Requires-Dist: pydantic (>=2.5.0,<3.0.0)
17
+ Requires-Dist: rich (>=14.0,<15.0)
18
+ Requires-Dist: stripe (>=12.5.1,<13.0.0)
19
+ Description-Content-Type: text/markdown
20
+
21
+ # AI LLS Library
22
+
23
+ Core business logic library and CLI tools for Landline Scrubber - phone verification and DNC checking.
24
+
25
+ ## Version 2.1.0 - Streaming & Provider Architecture
26
+
27
+ New features:
28
+ - **Streaming support** for large CSV files to reduce memory usage
29
+ - **Provider architecture** for clean separation of verification logic
30
+ - **Contract tests** ensuring all providers behave consistently
31
+
32
+ ## Version 2.0.0 - Breaking Changes
33
+
34
+ This is a greenfield rewrite with no backwards compatibility:
35
+ - All file-based CSV processing replaced with text-based methods
36
+ - Removed `_sync` suffix from all methods (everything is sync)
37
+ - `process_csv_sync(file_path)` → `process_csv(csv_text)`
38
+ - `generate_results_csv(...)` now returns CSV string instead of writing to file
39
+
40
+ ## Features
41
+
42
+ - Phone number normalization (E.164 format)
43
+ - Line type detection (mobile/landline/voip)
44
+ - DNC (Do Not Call) list checking
45
+ - DynamoDB caching with 30-day TTL
46
+ - Bulk CSV processing
47
+ - Infrastructure-aware CLI for admin operations
48
+ - AWS Lambda PowerTools integration
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ # Install library with Poetry
54
+ poetry install
55
+
56
+ # Install CLI globally
57
+ pip install -e .
58
+ ```
59
+
60
+ ## Library Usage
61
+
62
+ ### Single Phone Verification
63
+
64
+ ```python
65
+ from ai_lls_lib import PhoneVerifier, DynamoDBCache
66
+
67
+ cache = DynamoDBCache(table_name="phone-cache")
68
+ verifier = PhoneVerifier(cache)
69
+
70
+ result = verifier.verify("+15551234567")
71
+ print(f"Line type: {result.line_type}")
72
+ print(f"DNC: {result.dnc}")
73
+ print(f"From cache: {result.cached}")
74
+ ```
75
+
76
+ ### Bulk Processing
77
+
78
+ ```python
79
+ from ai_lls_lib import BulkProcessor, PhoneVerifier, DynamoDBCache
80
+
81
+ cache = DynamoDBCache(table_name="phone-cache")
82
+ verifier = PhoneVerifier(cache)
83
+ processor = BulkProcessor(verifier)
84
+
85
+ # Process CSV text content
86
+ csv_text = "name,phone\nJohn,+15551234567\nJane,+15551234568"
87
+ results = processor.process_csv(csv_text)
88
+
89
+ # Generate results CSV
90
+ results_csv = processor.generate_results_csv(csv_text, results)
91
+ print(results_csv) # CSV string with added line_type, dnc, cached columns
92
+ ```
93
+
94
+ ### Streaming Large Files
95
+
96
+ For memory-efficient processing of large CSV files:
97
+
98
+ ```python
99
+ from ai_lls_lib import BulkProcessor, PhoneVerifier, DynamoDBCache
100
+
101
+ cache = DynamoDBCache(table_name="phone-cache")
102
+ verifier = PhoneVerifier(cache)
103
+ processor = BulkProcessor(verifier)
104
+
105
+ # Process CSV as a stream, yielding batches
106
+ csv_lines = open('large_file.csv').readlines()
107
+ for batch in processor.process_csv_stream(csv_lines, batch_size=100):
108
+ print(f"Processed batch of {len(batch)} phones")
109
+ # Each batch is a list of PhoneVerification objects
110
+ ```
111
+
112
+ ### Custom Verification Providers
113
+
114
+ Use different verification providers based on your needs:
115
+
116
+ ```python
117
+ from ai_lls_lib import PhoneVerifier, DynamoDBCache
118
+ from ai_lls_lib.providers import StubProvider
119
+
120
+ # Use stub provider for testing
121
+ cache = DynamoDBCache(table_name="phone-cache")
122
+ provider = StubProvider() # Deterministic testing provider
123
+ verifier = PhoneVerifier(cache, provider=provider)
124
+
125
+ # When external APIs are ready, switch to:
126
+ # from ai_lls_lib.providers.external import ExternalAPIProvider
127
+ # provider = ExternalAPIProvider(phone_api_key="...", dnc_api_key="...")
128
+ ```
129
+
130
+ ## CLI Usage
131
+
132
+ The `ai-lls` CLI provides infrastructure-aware administrative tools:
133
+
134
+ ### Verification Commands
135
+ ```bash
136
+ # Verify single phone
137
+ ai-lls verify phone +15551234567 --stack landline-api
138
+
139
+ # Bulk verify CSV
140
+ ai-lls verify bulk input.csv -o output.csv --stack landline-api
141
+ ```
142
+
143
+ ### Cache Management
144
+ ```bash
145
+ # Show cache statistics
146
+ ai-lls cache stats --stack landline-api
147
+
148
+ # Get cached entry
149
+ ai-lls cache get +15551234567 --stack landline-api
150
+
151
+ # Invalidate cache entry
152
+ ai-lls cache invalidate +15551234567 --stack landline-api
153
+
154
+ # Clear old entries
155
+ ai-lls cache clear --older-than 20 --stack landline-api
156
+ ```
157
+
158
+ ### Administrative Commands
159
+ ```bash
160
+ # Manage user credits
161
+ ai-lls admin user-credits user123 --add 100
162
+ ai-lls admin user-credits user123 --set 500
163
+
164
+ # List API keys
165
+ ai-lls admin api-keys --user user123
166
+
167
+ # Check queue status
168
+ ai-lls admin queue-stats
169
+
170
+ # View secrets (masked)
171
+ ai-lls admin secrets --stack landline-api
172
+ ```
173
+
174
+ ### Test Stack Management
175
+ ```bash
176
+ # Deploy test stack
177
+ ai-lls test-stack deploy
178
+
179
+ # Check status
180
+ ai-lls test-stack status
181
+
182
+ # Run integration tests
183
+ ai-lls test-stack test
184
+
185
+ # Delete test stack
186
+ ai-lls test-stack delete
187
+ ```
188
+
189
+ ### CloudWatch Log Monitoring
190
+ ```bash
191
+ # Monitor staging environment logs in real-time
192
+ ai-lls monitor logs --staging
193
+
194
+ # Monitor production environment logs
195
+ ai-lls monitor logs --production
196
+
197
+ # Monitor with custom duration (look back 10 minutes)
198
+ ai-lls monitor logs --staging --duration 600
199
+
200
+ # Filter logs for errors only
201
+ ai-lls monitor logs --staging --filter "ERROR"
202
+
203
+ # Use specific AWS profile
204
+ ai-lls monitor logs --staging --profile myprofile
205
+
206
+ # Experimental: Use CloudWatch Logs Live Tail API
207
+ ai-lls monitor live --staging
208
+ ```
209
+
210
+ The monitor command provides real-time log streaming from Lambda functions with:
211
+ - Color-coded output for different event types (external API calls, cache events, errors)
212
+ - Support for multiple log groups simultaneously
213
+ - Rich formatting when the `rich` library is installed
214
+ - Automatic detection of external API calls to landlineremover.com
215
+
216
+ ## Project Structure
217
+
218
+ ```
219
+ ai-lls-lib/
220
+ ├── src/ai_lls_lib/
221
+ │ ├── core/ # Business logic (infrastructure-agnostic)
222
+ │ │ ├── models.py # Pydantic models
223
+ │ │ ├── verifier.py # Phone verification
224
+ │ │ ├── processor.py # Bulk processing
225
+ │ │ └── cache.py # DynamoDB cache
226
+ │ ├── cli/ # Infrastructure-aware CLI
227
+ │ │ ├── __main__.py # Entry point
228
+ │ │ ├── commands/ # Command modules
229
+ │ │ └── aws_client.py # AWS operations
230
+ │ └── testing/ # Test utilities
231
+ │ └── fixtures.py # Test data
232
+ ├── tests/
233
+ │ ├── unit/ # Mocked tests
234
+ │ └── integration/ # AWS integration tests
235
+ └── test-stack.yaml # Test infrastructure
236
+ ```
237
+
238
+ ## Testing
239
+
240
+ ```bash
241
+ # Run unit tests (mocked AWS)
242
+ poetry run pytest tests/unit -v
243
+
244
+ # Deploy test stack for integration tests
245
+ ai-lls test-stack deploy
246
+
247
+ # Run integration tests (requires test stack)
248
+ TEST_STACK_NAME=ai-lls-lib-test poetry run pytest tests/integration -v
249
+
250
+ # All tests with coverage
251
+ poetry run pytest --cov=src --cov-report=html
252
+
253
+ # Clean up
254
+ ai-lls test-stack delete
255
+ ```
256
+
257
+ ## Development
258
+
259
+ ### Current Stub Implementation
260
+
261
+ For demo purposes, verification uses stub logic based on last digit:
262
+ - Ends in 3: mobile, not on DNC
263
+ - Ends in 2: landline, not on DNC
264
+ - Ends in 1: mobile, on DNC
265
+ - Ends in 0: landline, on DNC
266
+ - Otherwise: mobile, not on DNC
267
+
268
+ TODO markers indicate where real API integration will be added.
269
+
270
+ ### Code Quality
271
+
272
+ ```bash
273
+ # Format code
274
+ poetry run black src/ tests/
275
+ poetry run isort src/ tests/
276
+
277
+ # Type checking
278
+ poetry run mypy src/
279
+
280
+ # Run pre-commit hooks
281
+ pre-commit run --all-files
282
+ ```
283
+
284
+ ## Environment Variables
285
+
286
+ - `DNC_API_KEY` - DNC verification API key
287
+ - `DNC_CHECK_API_KEY` - Alternative DNC service
288
+ - `PHONE_VERIFY_API_KEY` - Line type verification
289
+ - `AWS_REGION` - AWS region (default: us-east-1)
290
+ - `AWS_PROFILE` - AWS profile for CLI operations
291
+
292
+ ## License
293
+
294
+ Proprietary - All rights reserved
295
+
296
+ ## Release Process
297
+
298
+ This library uses semantic versioning and publishes to:
299
+ - TestPyPI on dev branch pushes (pre-release versions)
300
+ - PyPI on main branch pushes (stable releases)
301
+
@@ -0,0 +1,34 @@
1
+ ai_lls_lib/__init__.py,sha256=Y11h9ZWDlbxKiKl0U-j2jd-5ITephsmmZ-961Np_Imk,792
2
+ ai_lls_lib/auth/__init__.py,sha256=ZjwlfTvYUo9A9BaLinaXW2elxYectScmu0XtKAppSFs,198
3
+ ai_lls_lib/auth/context_parser.py,sha256=AWyGWejrFR0jJ7fMhajdA1ABo656Qlvs2YAzz-IfTrs,2290
4
+ ai_lls_lib/cli/__init__.py,sha256=HyjnIBGlrbTlHQ82n_UppjtJbZl4_7QsnAgRqNlXKMU,77
5
+ ai_lls_lib/cli/__main__.py,sha256=OLpqz78s2nAtib7soqI-WQ2_V9aqa9Cd4NRwvso0IbM,2120
6
+ ai_lls_lib/cli/aws_client.py,sha256=yJ_seXyAOSy1xFqUHD8CScnN5un18b2412a7pUG_UQs,4283
7
+ ai_lls_lib/cli/commands/__init__.py,sha256=yi0bdkZSPIXY33apvJRcuK410-Ta0-_-n31MQYuL_aU,31
8
+ ai_lls_lib/cli/commands/admin.py,sha256=JlFljbblVWJkJ2z2FIM6P0fy3Pmc0VqG62Y3POtvRFw,6861
9
+ ai_lls_lib/cli/commands/cache.py,sha256=1Vm3m5vXJkRagNmQXpT8_YEsQEv92veJUFwA_v9FPb0,5822
10
+ ai_lls_lib/cli/commands/monitor.py,sha256=TLbf5Q_viwF7q_aPXo9XenzY4W0R1bjO68Iu8KlzvoE,11315
11
+ ai_lls_lib/cli/commands/stripe.py,sha256=uhwX0Zq56R-68P53NOtKx6ZoR1ybhWawdQTq1zgK98M,14239
12
+ ai_lls_lib/cli/commands/test_stack.py,sha256=FK6ITOek7j4e0QiSNTv_taLghNnR8d_kWG02cl0A3rY,7594
13
+ ai_lls_lib/cli/commands/verify.py,sha256=8rTg8xbdQbJdebDy5CT7HFcJ-ODFZdAOAo2JX82ARJs,8522
14
+ ai_lls_lib/cli/env_loader.py,sha256=ZL8GykQw8gf--aSMvIR4pdfQYKIA8bbJDWWNUpxZYsI,4260
15
+ ai_lls_lib/core/__init__.py,sha256=ATh5sGhhB9g5Sd2H0kRqoCA0hxqe6UWonlPq2Wnl_i8,39
16
+ ai_lls_lib/core/cache.py,sha256=4HSVaRvv_wueLV30fVbTk_KWZmXjR2mBrGl7UNT_5kQ,3817
17
+ ai_lls_lib/core/models.py,sha256=jzvc-SlP-nLgvkom9hj-TwKHxBePbEfC9xL_Tt1Uh4Y,2458
18
+ ai_lls_lib/core/processor.py,sha256=8PI_j1ZMOD1hru3PyV5QMmMx7Em8X0ivq8prMXwait4,10269
19
+ ai_lls_lib/core/verifier.py,sha256=mQBgzV-vZiiKGzeeVl3TwfOWGrYTeB_zQ6wpaI07u54,3147
20
+ ai_lls_lib/payment/__init__.py,sha256=uQwWZ2tw-cxS06hbWiKu8ubxzzYCmxeKBQQU7m_mRX4,308
21
+ ai_lls_lib/payment/credit_manager.py,sha256=DH_t8AMx74vexegoTD3UkFNA1XuomIQWOZu9VoJMO3E,7340
22
+ ai_lls_lib/payment/models.py,sha256=LxGop5e1hhUmBCpnzJwU-dDQSLHy6uM6gSFYYo2V_FI,3609
23
+ ai_lls_lib/payment/stripe_manager.py,sha256=cSJvRWk1OT16SlDh5BMyoEQD8TU0IzeP0TaL8e2U4zA,18423
24
+ ai_lls_lib/payment/webhook_processor.py,sha256=bAf8oUBzvCsb1stzKZ-cjZs02T-RJl-MeVnZmnnj5UM,8980
25
+ ai_lls_lib/providers/__init__.py,sha256=dBjXJHn2nnA8KUuLYkgCJjZZzWeYAPPd6IJHUd7b-Kk,252
26
+ ai_lls_lib/providers/base.py,sha256=WSnSkHtRvwpX8QtGINjO-EWsZL0augp5E8M1DPwpf00,709
27
+ ai_lls_lib/providers/external.py,sha256=MKu3BZV8gfSqV3lNcF9Vt4UmKIJixQ5Q7FI2wFeSBz0,5075
28
+ ai_lls_lib/providers/stub.py,sha256=XXUObkIb3hs7_fYMA9mlLh1llJUGIgqQHVjgZHZl1T8,1199
29
+ ai_lls_lib/testing/__init__.py,sha256=NytBz7T0YtNLDArRYHsczaeopIQmmBeV21-XXUprdeY,42
30
+ ai_lls_lib/testing/fixtures.py,sha256=OC1huorIqUndePoUTfgoU-aDvsWAFJqmQ6fGDjH9E14,3414
31
+ ai_lls_lib-2.0.0rc2.dist-info/METADATA,sha256=J6A26EIFEsD7UOqpHLY4afJFKG0bGybJCHVUP5ylO84,8175
32
+ ai_lls_lib-2.0.0rc2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
33
+ ai_lls_lib-2.0.0rc2.dist-info/entry_points.txt,sha256=Pi0V_HBViEKGFbNQKatl5lhhnHHBXlxaom-5gH9gXZ0,55
34
+ ai_lls_lib-2.0.0rc2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.2.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ ai-lls=ai_lls_lib.cli.__main__:main
3
+