Metadata-Version: 2.4
Name: infinium-claude-code-connector
Version: 1.1.1
Summary: Bridge between Claude Code hooks and Infinium agent tracing
Project-URL: Homepage, https://github.com/xyendigital/infinium-claude-code-connector
Project-URL: Repository, https://github.com/xyendigital/infinium-claude-code-connector
Project-URL: Documentation, https://i42m.ai/docs/claude-code/index
Project-URL: Bug Tracker, https://github.com/xyendigital/infinium-claude-code-connector/issues
Author-email: Infinium <support@i42m.ai>
License: MIT License
        
        Copyright (c) 2026 Infinium
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agent,claude-code,hooks,infinium,observability,tracing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: click>=8.0.0
Requires-Dist: infinium-o2>=1.0.0
Requires-Dist: keyring>=24.0.0
Provides-Extra: dev
Requires-Dist: black>=23.7.0; extra == 'dev'
Requires-Dist: isort>=5.12.0; extra == 'dev'
Requires-Dist: mypy>=1.5.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.11.0; extra == 'dev'
Requires-Dist: pytest>=7.4.0; extra == 'dev'
Provides-Extra: server
Requires-Dist: starlette>=0.27.0; extra == 'server'
Requires-Dist: uvicorn[standard]>=0.23.0; extra == 'server'
Description-Content-Type: text/markdown

# Infinium Claude Code Connector

Bridge between [Claude Code](https://docs.anthropic.com/en/docs/claude-code) hooks and [Infinium](https://i42m.ai) agent tracing. Automatically captures Claude Code sessions — tool calls, prompts, subagent activity — and sends structured traces to the Infinium platform for Maestro analysis.

## Quick Start

Navigate to your project, install, and set up:

```bash
cd /path/to/your/project
pip install infinium-claude-code-connector
infinium init
infinium test
```

That's it. Now just use Claude Code as you normally would — every session is automatically traced to Infinium. No server to run, no extra terminal, nothing to remember.

> If `infinium` is not on your PATH, use `python -m infinium_connector` as a drop-in replacement.

## How It Works

After `infinium init`, everything is automatic. You use Claude Code exactly as before — the connector works silently in the background via hooks.

```
Claude Code ──command hook──> python -m infinium_connector.hook
                                  │
                                  ├─ append event to session JSONL file
                                  │
                                  └─ on Stop/SessionEnd:
                                       replay events → aggregate → send trace
                                                                      │
                                                                      ▼
                                                              Infinium API
                                                          POST /agents/{id}/trace
```

1. Claude Code fires a command hook for each event (tool call, prompt, etc.)
2. The hook script appends the event to a session JSONL file on disk
3. On turn completion (`Stop`) or session end, all events are replayed, aggregated into a structured trace, and sent to Infinium via the Python SDK
4. Maestro interprets the trace (grading accuracy, efficiency, prompt adherence)

## CLI Reference

### `infinium init`

Interactive setup wizard. Configures credentials and Claude Code hooks.

```
Options:
  --agent-id TEXT        Agent ID (skip prompt)
  --agent-secret TEXT    Agent Secret (skip prompt)
  --base-url TEXT        API base URL
  --no-interactive       Use flags only, no prompts (for CI/scripting)
```

### `infinium test`

Send a test trace to verify your setup works end-to-end.

```
Options:
  -v, --verbose    Show the full trace payload before sending
```

### `infinium status`

Show current configuration: tracing state, credentials, config source, hook locations, pending retries.

### `infinium pause` / `infinium resume`

Temporarily stop or restart tracing. Hooks stay installed — events are silently skipped while paused.

Aliases: `stop` / `continue`

### `infinium history`

View recently sent traces.

```
Options:
  -n, --limit N    Number of entries (default: 10)
  --json           Output raw JSON lines
  --clear          Delete all history
```

### `infinium retry`

Resend traces that failed due to network issues.

```
Options:
  --dry-run    Show what would be retried without sending
```

### `infinium update-credentials`

Update your Agent ID or Secret.

### `infinium uninstall`

Remove the connector completely — hooks, config file, and keyring secret.

```
Options:
  -y, --yes    Skip confirmation prompt
```

### `infinium cleanup`

Remove stale session files (housekeeping).

### `infinium start`

Start HTTP server mode (alternative to command hooks, requires `pip install infinium-claude-code-connector[server]`).

## Per-Project Configuration

Each project traces to its own Infinium agent:

```bash
cd /path/to/project-a
infinium init    # Enter Agent A credentials

cd /path/to/project-b
infinium init    # Enter Agent B credentials
```

Config resolution order:
1. **Project config** (`.infinium/config.json` in the working directory)
2. **Environment variables** (`INFINIUM_AGENT_ID`, `INFINIUM_AGENT_SECRET` — override for CI/Docker)

Add `.infinium/` to your `.gitignore`.

## Credential Storage

- **Agent ID** and **API URL** are stored in the project config file (`.infinium/config.json`)
- **Agent Secret** is stored in your **OS keyring**:
  - Windows: Credential Manager
  - macOS: Keychain
  - Linux: Secret Service (GNOME Keyring / KWallet)
- Environment variables (`INFINIUM_AGENT_ID`, `INFINIUM_AGENT_SECRET`) override stored values — useful for CI/Docker

## What Gets Traced

| Field | Source |
|-------|--------|
| **name** | Session summary (e.g., "Claude Code session (3 turns)") |
| **description** | First user prompt |
| **duration** | Total session duration in seconds |
| **steps** | Ordered list: user prompts, tool calls, subagent spawns |
| **errors** | Tool failures with error messages |
| **environment** | Model, session source, working directory, permission mode |

### Captured Events

| Event | What It Captures |
|-------|-----------------|
| `SessionStart` | Model, source (startup/resume), working directory |
| `UserPromptSubmit` | User prompt text (truncated to 500 chars) |
| `PreToolUse` / `PostToolUse` | Tool name, input, output, duration |
| `PostToolUseFailure` | Error details |
| `SubagentStart` / `SubagentStop` | Subagent lifecycle (cowork, agent teams) |
| `Stop` | Assistant's final response — triggers trace flush |
| `SessionEnd` | Session cleanup — triggers final flush |

## Configuration

Environment variables (all optional — `init` handles the common case):

```bash
# Credentials (override config file + keyring)
INFINIUM_AGENT_ID=...
INFINIUM_AGENT_SECRET=...
INFINIUM_BASE_URL=...

# Connector behavior
CONNECTOR_QUIET=false              # Suppress output
CONNECTOR_FLUSH_ON_STOP=true       # Send trace after each turn
CONNECTOR_FLUSH_ON_SESSION_END=true
CONNECTOR_SESSION_TTL=3600         # Stale session cleanup threshold (seconds)
CONNECTOR_SESSION_DIR=...          # Override temp directory for session files
```

## Documentation

Full documentation: [i42m.ai/docs/claude-code](https://i42m.ai/docs/claude-code/index)

## License

MIT
