capsolver-agent 0.1.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.
- capsolver_agent-0.1.0/.gitignore +44 -0
- capsolver_agent-0.1.0/CHANGELOG.md +18 -0
- capsolver_agent-0.1.0/CONTRIBUTING.md +40 -0
- capsolver_agent-0.1.0/LICENSE +15 -0
- capsolver_agent-0.1.0/PKG-INFO +197 -0
- capsolver_agent-0.1.0/PUBLISHING.md +118 -0
- capsolver_agent-0.1.0/README.md +159 -0
- capsolver_agent-0.1.0/SECURITY.md +32 -0
- capsolver_agent-0.1.0/SUPPORT.md +25 -0
- capsolver_agent-0.1.0/docs/agent-integration.md +251 -0
- capsolver_agent-0.1.0/pyproject.toml +70 -0
- capsolver_agent-0.1.0/requirements-dev.txt +20 -0
- capsolver_agent-0.1.0/requirements.txt +4 -0
- capsolver_agent-0.1.0/src/capsolver_agent/__init__.py +28 -0
- capsolver_agent-0.1.0/src/capsolver_agent/__main__.py +112 -0
- capsolver_agent-0.1.0/src/capsolver_agent/langchain_tools.py +213 -0
- capsolver_agent-0.1.0/src/capsolver_agent/py.typed +0 -0
- capsolver_agent-0.1.0/src/capsolver_agent/schema.py +468 -0
- capsolver_agent-0.1.0/tests/__init__.py +0 -0
- capsolver_agent-0.1.0/tests/test_tools.py +628 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Byte-compiled / optimized
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
|
|
7
|
+
# Distribution
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
*.egg
|
|
12
|
+
*.whl
|
|
13
|
+
|
|
14
|
+
# Virtual environments
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
env/
|
|
18
|
+
|
|
19
|
+
# IDE
|
|
20
|
+
.idea/
|
|
21
|
+
.vscode/
|
|
22
|
+
.cursor/
|
|
23
|
+
*.swp
|
|
24
|
+
*.swo
|
|
25
|
+
|
|
26
|
+
# Testing
|
|
27
|
+
.pytest_cache/
|
|
28
|
+
.coverage
|
|
29
|
+
htmlcov/
|
|
30
|
+
.mypy_cache/
|
|
31
|
+
.ruff_cache/
|
|
32
|
+
.dmypy.json
|
|
33
|
+
|
|
34
|
+
# Environment
|
|
35
|
+
.env
|
|
36
|
+
.env.local
|
|
37
|
+
.python-version
|
|
38
|
+
|
|
39
|
+
# Logs
|
|
40
|
+
*.log
|
|
41
|
+
|
|
42
|
+
# OS
|
|
43
|
+
.DS_Store
|
|
44
|
+
Thumbs.db
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
This project follows semantic versioning where practical. Public releases are
|
|
6
|
+
tagged in Git as `vX.Y.Z` and published to PyPI with the same version.
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-09-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial public release of `capsolver-agent`.
|
|
13
|
+
- Framework-agnostic tool definitions for CapSolver captcha solving.
|
|
14
|
+
- Async tool executor for use in custom agent loops.
|
|
15
|
+
- LangChain tool implementations behind the `langchain` extra.
|
|
16
|
+
- Optional browser-based tools behind the `browser` extra.
|
|
17
|
+
- `capsolver-agent` CLI for inspecting tools and schemas.
|
|
18
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in `capsolver-agent`.
|
|
4
|
+
|
|
5
|
+
This repository is maintained by the CapSolver team. Issues and pull requests
|
|
6
|
+
are welcome when they are focused on bugs, documentation, compatibility, or
|
|
7
|
+
small improvements to the public agent integration surface.
|
|
8
|
+
|
|
9
|
+
## Before You Start
|
|
10
|
+
|
|
11
|
+
- Search existing issues before opening a new one.
|
|
12
|
+
- Open an issue before starting a large change or adding a new framework
|
|
13
|
+
integration.
|
|
14
|
+
- Do not include real API keys, cookies, private URLs, prompts, tool traces, or
|
|
15
|
+
customer data in issues, tests, examples, or screenshots.
|
|
16
|
+
- Keep examples token-mode focused and use placeholder credentials.
|
|
17
|
+
|
|
18
|
+
## Development
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
uv sync --all-extras
|
|
22
|
+
uv run pytest
|
|
23
|
+
uv run ruff check src tests
|
|
24
|
+
uv run mypy src
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If you do not use `uv`, install the development dependencies from
|
|
28
|
+
`requirements-dev.txt` and run the equivalent commands with Python.
|
|
29
|
+
|
|
30
|
+
## Pull Requests
|
|
31
|
+
|
|
32
|
+
Pull requests should include:
|
|
33
|
+
|
|
34
|
+
- A clear description of the change.
|
|
35
|
+
- Tests or a short explanation of why tests are not needed.
|
|
36
|
+
- Documentation updates for user-facing behavior.
|
|
37
|
+
|
|
38
|
+
Maintainers may close changes that are outside the public agent integration
|
|
39
|
+
scope or require private service-side details.
|
|
40
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 capsolver-ai
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: capsolver-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Agent integrations for CapSolver — framework-agnostic tool definitions + LangChain tools.
|
|
5
|
+
Project-URL: Homepage, https://capsolver.com
|
|
6
|
+
Project-URL: Repository, https://github.com/capsolver-ai/agent-capsolver
|
|
7
|
+
Project-URL: Issues, https://github.com/capsolver-ai/agent-capsolver/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/capsolver-ai/agent-capsolver/blob/main/docs/agent-integration.md
|
|
9
|
+
Project-URL: Changelog, https://github.com/capsolver-ai/agent-capsolver/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Security, https://github.com/capsolver-ai/agent-capsolver/blob/main/SECURITY.md
|
|
11
|
+
Author-email: capsolver-ai <dev@capsolver.ai>
|
|
12
|
+
License-Expression: ISC
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: agent,ai-agent,capsolver,captcha,langchain,tools
|
|
15
|
+
Classifier: Development Status :: 3 - Alpha
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: capsolver-core>=0.1.0
|
|
28
|
+
Provides-Extra: browser
|
|
29
|
+
Requires-Dist: playwright>=1.40; extra == 'browser'
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-asyncio>=1.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
35
|
+
Provides-Extra: langchain
|
|
36
|
+
Requires-Dist: langchain-core>=0.3.0; extra == 'langchain'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# capsolver-agent
|
|
40
|
+
|
|
41
|
+
Agent integrations for [CapSolver](https://capsolver.com) — framework-agnostic tool definitions and LangChain BaseTool implementations.
|
|
42
|
+
|
|
43
|
+
See the [capsolver-ai](https://github.com/capsolver-ai/capsolver-ai) hub repo for integration examples and the full documentation.
|
|
44
|
+
|
|
45
|
+
For framework integration guides (OpenAI, LangChain, LlamaIndex, CrewAI, Google ADK, and more), see [docs/agent-integration.md](docs/agent-integration.md).
|
|
46
|
+
|
|
47
|
+
## Install
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install capsolver-agent
|
|
51
|
+
pip install capsolver-agent[langchain] # with LangChain support
|
|
52
|
+
pip install capsolver-agent[browser] # with Playwright support (for detect/solve_on_page)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
All packages read the API key from the environment:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# bash / zsh
|
|
59
|
+
export CAPSOLVER_API_KEY="your-capsolver-api-key"
|
|
60
|
+
|
|
61
|
+
# PowerShell
|
|
62
|
+
$env:CAPSOLVER_API_KEY = "your-capsolver-api-key"
|
|
63
|
+
|
|
64
|
+
# cmd
|
|
65
|
+
set CAPSOLVER_API_KEY=your-capsolver-api-key
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Framework-agnostic tools (any LLM / agent framework)
|
|
69
|
+
|
|
70
|
+
Use `schema.py` to get tool schemas as JSON and an async executor to run tool calls. Works with OpenAI function calling, OpenAI Agents SDK, Browser Use, or any custom agent loop.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import asyncio
|
|
74
|
+
from capsolver_agent.schema import get_all_tools, create_executor
|
|
75
|
+
|
|
76
|
+
async def main():
|
|
77
|
+
# 1. Get tool schemas — feed to your LLM's function-calling API
|
|
78
|
+
tools = get_all_tools()
|
|
79
|
+
openai_functions = [t.to_openai_function() for t in tools]
|
|
80
|
+
|
|
81
|
+
# 2. Execute a tool call returned by the LLM
|
|
82
|
+
executor = create_executor(api_key="YOUR_API_KEY")
|
|
83
|
+
result = await executor.execute("solve_captcha", {
|
|
84
|
+
"captcha_type": "reCaptchaV2",
|
|
85
|
+
"website_url": "https://example.com",
|
|
86
|
+
"website_key": "6Le-wvkSAAAAAPBMRT...",
|
|
87
|
+
})
|
|
88
|
+
print(result)
|
|
89
|
+
# {"success": True, "solution": {"token": "03AF...", ...}}
|
|
90
|
+
|
|
91
|
+
asyncio.run(main())
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Each `ToolDef` provides two export formats:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
tool = get_all_tools()[0]
|
|
98
|
+
tool.to_openai_function() # → OpenAI function-calling schema
|
|
99
|
+
tool.to_json_schema() # → MCP-style tool descriptor (name + inputSchema)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For a quick one-shot call without creating an executor:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from capsolver_agent.schema import execute_tool
|
|
106
|
+
|
|
107
|
+
result = await execute_tool("solve_captcha", {
|
|
108
|
+
"captcha_type": "reCaptchaV2",
|
|
109
|
+
"website_url": "https://example.com",
|
|
110
|
+
"website_key": "6Le-wvkSAAAAAPBMRT...",
|
|
111
|
+
}, api_key="YOUR_API_KEY")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## LangChain integration
|
|
115
|
+
|
|
116
|
+
Pre-built `BaseTool` subclasses with Pydantic input schemas — plug directly into any LangChain agent.
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
import asyncio
|
|
120
|
+
from capsolver_agent.langchain_tools import get_langchain_tools
|
|
121
|
+
from langchain_openai import ChatOpenAI
|
|
122
|
+
from langgraph.prebuilt import create_react_agent
|
|
123
|
+
|
|
124
|
+
tools = get_langchain_tools(api_key="YOUR_API_KEY")
|
|
125
|
+
|
|
126
|
+
llm = ChatOpenAI(model="gpt-4o")
|
|
127
|
+
agent = create_react_agent(llm, tools)
|
|
128
|
+
|
|
129
|
+
async def main():
|
|
130
|
+
result = await agent.ainvoke({"messages": [...]})
|
|
131
|
+
|
|
132
|
+
asyncio.run(main())
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Or import individual tools:
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from capsolver_agent.langchain_tools import SolveCaptchaTool, GetBalanceTool
|
|
139
|
+
|
|
140
|
+
solver = SolveCaptchaTool(api_key="YOUR_API_KEY")
|
|
141
|
+
balance = GetBalanceTool(api_key="YOUR_API_KEY")
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## CLI
|
|
145
|
+
|
|
146
|
+
The `capsolver-agent` command lets you inspect available tools and their schemas from the terminal.
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# List all tools with descriptions
|
|
150
|
+
capsolver-agent list
|
|
151
|
+
|
|
152
|
+
# Show JSON Schema for a specific tool
|
|
153
|
+
capsolver-agent schema solve_captcha
|
|
154
|
+
|
|
155
|
+
# Export all tools in OpenAI function-calling format
|
|
156
|
+
capsolver-agent schema --format openai
|
|
157
|
+
|
|
158
|
+
# Export one tool in OpenAI format
|
|
159
|
+
capsolver-agent schema --format openai detect_captchas
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Also works via `python -m capsolver_agent list`.
|
|
163
|
+
|
|
164
|
+
## Available tools
|
|
165
|
+
|
|
166
|
+
| Tool | Browser? | Description |
|
|
167
|
+
|---|---|---|
|
|
168
|
+
| `solve_captcha` | No | Token-mode solving — provide type + URL + site key, get a token back |
|
|
169
|
+
| `detect_captchas` | Yes | Scan a page URL and return which captcha types are present |
|
|
170
|
+
| `solve_on_page` | Yes | One-shot: detect + solve + autofill all captchas on a page |
|
|
171
|
+
| `get_balance` | No | Check account balance and packages |
|
|
172
|
+
| `get_supported_captchas` | No | List all supported captcha types and handler names |
|
|
173
|
+
|
|
174
|
+
Browser-based tools require `pip install capsolver-agent[browser]` and `playwright install chromium`.
|
|
175
|
+
|
|
176
|
+
## Integration examples
|
|
177
|
+
|
|
178
|
+
See the [capsolver-ai examples](https://github.com/capsolver-ai/capsolver-ai/tree/main/examples) for runnable demos:
|
|
179
|
+
|
|
180
|
+
- `openai_function_calling.py` — agentic loop with OpenAI function calling
|
|
181
|
+
- `openai_agents.py` — OpenAI Agents SDK with `@function_tool`
|
|
182
|
+
- `langchain_agent.py` — LangChain ReAct agent
|
|
183
|
+
- `browser_use_agent.py` — Browser Use with `@tools.action()`
|
|
184
|
+
|
|
185
|
+
## Development
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
git clone https://github.com/capsolver-ai/agent-capsolver.git
|
|
189
|
+
cd agent-capsolver
|
|
190
|
+
uv sync --all-extras # or: pip install -r requirements-dev.txt
|
|
191
|
+
uv run pytest # run tests
|
|
192
|
+
uv run ruff check src tests # lint
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## License
|
|
196
|
+
|
|
197
|
+
ISC
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Publishing
|
|
2
|
+
|
|
3
|
+
Release target: `capsolver-agent` version `0.1.0`, prepared for public release
|
|
4
|
+
on 2026-09-01.
|
|
5
|
+
|
|
6
|
+
This checklist is for maintainers syncing the prepared public files to the
|
|
7
|
+
official open-source repository, testing the package on TestPyPI, and then
|
|
8
|
+
publishing the final package to PyPI.
|
|
9
|
+
|
|
10
|
+
Publish `capsolver-core==0.1.0` first. This package depends on
|
|
11
|
+
`capsolver-core>=0.1.0`.
|
|
12
|
+
|
|
13
|
+
## Preconditions
|
|
14
|
+
|
|
15
|
+
- The source is the prepared public copy, not a private development checkout.
|
|
16
|
+
- `capsolver-core==0.1.0` has already passed TestPyPI testing before this
|
|
17
|
+
package is tested.
|
|
18
|
+
- `capsolver-core==0.1.0` is already available on PyPI before this package is
|
|
19
|
+
formally published.
|
|
20
|
+
- `pyproject.toml` has `version = "0.1.0"`.
|
|
21
|
+
- `CHANGELOG.md` has `## [0.1.0] - 2026-09-01`.
|
|
22
|
+
- `README.md`, `LICENSE`, `SECURITY.md`, `CONTRIBUTING.md`, and `SUPPORT.md`
|
|
23
|
+
are present.
|
|
24
|
+
- Documentation examples use placeholder credentials only.
|
|
25
|
+
- The tree does not contain `.git`, `.venv`, `uv.lock`, caches, local path
|
|
26
|
+
overrides, real API keys, browser profiles, prompts, tool traces, or private
|
|
27
|
+
service data.
|
|
28
|
+
|
|
29
|
+
## Sync to the Official Open-Source Repository
|
|
30
|
+
|
|
31
|
+
Copy this directory into the official `agent-capsolver` public repository
|
|
32
|
+
working tree, then review the diff before committing.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
git status
|
|
36
|
+
git diff
|
|
37
|
+
git add .
|
|
38
|
+
git commit -m "Release v0.1.0"
|
|
39
|
+
git status
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Do not tag until the build, TestPyPI upload, and install test have passed.
|
|
43
|
+
|
|
44
|
+
## Verify Locally
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
uv sync --all-extras
|
|
48
|
+
uv run pytest
|
|
49
|
+
uv run ruff check src tests
|
|
50
|
+
uv run mypy src
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Build and Check
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
python -m pip install --upgrade build twine
|
|
57
|
+
python -m build
|
|
58
|
+
python -m twine check dist/*
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Inspect the source distribution and wheel before upload. Confirm that no
|
|
62
|
+
private files, local paths, secrets, browser profiles, caches, prompts, tool
|
|
63
|
+
traces, or test output are included.
|
|
64
|
+
|
|
65
|
+
## TestPyPI Test Release
|
|
66
|
+
|
|
67
|
+
Upload the exact distribution files to TestPyPI first.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
python -m twine upload --repository testpypi dist/*
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Install from TestPyPI in a clean environment and smoke-test the CLI import path.
|
|
74
|
+
Use PyPI as an extra index so normal third-party dependencies can still resolve.
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ capsolver-agent==0.1.0
|
|
78
|
+
python -c "import capsolver_agent; print(capsolver_agent.__version__)"
|
|
79
|
+
capsolver-agent --help
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
PyPI and TestPyPI distributions cannot be overwritten. If the test upload is
|
|
83
|
+
wrong, fix the issue and publish a new version.
|
|
84
|
+
|
|
85
|
+
## Formal PyPI Release
|
|
86
|
+
|
|
87
|
+
After TestPyPI passes and `capsolver-core==0.1.0` is available from PyPI, upload
|
|
88
|
+
the same checked distribution files to PyPI.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
python -m twine upload dist/*
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Then verify installation from PyPI.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
python -m pip install capsolver-agent==0.1.0
|
|
98
|
+
python -c "import capsolver_agent; print(capsolver_agent.__version__)"
|
|
99
|
+
capsolver-agent --help
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Tag and GitHub Release
|
|
103
|
+
|
|
104
|
+
When the PyPI release is verified, create the release tag and push it from the
|
|
105
|
+
official public repository.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
git tag v0.1.0
|
|
109
|
+
git push origin main
|
|
110
|
+
git push origin v0.1.0
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Create a GitHub Release for `v0.1.0` using the `CHANGELOG.md` entry.
|
|
114
|
+
|
|
115
|
+
Prefer PyPI Trusted Publishing from the official public GitHub repository for
|
|
116
|
+
future releases. If manual upload is used, use a project-scoped PyPI API token
|
|
117
|
+
instead of an account password.
|
|
118
|
+
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# capsolver-agent
|
|
2
|
+
|
|
3
|
+
Agent integrations for [CapSolver](https://capsolver.com) — framework-agnostic tool definitions and LangChain BaseTool implementations.
|
|
4
|
+
|
|
5
|
+
See the [capsolver-ai](https://github.com/capsolver-ai/capsolver-ai) hub repo for integration examples and the full documentation.
|
|
6
|
+
|
|
7
|
+
For framework integration guides (OpenAI, LangChain, LlamaIndex, CrewAI, Google ADK, and more), see [docs/agent-integration.md](docs/agent-integration.md).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install capsolver-agent
|
|
13
|
+
pip install capsolver-agent[langchain] # with LangChain support
|
|
14
|
+
pip install capsolver-agent[browser] # with Playwright support (for detect/solve_on_page)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
All packages read the API key from the environment:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# bash / zsh
|
|
21
|
+
export CAPSOLVER_API_KEY="your-capsolver-api-key"
|
|
22
|
+
|
|
23
|
+
# PowerShell
|
|
24
|
+
$env:CAPSOLVER_API_KEY = "your-capsolver-api-key"
|
|
25
|
+
|
|
26
|
+
# cmd
|
|
27
|
+
set CAPSOLVER_API_KEY=your-capsolver-api-key
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Framework-agnostic tools (any LLM / agent framework)
|
|
31
|
+
|
|
32
|
+
Use `schema.py` to get tool schemas as JSON and an async executor to run tool calls. Works with OpenAI function calling, OpenAI Agents SDK, Browser Use, or any custom agent loop.
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import asyncio
|
|
36
|
+
from capsolver_agent.schema import get_all_tools, create_executor
|
|
37
|
+
|
|
38
|
+
async def main():
|
|
39
|
+
# 1. Get tool schemas — feed to your LLM's function-calling API
|
|
40
|
+
tools = get_all_tools()
|
|
41
|
+
openai_functions = [t.to_openai_function() for t in tools]
|
|
42
|
+
|
|
43
|
+
# 2. Execute a tool call returned by the LLM
|
|
44
|
+
executor = create_executor(api_key="YOUR_API_KEY")
|
|
45
|
+
result = await executor.execute("solve_captcha", {
|
|
46
|
+
"captcha_type": "reCaptchaV2",
|
|
47
|
+
"website_url": "https://example.com",
|
|
48
|
+
"website_key": "6Le-wvkSAAAAAPBMRT...",
|
|
49
|
+
})
|
|
50
|
+
print(result)
|
|
51
|
+
# {"success": True, "solution": {"token": "03AF...", ...}}
|
|
52
|
+
|
|
53
|
+
asyncio.run(main())
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Each `ToolDef` provides two export formats:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
tool = get_all_tools()[0]
|
|
60
|
+
tool.to_openai_function() # → OpenAI function-calling schema
|
|
61
|
+
tool.to_json_schema() # → MCP-style tool descriptor (name + inputSchema)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
For a quick one-shot call without creating an executor:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from capsolver_agent.schema import execute_tool
|
|
68
|
+
|
|
69
|
+
result = await execute_tool("solve_captcha", {
|
|
70
|
+
"captcha_type": "reCaptchaV2",
|
|
71
|
+
"website_url": "https://example.com",
|
|
72
|
+
"website_key": "6Le-wvkSAAAAAPBMRT...",
|
|
73
|
+
}, api_key="YOUR_API_KEY")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## LangChain integration
|
|
77
|
+
|
|
78
|
+
Pre-built `BaseTool` subclasses with Pydantic input schemas — plug directly into any LangChain agent.
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import asyncio
|
|
82
|
+
from capsolver_agent.langchain_tools import get_langchain_tools
|
|
83
|
+
from langchain_openai import ChatOpenAI
|
|
84
|
+
from langgraph.prebuilt import create_react_agent
|
|
85
|
+
|
|
86
|
+
tools = get_langchain_tools(api_key="YOUR_API_KEY")
|
|
87
|
+
|
|
88
|
+
llm = ChatOpenAI(model="gpt-4o")
|
|
89
|
+
agent = create_react_agent(llm, tools)
|
|
90
|
+
|
|
91
|
+
async def main():
|
|
92
|
+
result = await agent.ainvoke({"messages": [...]})
|
|
93
|
+
|
|
94
|
+
asyncio.run(main())
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Or import individual tools:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from capsolver_agent.langchain_tools import SolveCaptchaTool, GetBalanceTool
|
|
101
|
+
|
|
102
|
+
solver = SolveCaptchaTool(api_key="YOUR_API_KEY")
|
|
103
|
+
balance = GetBalanceTool(api_key="YOUR_API_KEY")
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## CLI
|
|
107
|
+
|
|
108
|
+
The `capsolver-agent` command lets you inspect available tools and their schemas from the terminal.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# List all tools with descriptions
|
|
112
|
+
capsolver-agent list
|
|
113
|
+
|
|
114
|
+
# Show JSON Schema for a specific tool
|
|
115
|
+
capsolver-agent schema solve_captcha
|
|
116
|
+
|
|
117
|
+
# Export all tools in OpenAI function-calling format
|
|
118
|
+
capsolver-agent schema --format openai
|
|
119
|
+
|
|
120
|
+
# Export one tool in OpenAI format
|
|
121
|
+
capsolver-agent schema --format openai detect_captchas
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Also works via `python -m capsolver_agent list`.
|
|
125
|
+
|
|
126
|
+
## Available tools
|
|
127
|
+
|
|
128
|
+
| Tool | Browser? | Description |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| `solve_captcha` | No | Token-mode solving — provide type + URL + site key, get a token back |
|
|
131
|
+
| `detect_captchas` | Yes | Scan a page URL and return which captcha types are present |
|
|
132
|
+
| `solve_on_page` | Yes | One-shot: detect + solve + autofill all captchas on a page |
|
|
133
|
+
| `get_balance` | No | Check account balance and packages |
|
|
134
|
+
| `get_supported_captchas` | No | List all supported captcha types and handler names |
|
|
135
|
+
|
|
136
|
+
Browser-based tools require `pip install capsolver-agent[browser]` and `playwright install chromium`.
|
|
137
|
+
|
|
138
|
+
## Integration examples
|
|
139
|
+
|
|
140
|
+
See the [capsolver-ai examples](https://github.com/capsolver-ai/capsolver-ai/tree/main/examples) for runnable demos:
|
|
141
|
+
|
|
142
|
+
- `openai_function_calling.py` — agentic loop with OpenAI function calling
|
|
143
|
+
- `openai_agents.py` — OpenAI Agents SDK with `@function_tool`
|
|
144
|
+
- `langchain_agent.py` — LangChain ReAct agent
|
|
145
|
+
- `browser_use_agent.py` — Browser Use with `@tools.action()`
|
|
146
|
+
|
|
147
|
+
## Development
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
git clone https://github.com/capsolver-ai/agent-capsolver.git
|
|
151
|
+
cd agent-capsolver
|
|
152
|
+
uv sync --all-extras # or: pip install -r requirements-dev.txt
|
|
153
|
+
uv run pytest # run tests
|
|
154
|
+
uv run ruff check src tests # lint
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
ISC
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Security fixes are provided for the latest public release line.
|
|
6
|
+
|
|
7
|
+
| Version | Supported |
|
|
8
|
+
| ------- | --------- |
|
|
9
|
+
| 0.1.x | Yes |
|
|
10
|
+
|
|
11
|
+
## Reporting a Vulnerability
|
|
12
|
+
|
|
13
|
+
Please do not open public issues for vulnerabilities, leaked credentials, or
|
|
14
|
+
reports that include private target URLs, API keys, prompts, tool traces, or
|
|
15
|
+
customer data.
|
|
16
|
+
|
|
17
|
+
Report security issues by emailing `dev@capsolver.ai` with:
|
|
18
|
+
|
|
19
|
+
- The affected package and version.
|
|
20
|
+
- A concise description of the issue.
|
|
21
|
+
- Reproduction steps or a minimal proof of concept.
|
|
22
|
+
- The impact you believe the issue has.
|
|
23
|
+
|
|
24
|
+
We will acknowledge valid reports as soon as possible and coordinate a fix or
|
|
25
|
+
mitigation before public disclosure.
|
|
26
|
+
|
|
27
|
+
## Handling API Keys and Agent Data
|
|
28
|
+
|
|
29
|
+
Never commit real `CAPSOLVER_API_KEY` values, browser profiles, cookies,
|
|
30
|
+
captured tokens, prompts, or agent traces. Documentation examples must use
|
|
31
|
+
placeholder values only.
|
|
32
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Support
|
|
2
|
+
|
|
3
|
+
Use the right channel for the type of help you need.
|
|
4
|
+
|
|
5
|
+
## Package Bugs and Documentation
|
|
6
|
+
|
|
7
|
+
Open a GitHub issue for:
|
|
8
|
+
|
|
9
|
+
- Installation problems.
|
|
10
|
+
- Runtime errors in this package.
|
|
11
|
+
- Documentation mistakes.
|
|
12
|
+
- Compatibility issues with supported Python versions, agent frameworks, or
|
|
13
|
+
optional browser tooling.
|
|
14
|
+
|
|
15
|
+
Include the package version, Python version, operating system, framework name
|
|
16
|
+
and version, and a minimal reproduction when possible.
|
|
17
|
+
|
|
18
|
+
## CapSolver Account or API Service Issues
|
|
19
|
+
|
|
20
|
+
For account access, billing, API key, balance, or service availability issues,
|
|
21
|
+
use the support options available from `https://capsolver.com`.
|
|
22
|
+
|
|
23
|
+
Do not post API keys, account identifiers, cookies, browser profiles, prompts,
|
|
24
|
+
tool traces, or target site credentials in public issues.
|
|
25
|
+
|