llm-interceptor 2.0.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 (69) hide show
  1. llm_interceptor-2.0.0/.github/workflows/ci.yml +90 -0
  2. llm_interceptor-2.0.0/.github/workflows/publish.yml +100 -0
  3. llm_interceptor-2.0.0/.gitignore +93 -0
  4. llm_interceptor-2.0.0/.pre-commit-config.yaml +21 -0
  5. llm_interceptor-2.0.0/CHANGELOG.md +170 -0
  6. llm_interceptor-2.0.0/PKG-INFO +336 -0
  7. llm_interceptor-2.0.0/README.md +295 -0
  8. llm_interceptor-2.0.0/build_ui.py +42 -0
  9. llm_interceptor-2.0.0/cci-icon.png +0 -0
  10. llm_interceptor-2.0.0/cci-ui-screenshot.png +0 -0
  11. llm_interceptor-2.0.0/cci.example.toml +65 -0
  12. llm_interceptor-2.0.0/lli.example.toml +67 -0
  13. llm_interceptor-2.0.0/pyproject.toml +75 -0
  14. llm_interceptor-2.0.0/src/cci/__init__.py +11 -0
  15. llm_interceptor-2.0.0/src/cci/app.py +319 -0
  16. llm_interceptor-2.0.0/src/cci/cli.py +727 -0
  17. llm_interceptor-2.0.0/src/cci/config.py +225 -0
  18. llm_interceptor-2.0.0/src/cci/filters.py +171 -0
  19. llm_interceptor-2.0.0/src/cci/logger.py +166 -0
  20. llm_interceptor-2.0.0/src/cci/merger.py +673 -0
  21. llm_interceptor-2.0.0/src/cci/models.py +126 -0
  22. llm_interceptor-2.0.0/src/cci/proxy.py +372 -0
  23. llm_interceptor-2.0.0/src/cci/server.py +244 -0
  24. llm_interceptor-2.0.0/src/cci/splitter.py +151 -0
  25. llm_interceptor-2.0.0/src/cci/storage.py +190 -0
  26. llm_interceptor-2.0.0/src/cci/watch.py +454 -0
  27. llm_interceptor-2.0.0/src/llm_interceptor/__init__.py +30 -0
  28. llm_interceptor-2.0.0/src/llm_interceptor/cli.py +21 -0
  29. llm_interceptor-2.0.0/tests/__init__.py +1 -0
  30. llm_interceptor-2.0.0/tests/test_basic.py +211 -0
  31. llm_interceptor-2.0.0/tests/test_merger.py +1313 -0
  32. llm_interceptor-2.0.0/ui/.gitignore +24 -0
  33. llm_interceptor-2.0.0/ui/README.md +53 -0
  34. llm_interceptor-2.0.0/ui/eslint.config.js +23 -0
  35. llm_interceptor-2.0.0/ui/index.html +14 -0
  36. llm_interceptor-2.0.0/ui/package-lock.json +5114 -0
  37. llm_interceptor-2.0.0/ui/package.json +39 -0
  38. llm_interceptor-2.0.0/ui/postcss.config.js +6 -0
  39. llm_interceptor-2.0.0/ui/public/cci-icon.png +0 -0
  40. llm_interceptor-2.0.0/ui/public/vite.svg +1 -0
  41. llm_interceptor-2.0.0/ui/src/App.css +42 -0
  42. llm_interceptor-2.0.0/ui/src/App.tsx +123 -0
  43. llm_interceptor-2.0.0/ui/src/assets/react.svg +1 -0
  44. llm_interceptor-2.0.0/ui/src/components/chat/ChatBubble.tsx +67 -0
  45. llm_interceptor-2.0.0/ui/src/components/chat/MessageContent.tsx +101 -0
  46. llm_interceptor-2.0.0/ui/src/components/chat/ToolCallBlock.tsx +49 -0
  47. llm_interceptor-2.0.0/ui/src/components/common/CopyButton.tsx +37 -0
  48. llm_interceptor-2.0.0/ui/src/components/common/JSONViewer.tsx +15 -0
  49. llm_interceptor-2.0.0/ui/src/components/common/TokenBadge.tsx +25 -0
  50. llm_interceptor-2.0.0/ui/src/components/common/Tooltip.tsx +35 -0
  51. llm_interceptor-2.0.0/ui/src/components/layout/EmptyState.tsx +40 -0
  52. llm_interceptor-2.0.0/ui/src/components/layout/ExchangeDetailsPane.tsx +384 -0
  53. llm_interceptor-2.0.0/ui/src/components/layout/RequestsPane.tsx +431 -0
  54. llm_interceptor-2.0.0/ui/src/components/layout/SessionsSidebar.tsx +272 -0
  55. llm_interceptor-2.0.0/ui/src/components/tools/ToolsList.tsx +199 -0
  56. llm_interceptor-2.0.0/ui/src/hooks/useAnnotations.ts +110 -0
  57. llm_interceptor-2.0.0/ui/src/hooks/useResizablePanels.ts +69 -0
  58. llm_interceptor-2.0.0/ui/src/hooks/useSessions.ts +101 -0
  59. llm_interceptor-2.0.0/ui/src/hooks/useTheme.ts +19 -0
  60. llm_interceptor-2.0.0/ui/src/index.css +36 -0
  61. llm_interceptor-2.0.0/ui/src/main.tsx +10 -0
  62. llm_interceptor-2.0.0/ui/src/types.ts +101 -0
  63. llm_interceptor-2.0.0/ui/src/utils/ui.ts +84 -0
  64. llm_interceptor-2.0.0/ui/src/utils.ts +380 -0
  65. llm_interceptor-2.0.0/ui/tailwind.config.js +12 -0
  66. llm_interceptor-2.0.0/ui/tsconfig.app.json +28 -0
  67. llm_interceptor-2.0.0/ui/tsconfig.json +7 -0
  68. llm_interceptor-2.0.0/ui/tsconfig.node.json +26 -0
  69. llm_interceptor-2.0.0/ui/vite.config.ts +7 -0
