monkeycode-sdk 1.7.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.
- monkeycode_sdk-1.7.0/LICENSE +21 -0
- monkeycode_sdk-1.7.0/PKG-INFO +93 -0
- monkeycode_sdk-1.7.0/README.md +69 -0
- monkeycode_sdk-1.7.0/monkeycode/__init__.py +58 -0
- monkeycode_sdk-1.7.0/monkeycode/client.py +2141 -0
- monkeycode_sdk-1.7.0/monkeycode/consts.py +29 -0
- monkeycode_sdk-1.7.0/monkeycode/errors.py +30 -0
- monkeycode_sdk-1.7.0/monkeycode/links.py +138 -0
- monkeycode_sdk-1.7.0/monkeycode/models.py +227 -0
- monkeycode_sdk-1.7.0/monkeycode/pow.py +65 -0
- monkeycode_sdk-1.7.0/monkeycode/session.py +140 -0
- monkeycode_sdk-1.7.0/monkeycode/stream.py +381 -0
- monkeycode_sdk-1.7.0/monkeycode_sdk.egg-info/PKG-INFO +93 -0
- monkeycode_sdk-1.7.0/monkeycode_sdk.egg-info/SOURCES.txt +23 -0
- monkeycode_sdk-1.7.0/monkeycode_sdk.egg-info/dependency_links.txt +1 -0
- monkeycode_sdk-1.7.0/monkeycode_sdk.egg-info/requires.txt +4 -0
- monkeycode_sdk-1.7.0/monkeycode_sdk.egg-info/top_level.txt +1 -0
- monkeycode_sdk-1.7.0/pyproject.toml +39 -0
- monkeycode_sdk-1.7.0/setup.cfg +4 -0
- monkeycode_sdk-1.7.0/tests/test_client.py +176 -0
- monkeycode_sdk-1.7.0/tests/test_errors.py +29 -0
- monkeycode_sdk-1.7.0/tests/test_links.py +155 -0
- monkeycode_sdk-1.7.0/tests/test_models.py +96 -0
- monkeycode_sdk-1.7.0/tests/test_pow.py +53 -0
- monkeycode_sdk-1.7.0/tests/test_stream.py +52 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cyqmq
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: monkeycode-sdk
|
|
3
|
+
Version: 1.7.0
|
|
4
|
+
Summary: MonkeyCode 云平台 REST API 的 Python SDK(认证、任务提交、结果轮询)
|
|
5
|
+
Author: cyqmq
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/cyqmq/monkeycode-sdk
|
|
8
|
+
Project-URL: Repository, https://github.com/cyqmq/monkeycode-sdk
|
|
9
|
+
Keywords: monkeycode,ai,coding,agent,sdk
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: httpx>=0.27
|
|
21
|
+
Requires-Dist: websockets>=12
|
|
22
|
+
Provides-Extra: cli
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# monkeycode-sdk
|
|
26
|
+
|
|
27
|
+
MonkeyCode 云平台 REST API 的 Python SDK。用于在任意 Python 项目/聊天框架(AstrBot、NoneBot 等)中:
|
|
28
|
+
认证登录 → 创建 AI 编程任务 → 轮询结果,让机器人像人一样使用 MonkeyCode。
|
|
29
|
+
|
|
30
|
+
**特性**
|
|
31
|
+
- 密码登录 / 团队登录 / PoW 验证码全自动求解
|
|
32
|
+
- 会话持久化:Cookie 保存到文件,长期运行自动重登(401 自动恢复)
|
|
33
|
+
- 任务创建(附件、技能、默认档位)、列表、轮询、WebSocket 实时会话
|
|
34
|
+
- AgentSession 高层封装:断线自动重连 + 事件缓冲
|
|
35
|
+
- 任务控制通道:切换模型、重启、技能/插件、仓库文件 diff/changes 等同步调用
|
|
36
|
+
- 项目管理、Git 身份、Git Bots、钱包签到、文件/VM 管理、预览链接
|
|
37
|
+
- 虚拟机终端:会话管理(REST)+ 实时交互/共享加入(WebSocket)
|
|
38
|
+
- 用户与会话:whoami / logout / 团队会话列表
|
|
39
|
+
- 配置管理:模型/宿主机/VM/端口转发/Git 身份 CRUD 与健康检查
|
|
40
|
+
- 团队管理:用户/分组/宿主/镜像/模型/技能/MCP/通知/OAuth/扩展包完整控制面
|
|
41
|
+
- 分页迭代:`iter_tasks` / `iter_projects` / `paginate` 自动翻页
|
|
42
|
+
- 健壮性:只读请求自动重试(指数退避)、429 限流等待、错误提示友好化
|
|
43
|
+
- CLI:25+ 命令(任务/钱包/项目/终端/API Key/会话控制)
|
|
44
|
+
- 覆盖完整 REST API(镜像/MCP/通知/团队管理/License/社区等)
|
|
45
|
+
- 支持自托管部署
|
|
46
|
+
|
|
47
|
+
## 安装
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install monkeycode-sdk
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
或从源码安装:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
git clone https://github.com/cyqmq/monkeycode-sdk.git
|
|
57
|
+
cd monkeycode-sdk
|
|
58
|
+
pip install -e .
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 快速开始
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from monkeycode import MonkeyCodeClient
|
|
65
|
+
from monkeycode.models import RepoReq
|
|
66
|
+
|
|
67
|
+
client = MonkeyCodeClient(email="you@example.com", password="your_password")
|
|
68
|
+
client.login() # PoW 验证码自动求解
|
|
69
|
+
|
|
70
|
+
# 创建任务(默认档位;repo 可空)
|
|
71
|
+
task = client.create_task(
|
|
72
|
+
content="修复登录接口的异常处理",
|
|
73
|
+
repo=RepoReq(repo_url="https://github.com/org/repo", branch="main"),
|
|
74
|
+
skill_ids=["feature-design", "project-wiki"],
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# 轮询结果
|
|
78
|
+
result = client.wait_task(task.id, timeout=1800, interval=10)
|
|
79
|
+
print(result.status, result.pr_url)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 文档导航
|
|
83
|
+
|
|
84
|
+
| 文档 | 内容 |
|
|
85
|
+
|---|---|
|
|
86
|
+
| [docs/认证说明.md](docs/认证说明.md) | 密码/PoW/团队登录、自托管、安全提示 |
|
|
87
|
+
| [docs/功能参考.md](docs/功能参考.md) | 全部功能方法示例(任务/项目/Git/钱包/文件/预览/管理) |
|
|
88
|
+
| [docs/API.md](docs/API.md) | 全部公开方法索引表(205 个) |
|
|
89
|
+
| [docs/架构说明.md](docs/架构说明.md) | 模块划分、WebSocket 协议摘要、认证流程 |
|
|
90
|
+
| [docs/CLI.md](docs/CLI.md) | 命令行使用 |
|
|
91
|
+
| [docs/已知问题.md](docs/已知问题.md) | 平台侧已知问题、开发与参考 |
|
|
92
|
+
|
|
93
|
+
完整变更见 [CHANGELOG.md](CHANGELOG.md)。
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# monkeycode-sdk
|
|
2
|
+
|
|
3
|
+
MonkeyCode 云平台 REST API 的 Python SDK。用于在任意 Python 项目/聊天框架(AstrBot、NoneBot 等)中:
|
|
4
|
+
认证登录 → 创建 AI 编程任务 → 轮询结果,让机器人像人一样使用 MonkeyCode。
|
|
5
|
+
|
|
6
|
+
**特性**
|
|
7
|
+
- 密码登录 / 团队登录 / PoW 验证码全自动求解
|
|
8
|
+
- 会话持久化:Cookie 保存到文件,长期运行自动重登(401 自动恢复)
|
|
9
|
+
- 任务创建(附件、技能、默认档位)、列表、轮询、WebSocket 实时会话
|
|
10
|
+
- AgentSession 高层封装:断线自动重连 + 事件缓冲
|
|
11
|
+
- 任务控制通道:切换模型、重启、技能/插件、仓库文件 diff/changes 等同步调用
|
|
12
|
+
- 项目管理、Git 身份、Git Bots、钱包签到、文件/VM 管理、预览链接
|
|
13
|
+
- 虚拟机终端:会话管理(REST)+ 实时交互/共享加入(WebSocket)
|
|
14
|
+
- 用户与会话:whoami / logout / 团队会话列表
|
|
15
|
+
- 配置管理:模型/宿主机/VM/端口转发/Git 身份 CRUD 与健康检查
|
|
16
|
+
- 团队管理:用户/分组/宿主/镜像/模型/技能/MCP/通知/OAuth/扩展包完整控制面
|
|
17
|
+
- 分页迭代:`iter_tasks` / `iter_projects` / `paginate` 自动翻页
|
|
18
|
+
- 健壮性:只读请求自动重试(指数退避)、429 限流等待、错误提示友好化
|
|
19
|
+
- CLI:25+ 命令(任务/钱包/项目/终端/API Key/会话控制)
|
|
20
|
+
- 覆盖完整 REST API(镜像/MCP/通知/团队管理/License/社区等)
|
|
21
|
+
- 支持自托管部署
|
|
22
|
+
|
|
23
|
+
## 安装
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install monkeycode-sdk
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
或从源码安装:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/cyqmq/monkeycode-sdk.git
|
|
33
|
+
cd monkeycode-sdk
|
|
34
|
+
pip install -e .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 快速开始
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from monkeycode import MonkeyCodeClient
|
|
41
|
+
from monkeycode.models import RepoReq
|
|
42
|
+
|
|
43
|
+
client = MonkeyCodeClient(email="you@example.com", password="your_password")
|
|
44
|
+
client.login() # PoW 验证码自动求解
|
|
45
|
+
|
|
46
|
+
# 创建任务(默认档位;repo 可空)
|
|
47
|
+
task = client.create_task(
|
|
48
|
+
content="修复登录接口的异常处理",
|
|
49
|
+
repo=RepoReq(repo_url="https://github.com/org/repo", branch="main"),
|
|
50
|
+
skill_ids=["feature-design", "project-wiki"],
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# 轮询结果
|
|
54
|
+
result = client.wait_task(task.id, timeout=1800, interval=10)
|
|
55
|
+
print(result.status, result.pr_url)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 文档导航
|
|
59
|
+
|
|
60
|
+
| 文档 | 内容 |
|
|
61
|
+
|---|---|
|
|
62
|
+
| [docs/认证说明.md](docs/认证说明.md) | 密码/PoW/团队登录、自托管、安全提示 |
|
|
63
|
+
| [docs/功能参考.md](docs/功能参考.md) | 全部功能方法示例(任务/项目/Git/钱包/文件/预览/管理) |
|
|
64
|
+
| [docs/API.md](docs/API.md) | 全部公开方法索引表(205 个) |
|
|
65
|
+
| [docs/架构说明.md](docs/架构说明.md) | 模块划分、WebSocket 协议摘要、认证流程 |
|
|
66
|
+
| [docs/CLI.md](docs/CLI.md) | 命令行使用 |
|
|
67
|
+
| [docs/已知问题.md](docs/已知问题.md) | 平台侧已知问题、开发与参考 |
|
|
68
|
+
|
|
69
|
+
完整变更见 [CHANGELOG.md](CHANGELOG.md)。
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""MonkeyCode SDK。
|
|
2
|
+
|
|
3
|
+
封装 MonkeyCode 云平台 REST API,提供认证、任务提交、结果轮询、
|
|
4
|
+
WebSocket 会话交互等能力。
|
|
5
|
+
"""
|
|
6
|
+
from monkeycode.client import MonkeyCodeClient
|
|
7
|
+
from monkeycode.errors import (
|
|
8
|
+
APIError,
|
|
9
|
+
AuthenticationError,
|
|
10
|
+
CaptchaRequiredError,
|
|
11
|
+
RateLimitError,
|
|
12
|
+
TaskError,
|
|
13
|
+
)
|
|
14
|
+
from monkeycode.models import (
|
|
15
|
+
APIKeyInfo,
|
|
16
|
+
CaptchaChallenge,
|
|
17
|
+
CaptchaVerification,
|
|
18
|
+
RepoReq,
|
|
19
|
+
Task,
|
|
20
|
+
TaskExtraConfig,
|
|
21
|
+
TaskRound,
|
|
22
|
+
TaskStreamChunk,
|
|
23
|
+
UserInputPayload,
|
|
24
|
+
VMResource,
|
|
25
|
+
)
|
|
26
|
+
from monkeycode.session import AgentSession
|
|
27
|
+
from monkeycode.stream import (
|
|
28
|
+
ControlStream,
|
|
29
|
+
JoinTerminalStream,
|
|
30
|
+
TaskStream,
|
|
31
|
+
TerminalStream,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__version__ = "1.7.0"
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
"MonkeyCodeClient",
|
|
38
|
+
"APIError",
|
|
39
|
+
"AuthenticationError",
|
|
40
|
+
"CaptchaRequiredError",
|
|
41
|
+
"RateLimitError",
|
|
42
|
+
"TaskError",
|
|
43
|
+
"APIKeyInfo",
|
|
44
|
+
"CaptchaChallenge",
|
|
45
|
+
"CaptchaVerification",
|
|
46
|
+
"RepoReq",
|
|
47
|
+
"Task",
|
|
48
|
+
"TaskExtraConfig",
|
|
49
|
+
"TaskRound",
|
|
50
|
+
"TaskStream",
|
|
51
|
+
"TaskStreamChunk",
|
|
52
|
+
"UserInputPayload",
|
|
53
|
+
"VMResource",
|
|
54
|
+
"ControlStream",
|
|
55
|
+
"TerminalStream",
|
|
56
|
+
"JoinTerminalStream",
|
|
57
|
+
"AgentSession",
|
|
58
|
+
]
|