Metadata-Version: 2.4
Name: langchain-skilllite
Version: 0.1.3
Summary: LangChain integration for SkillLite - Lightweight sandboxed Python skill execution engine
Author-email: SkillLite Team <skilllite@example.com>
License: MIT
Project-URL: Homepage, https://github.com/EXboys/langchain-skilllite
Project-URL: Documentation, https://github.com/EXboys/langchain-skilllite#readme
Project-URL: Repository, https://github.com/EXboys/langchain-skilllite
Project-URL: Issues, https://github.com/EXboys/langchain-skilllite/issues
Project-URL: LangChain, https://python.langchain.com/
Project-URL: SkillLite, https://github.com/EXboys/skilllite
Keywords: langchain,skilllite,agent,tools,sandbox,llm,skills,python-execution
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
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
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain-core>=0.3.0
Requires-Dist: skilllite>=0.1.1
Provides-Extra: langgraph
Requires-Dist: langgraph>=0.2.0; extra == "langgraph"
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
Requires-Dist: langchain-tests>=0.3.0; extra == "test"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: langchain-tests>=0.3.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Dynamic: license-file

# langchain-skilllite

[![PyPI version](https://badge.fury.io/py/langchain-skilllite.svg)](https://badge.fury.io/py/langchain-skilllite)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

LangChain integration for [SkillLite](https://github.com/EXboys/skilllite) - a lightweight sandboxed Python skill execution engine.

## Features

- 🔒 **Sandboxed Execution** - All skills run in a Rust-based sandbox (skillbox)
- 📝 **Declarative Skills** - Define skills via SKILL.md, no Python wrappers needed
- 🔍 **Security Scanning** - Pre-execution code analysis for dangerous operations
- ✅ **Confirmation Callbacks** - User approval for high-severity security issues
- ⚡ **Async Support** - Full async support for LangGraph agents

## Installation

```bash
pip install langchain-skilllite
```

This will also install the required dependencies:
- `langchain-core>=0.3.0`
- `skilllite>=0.1.1`

## Quick Start

```python
from langchain_skilllite import SkillLiteToolkit
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

# Load all skills from a directory as LangChain tools
tools = SkillLiteToolkit.from_directory("./skills")

# Create a LangGraph agent
agent = create_react_agent(ChatOpenAI(model="gpt-4"), tools)

# Run the agent
result = agent.invoke({
    "messages": [("user", "Calculate 15 + 27 using the calculator skill")]
})
```

## Usage

### Basic Usage with SkillManager

```python
from skilllite import SkillManager
from langchain_skilllite import SkillLiteToolkit

# Create a SkillManager
manager = SkillManager(skills_dir="./skills")

# Convert all skills to LangChain tools
tools = SkillLiteToolkit.from_manager(manager)

# Or select specific skills
tools = SkillLiteToolkit.from_manager(
    manager,
    skill_names=["calculator", "web_search"],
    allow_network=True,
    timeout=60
)
```

### Security Levels

SkillLite supports three sandbox security levels:

| Level | Description |
|-------|-------------|
| 1 | No sandbox - direct execution (fastest, least secure) |
| 2 | Sandbox isolation only |
| 3 | Sandbox + security scanning (default, most secure) |

```python
# Level 3 with confirmation callback for high-severity issues
def confirm_execution(report: str, scan_id: str) -> bool:
    print(report)
    return input("Proceed? [y/N]: ").lower() == 'y'

tools = SkillLiteToolkit.from_directory(
    "./skills",
    sandbox_level=3,
    confirmation_callback=confirm_execution
)
```

### Async Confirmation (for LangGraph)

```python
import asyncio

async def async_confirm(report: str, scan_id: str) -> bool:
    print(report)
    # In a real app, this might be a UI prompt
    return True

tools = SkillLiteToolkit.from_directory(
    "./skills",
    sandbox_level=3,
    async_confirmation_callback=async_confirm
)
```

### Callback Handler for Monitoring

```python
from langchain_skilllite import SkillLiteCallbackHandler

handler = SkillLiteCallbackHandler(verbose=True)

# Use with agent
result = agent.invoke(
    {"messages": [("user", "Run my skill")]},
    config={"callbacks": [handler]}
)

# Get execution summary
print(handler.get_execution_summary())
```

## API Reference

### SkillLiteTool

LangChain `BaseTool` adapter for a single SkillLite skill.

### SkillLiteToolkit

Factory class for creating multiple `SkillLiteTool` instances.

- `from_manager(manager, ...)` - Create tools from a SkillManager
- `from_directory(skills_dir, ...)` - Create tools from a skills directory

### SkillLiteCallbackHandler

LangChain callback handler for monitoring skill execution.

## Requirements

- Python >= 3.9
- langchain-core >= 0.3.0
- skilllite >= 0.1.1

## License

MIT License - see [LICENSE](LICENSE) for details.

## Links

- [SkillLite Repository](https://github.com/EXboys/skilllite)
- [LangChain Documentation](https://python.langchain.com/)
- [LangGraph Documentation](https://langchain-ai.github.io/langgraph/)