@@ -0,0 +1,90 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ os: [ubuntu-latest, macos-latest, windows-latest]
16
+ python-version: ["3.10", "3.11", "3.12"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v4
23
+ with:
24
+ version: "latest"
25
+
26
+ - name: Set up Python ${{ matrix.python-version }}
27
+ run: uv python install ${{ matrix.python-version }}
28
+
29
+ - name: Install dependencies
30
+ run: uv sync --all-extras --dev
31
+
32
+ - name: Run linting with ruff
33
+ run: uv run ruff check src/
34
+
35
+ - name: Run type checking with mypy
36
+ run: uv run mypy src/cci --ignore-missing-imports
37
+ continue-on-error: true
38
+
39
+ - name: Run tests
40
+ run: uv run pytest tests/ -v --tb=short
41
+ continue-on-error: true
42
+
43
+ - name: Verify CLI works
44
+ run: |
45
+ uv run cci --version
46
+ uv run cci --help
47
+
48
+ build:
49
+ runs-on: ubuntu-latest
50
+ needs: test
51
+
52
+ steps:
53
+ - uses: actions/checkout@v4
54
+
55
+ - name: Set up Node.js
56
+ uses: actions/setup-node@v4
57
+ with:
58
+ node-version: '20'
59
+ cache: 'npm'
60
+ cache-dependency-path: ui/package-lock.json
61
+
62
+ - name: Install uv
63
+ uses: astral-sh/setup-uv@v4
64
+ with:
65
+ version: "latest"
66
+
67
+ - name: Set up Python
68
+ run: uv python install 3.11
69
+
70
+ - name: Install Node.js dependencies
71
+ run: npm ci
72
+ working-directory: ui
73
+
74
+ - name: Build UI
75
+ run: npm run build
76
+ working-directory: ui
77
+
78
+ - name: Copy UI assets to static directory
79
+ run: |
80
+ mkdir -p src/cci/static
81
+ cp -r ui/dist/* src/cci/static/
82
+
83
+ - name: Build package
84
+ run: uv build
85
+
86
+ - name: Upload artifacts
87
+ uses: actions/upload-artifact@v4
88
+ with:
89
+ name: dist
90
+ path: dist/
@@ -0,0 +1,100 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+ inputs:
8
+ test_pypi:
9
+ description: 'Publish to Test PyPI instead of PyPI'
10
+ required: false
11
+ default: 'false'
12
+ type: boolean
13
+
14
+ jobs:
15
+ build:
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Set up Node.js
22
+ uses: actions/setup-node@v4
23
+ with:
24
+ node-version: '20'
25
+ cache: 'npm'
26
+ cache-dependency-path: ui/package-lock.json
27
+
28
+ - name: Install uv
29
+ uses: astral-sh/setup-uv@v4
30
+ with:
31
+ version: "latest"
32
+
33
+ - name: Set up Python
34
+ run: uv python install 3.11
35
+
36
+ - name: Install Node.js dependencies
37
+ run: npm ci
38
+ working-directory: ui
39
+
40
+ - name: Build UI
41
+ run: npm run build
42
+ working-directory: ui
43
+
44
+ - name: Copy UI assets to static directory
45
+ run: |
46
+ mkdir -p src/cci/static
47
+ cp -r ui/dist/* src/cci/static/
48
+
49
+ - name: Build package
50
+ run: uv build
51
+
52
+ - name: Upload artifacts
53
+ uses: actions/upload-artifact@v4
54
+ with:
55
+ name: dist
56
+ path: dist/
57
+
58
+ publish-test-pypi:
59
+ runs-on: ubuntu-latest
60
+ needs: build
61
+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.test_pypi == 'true'
62
+ environment:
63
+ name: test-pypi
64
+ url: https://test.pypi.org/project/llm-interceptor/
65
+
66
+ permissions:
67
+ id-token: write
68
+
69
+ steps:
70
+ - name: Download artifacts
71
+ uses: actions/download-artifact@v4
72
+ with:
73
+ name: dist
74
+ path: dist/
75
+
76
+ - name: Publish to Test PyPI
77
+ uses: pypa/gh-action-pypi-publish@release/v1
78
+ with:
79
+ repository-url: https://test.pypi.org/legacy/
80
+
81
+ publish-pypi:
82
+ runs-on: ubuntu-latest
83
+ needs: build
84
+ if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.test_pypi == 'false')
85
+ environment:
86
+ name: pypi
87
+ url: https://pypi.org/project/llm-interceptor/
88
+
89
+ permissions:
90
+ id-token: write
91
+
92
+ steps:
93
+ - name: Download artifacts
94
+ uses: actions/download-artifact@v4
95
+ with:
96
+ name: dist
97
+ path: dist/
98
+
99
+ - name: Publish to PyPI
100
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,93 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # PyInstaller
28
+ *.manifest
29
+ *.spec
30
+
31
+ # Installer logs
32
+ pip-log.txt
33
+ pip-delete-this-directory.txt
34
+
35
+ # Unit test / coverage reports
36
+ htmlcov/
37
+ .tox/
38
+ .nox/
39
+ .coverage
40
+ .coverage.*
41
+ .cache
42
+ nosetests.xml
43
+ coverage.xml
44
+ *.cover
45
+ *.py,cover
46
+ .hypothesis/
47
+ .pytest_cache/
48
+
49
+ # Translations
50
+ *.mo
51
+ *.pot
52
+
53
+ # Environments
54
+ .env
55
+ .venv
56
+ env/
57
+ venv/
58
+ ENV/
59
+ env.bak/
60
+ venv.bak/
61
+
62
+ # IDE
63
+ .idea/
64
+ .vscode/
65
+ *.swp
66
+ *.swo
67
+ *~
68
+
69
+ # Project specific
70
+ *.jsonl
71
+ cci.toml
72
+ cci.yaml
73
+ cci.yml
74
+ split_output/
75
+ traces/
76
+ # mitmproxy certificates (user should manage these separately)
77
+ .mitmproxy/
78
+
79
+ # uv
80
+ .uv/
81
+ uv.lock
82
+
83
+ # OS files
84
+ .DS_Store
85
+ Thumbs.db
86
+ *_output/
87
+
88
+ # UI Development
89
+ ui/node_modules/
90
+ ui/dist/
91
+
92
+ # Built UI static files (generated by build_ui.py)
93
+ src/cci/static/
@@ -0,0 +1,21 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.8.4
4
+ hooks:
5
+ # Run the linter (Python only, exclude frontend)
6
+ - id: ruff
7
+ args: [--fix]
8
+ types: [python]
9
+ exclude: ^ui/
10
+ # Run the formatter (Python only, exclude frontend)
11
+ - id: ruff-format
12
+ types: [python]
13
+ exclude: ^ui/
14
+
15
+ - repo: https://github.com/pre-commit/pre-commit-hooks
16
+ rev: v5.0.0
17
+ hooks:
18
+ - id: trailing-whitespace
19
+ - id: end-of-file-fixer
20
+ - id: check-yaml
21
+ - id: check-added-large-files
@@ -0,0 +1,170 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.0.0] - 2025-12-18
9
+
10
+ ### Added
11
+
12
+ - **LLM Interceptor branding** - Complete rebranding from Claude Code Inspector to LLM Interceptor (LLI)
13
+ - **Performance optimizations** - Base performance improvements for better efficiency
14
+
15
+ ### Changed
16
+
17
+ - **Project rename** - Renamed from `cci` to `lli` (LLM Interceptor) across all components
18
+ - **CLI command** - Primary command changed from `cci` to `lli`
19
+ - **Package name** - Updated package name to `llm-interceptor`
20
+ - **Log improvements** - Enhanced log output coloring and deduplication for better readability
21
+
22
+ ---
23
+
24
+ ## [1.4.0] - 2025-12-16
25
+
26
+ ### Added
27
+
28
+ - **Annotation system** - Add annotation support for sessions and requests
29
+ - **UI enhancements**
30
+ - Favicon and custom page title
31
+ - Chat scroll buttons for easier navigation
32
+ - JSON text wrapping toggle in raw view
33
+ - Auto-select newest session on load
34
+ - Sticky tool name header for better context awareness
35
+
36
+ ### Fixed
37
+
38
+ - **Windows compatibility** - Fixed npm build command execution on Windows using `shell=True`
39
+ - **Port conflict detection** - Check if UI port is in use before starting server
40
+ - **Data normalization** - Normalize token usage and static file MIME types
41
+ - **UI fixes**
42
+ - Fixed system instruction color display
43
+ - Fixed sticky tool header flicker during scroll
44
+
45
+ ### Changed
46
+
47
+ - **Code organization** - Refactored UI into modular components and hooks
48
+ - **CLI improvements** - Centralized Rich Console instance for unified output
49
+ - **Better feedback** - CLI now uses `console.status` for improved user feedback
50
+ - **OpenAI compatibility** - Normalize OpenAI system content to string format
51
+
52
+ ---
53
+
54
+ ## [1.3.0] - 2025-12-09
55
+
56
+ ### Added
57
+
58
+ - **React Web UI** - Modern web interface for trace analysis
59
+ - Beautiful dark/light theme with toggle support
60
+ - Session list with timestamp-based sorting
61
+ - Conversation view with system prompts, messages, and tool calls
62
+ - Multiple view tabs: Chat, System, Tools, and Raw JSON
63
+ - Automatic API format detection (Anthropic/OpenAI)
64
+ - Real-time session updates via polling
65
+ - **FastAPI server** - Backend API for serving UI and session data
66
+ - RESTful endpoints for sessions and session details
67
+ - Static file serving for bundled React app
68
+ - **UI auto-launch** - `cci watch` now automatically starts the UI server (default: enabled)
69
+ - **Build script** - `build_ui.py` for building frontend assets
70
+
71
+ ### Changed
72
+
73
+ - **GitHub Actions** - Updated CI/CD workflows to build frontend UI before packaging
74
+ - **Dependencies** - Added `fastapi`, `uvicorn`, `python-multipart`, `watchdog`
75
+
76
+ ---
77
+
78
+ ## [1.2.0] - 2025-12-09
79
+
80
+ ### Added
81
+
82
+ - **New `watch` command** - Continuous session capture mode for real-time monitoring
83
+ - Automatic session management with timestamped directories
84
+ - Support for custom URL patterns via `--include` option
85
+ - **Streamlit app for AI Traffic Inspector** - Web-based UI for traffic analysis
86
+ - **Glob pattern support** - URL filtering now supports glob patterns for more flexible matching
87
+
88
+ ### Changed
89
+
90
+ - **CLI refactoring** - Removed `capture` command and updated subcommands for cleaner interface
91
+
92
+ ---
93
+
94
+ ## [1.1.0] - 2025-11-28
95
+
96
+ ### Added
97
+
98
+ - **New `split` command** - Split JSONL trace files into individual JSON files for easier analysis
99
+ - Output individual JSON files for each request and response
100
+ - Support for extracting tool_calls from messages
101
+ - **Enhanced `merge` command**
102
+ - Added tool_calls extraction support
103
+ - Output separate request and response lines for better organization
104
+ - **JSONLWriter improvements**
105
+ - Added file overwrite option for more flexible output handling
106
+
107
+ ### Fixed
108
+
109
+ - Corrected SSE streaming response capture for more reliable data collection
110
+
111
+ ### Changed
112
+
113
+ - Improved code formatting and readability throughout the codebase
114
+
115
+ ---
116
+
117
+ ## [1.0.0] - 2025-11-25
118
+
119
+ ### Added
120
+
121
+ - Initial release (project formerly known as Claude-Code-Inspector / CCI)
122
+ - **Core Features**
123
+ - MITM proxy server using mitmproxy for traffic interception
124
+ - Support for both streaming (SSE) and non-streaming API responses
125
+ - Automatic API key masking in captured logs
126
+ - JSONL output format for easy analysis
127
+ - Stream merger utility to consolidate streaming chunks
128
+
129
+ - **CLI Commands**
130
+ - `cci capture` - Start proxy and capture LLM API traffic
131
+ - `cci merge` - Merge streaming response chunks into complete records
132
+ - `cci config` - Display configuration and setup help
133
+ - `cci stats` - Show statistics for captured trace files
134
+
135
+ - **Supported LLM Providers**
136
+ - Anthropic (api.anthropic.com)
137
+ - OpenAI (api.openai.com)
138
+ - Google (generativelanguage.googleapis.com)
139
+ - Together (api.together.xyz)
140
+ - Groq (api.groq.com)
141
+ - Mistral (api.mistral.ai)
142
+ - Cohere (api.cohere.ai)
143
+ - DeepSeek (api.deepseek.com)
144
+ - Custom providers via `--include` pattern
145
+
146
+ - **Configuration**
147
+ - TOML/YAML configuration file support
148
+ - Environment variable overrides
149
+ - URL pattern filtering (include/exclude)
150
+ - Sensitive header masking
151
+ - Log rotation support
152
+
153
+ - **Documentation**
154
+ - Comprehensive README with installation instructions
155
+ - Certificate installation guide for macOS, Linux, and Windows
156
+ - Node.js application configuration (NODE_EXTRA_CA_CERTS)
157
+ - Troubleshooting guide
158
+
159
+ - **CI/CD**
160
+ - GitHub Actions workflow for CI (test on Ubuntu, macOS, Windows)
161
+ - GitHub Actions workflow for PyPI publishing
162
+ - Support for Python 3.10, 3.11, 3.12
163
+
164
+ ### Technical Details
165
+
166
+ - Built with Python 3.10+
167
+ - Uses mitmproxy for HTTPS interception
168
+ - Pydantic for data models and validation
169
+ - Click for CLI interface
170
+ - Rich for beautiful terminal output