Metadata-Version: 2.4
Name: cyka-agent
Version: 0.1.0
Summary: Python SDK for Cykani stealth browser automation and AI agents
Author-email: Cykani <dev@cykani.com>
License: Apache-2.0
Project-URL: Homepage, https://cykani.com
Project-URL: Documentation, https://docs.cykani.com
Project-URL: Repository, https://github.com/cykani/cyka-agent
Project-URL: Issues, https://github.com/cykani/cyka-agent/issues
Keywords: browser,automation,stealth,anti-detection,ai-agent,scraping
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software 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: Topic :: Internet :: WWW/HTTP :: Browsers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.24.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: websockets>=11.0
Provides-Extra: llm
Requires-Dist: openai>=1.0.0; extra == "llm"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"

# cyka-agent Python SDK

Python SDK for Cykani stealth browser automation and AI agents.

## Installation

```bash
pip install cyka-agent
```

For LLM support:

```bash
pip install cyka-agent[llm]
```

## Quick Start

### Manual Browser Control

```python
import asyncio
from cyka_agent import Browser

async def main():
    browser = await Browser.connect("ws://localhost:9222")
    
    await browser.goto("https://example.com")
    await browser.click("#login-button")
    await browser.type("#email", "user@example.com")
    text = await browser.extract("#content")
    
    print(text)
    await browser.disconnect()

asyncio.run(main())
```

### AI Agent (Autonomous)

```python
import asyncio
from cyka_agent import Agent, Browser, AgentConfig

async def main():
    browser = await Browser.connect("ws://localhost:9222")
    
    agent = Agent.create(
        session=browser._session,
        config=AgentConfig(
            session_id="",
            profile_id="",
            goal="Find the cheapest iPhone on Amazon and add to cart",
            max_steps=25,
        ),
    )
    
    result = await agent.run_async()
    print(result.status)  # "success" or "max_steps_exceeded"
    print(result.result)  # What was accomplished

asyncio.run(main())
```

### Tool-Based (For LLM Integration)

```python
import asyncio
from cyka_agent import Browser, BrowserTools

async def main():
    browser = await Browser.connect("ws://localhost:9222")
    session = browser._session
    
    tools = BrowserTools(session)
    
    # Get tool definitions for your LLM
    tool_defs = tools.get_definitions()
    
    # Use with any LLM (example: OpenAI)
    from openai import OpenAI
    client = OpenAI()
    
    response = client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Navigate to example.com"}],
        tools=tool_defs,
    )
    
    # Execute the tool call
    tool_call = response.choices[0].message.tool_calls[0]
    result = await tools.execute(
        tool_call.function.name,
        eval(tool_call.function.arguments),
    )
    
    print(result.output)

asyncio.run(main())
```

### Using with Cykani API

```python
from cyka_agent import CykaClient

client = CykaClient(
    api_url="http://localhost:3001",
    api_key="your-api-key",
)

# Create a session
session = client.sessions.create(profile_id="profile-123")
print(session.cdp_endpoint)  # ws://localhost:9222

# Start the session
session = client.sessions.start(session.id)

# Create and run an agent
agent = client.agents.create(
    session_id=session.id,
    profile_id="profile-123",
    goal="Scrape all product prices",
)
result = client.agents.run(agent["id"])
print(result)
```

## Supported LLM Providers

- OpenAI (GPT-4, GPT-3.5)
- Anthropic (Claude)
- Any OpenAI-compatible API (Hermes, Groq, etc.)

## Environment Variables

```bash
CYKANI_API_URL=http://localhost:3001
CYKANI_API_KEY=your-api-key
OPENAI_API_KEY=your-openai-key  # For OpenAI adapter
```

## License

Apache-2.0
