selfclaw 1.0.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.
- selfclaw-1.0.0/LICENSE +21 -0
- selfclaw-1.0.0/MANIFEST.in +13 -0
- selfclaw-1.0.0/PKG-INFO +98 -0
- selfclaw-1.0.0/README.md +53 -0
- selfclaw-1.0.0/pyproject.toml +73 -0
- selfclaw-1.0.0/requirements.txt +25 -0
- selfclaw-1.0.0/selfclaw/__init__.py +8 -0
- selfclaw-1.0.0/selfclaw/cli.py +416 -0
- selfclaw-1.0.0/selfclaw.egg-info/PKG-INFO +98 -0
- selfclaw-1.0.0/selfclaw.egg-info/SOURCES.txt +14 -0
- selfclaw-1.0.0/selfclaw.egg-info/dependency_links.txt +1 -0
- selfclaw-1.0.0/selfclaw.egg-info/entry_points.txt +2 -0
- selfclaw-1.0.0/selfclaw.egg-info/requires.txt +14 -0
- selfclaw-1.0.0/selfclaw.egg-info/top_level.txt +1 -0
- selfclaw-1.0.0/setup.cfg +4 -0
- selfclaw-1.0.0/setup.py +77 -0
selfclaw-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 raychiu0202
|
|
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,13 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include requirements.txt
|
|
4
|
+
recursive-include selfclaw *.py *.yaml *.yml *.json *.txt
|
|
5
|
+
exclude *.pyc
|
|
6
|
+
exclude __pycache__
|
|
7
|
+
exclude .git*
|
|
8
|
+
exclude .DS_Store
|
|
9
|
+
exclude .pytest_cache
|
|
10
|
+
exclude venv
|
|
11
|
+
exclude node_modules
|
|
12
|
+
exclude *.so
|
|
13
|
+
exclude *.egg-info
|
selfclaw-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: selfclaw
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Selfclaw - AI Agent System based on GLM-5
|
|
5
|
+
Home-page: https://github.com/raychiu0202/selfclaw
|
|
6
|
+
Author: raychiu0202
|
|
7
|
+
Author-email: raychiu0202 <your-email@example.com>
|
|
8
|
+
Maintainer: raychiu0202
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Bug Reports, https://github.com/raychiu0202/selfclaw/issues
|
|
11
|
+
Project-URL: Source, https://github.com/raychiu0202/selfclaw
|
|
12
|
+
Project-URL: Documentation, https://github.com/raychiu0202/selfclaw/docs
|
|
13
|
+
Keywords: ai,agent,chatbot,llm,glm,terminal,automation
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: fastapi>=0.104.0
|
|
29
|
+
Requires-Dist: uvicorn[standard]>=0.24.0
|
|
30
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
|
31
|
+
Requires-Dist: pymysql>=1.1.0
|
|
32
|
+
Requires-Dist: cryptography>=41.0.0
|
|
33
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
34
|
+
Requires-Dist: zhipuai>=2.0.0
|
|
35
|
+
Requires-Dist: click>=8.1.0
|
|
36
|
+
Requires-Dist: pyyaml>=6.0
|
|
37
|
+
Provides-Extra: dev
|
|
38
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
41
|
+
Dynamic: author
|
|
42
|
+
Dynamic: home-page
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
Dynamic: requires-python
|
|
45
|
+
|
|
46
|
+
# Selfclaw Package
|
|
47
|
+
|
|
48
|
+
基于GLM-5的智能AI助手系统 - 发布包
|
|
49
|
+
|
|
50
|
+
## 安装
|
|
51
|
+
|
|
52
|
+
### NPM安装
|
|
53
|
+
```bash
|
|
54
|
+
npm install -g selfclaw
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### pip安装
|
|
58
|
+
```bash
|
|
59
|
+
pip install selfclaw
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 快速开始
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# 初始化配置
|
|
66
|
+
selfclaw init
|
|
67
|
+
|
|
68
|
+
# 启动服务
|
|
69
|
+
selfclaw start
|
|
70
|
+
|
|
71
|
+
# 查看服务状态
|
|
72
|
+
selfclaw status
|
|
73
|
+
|
|
74
|
+
# 停止服务
|
|
75
|
+
selfclaw stop
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 命令参考
|
|
79
|
+
|
|
80
|
+
- `selfclaw init` - 初始化配置
|
|
81
|
+
- `selfclaw start` - 启动服务
|
|
82
|
+
- `selfclaw stop` - 停止服务
|
|
83
|
+
- `selfclaw status` - 查看服务状态
|
|
84
|
+
- `selfclaw config` - 配置设置
|
|
85
|
+
- `selfclaw clean` - 清理数据
|
|
86
|
+
- `selfclaw logs` - 查看日志
|
|
87
|
+
|
|
88
|
+
## 开发信息
|
|
89
|
+
|
|
90
|
+
- 包名: selfclaw
|
|
91
|
+
- 版本: 1.0.0
|
|
92
|
+
- 作者: raychiu0202
|
|
93
|
+
- 许可证: MIT
|
|
94
|
+
|
|
95
|
+
## 链接
|
|
96
|
+
|
|
97
|
+
- GitHub: https://github.com/raychiu0202/selfclaw
|
|
98
|
+
- 文档: https://github.com/raychiu0202/selfclaw/docs
|
selfclaw-1.0.0/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Selfclaw Package
|
|
2
|
+
|
|
3
|
+
基于GLM-5的智能AI助手系统 - 发布包
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
### NPM安装
|
|
8
|
+
```bash
|
|
9
|
+
npm install -g selfclaw
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### pip安装
|
|
13
|
+
```bash
|
|
14
|
+
pip install selfclaw
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 快速开始
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# 初始化配置
|
|
21
|
+
selfclaw init
|
|
22
|
+
|
|
23
|
+
# 启动服务
|
|
24
|
+
selfclaw start
|
|
25
|
+
|
|
26
|
+
# 查看服务状态
|
|
27
|
+
selfclaw status
|
|
28
|
+
|
|
29
|
+
# 停止服务
|
|
30
|
+
selfclaw stop
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 命令参考
|
|
34
|
+
|
|
35
|
+
- `selfclaw init` - 初始化配置
|
|
36
|
+
- `selfclaw start` - 启动服务
|
|
37
|
+
- `selfclaw stop` - 停止服务
|
|
38
|
+
- `selfclaw status` - 查看服务状态
|
|
39
|
+
- `selfclaw config` - 配置设置
|
|
40
|
+
- `selfclaw clean` - 清理数据
|
|
41
|
+
- `selfclaw logs` - 查看日志
|
|
42
|
+
|
|
43
|
+
## 开发信息
|
|
44
|
+
|
|
45
|
+
- 包名: selfclaw
|
|
46
|
+
- 版本: 1.0.0
|
|
47
|
+
- 作者: raychiu0202
|
|
48
|
+
- 许可证: MIT
|
|
49
|
+
|
|
50
|
+
## 链接
|
|
51
|
+
|
|
52
|
+
- GitHub: https://github.com/raychiu0202/selfclaw
|
|
53
|
+
- 文档: https://github.com/raychiu0202/selfclaw/docs
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "selfclaw"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Selfclaw - AI Agent System based on GLM-5"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "raychiu0202", email = "your-email@example.com"}
|
|
13
|
+
]
|
|
14
|
+
maintainers = [
|
|
15
|
+
{name = "raychiu0202"}
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 4 - Beta",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.8",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
28
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
29
|
+
]
|
|
30
|
+
keywords = ["ai", "agent", "chatbot", "llm", "glm", "terminal", "automation"]
|
|
31
|
+
requires-python = ">=3.8"
|
|
32
|
+
dependencies = [
|
|
33
|
+
"fastapi>=0.104.0",
|
|
34
|
+
"uvicorn[standard]>=0.24.0",
|
|
35
|
+
"sqlalchemy>=2.0.0",
|
|
36
|
+
"pymysql>=1.1.0",
|
|
37
|
+
"cryptography>=41.0.0",
|
|
38
|
+
"python-dotenv>=1.0.0",
|
|
39
|
+
"zhipuai>=2.0.0",
|
|
40
|
+
"click>=8.1.0",
|
|
41
|
+
"pyyaml>=6.0",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[project.optional-dependencies]
|
|
45
|
+
dev = [
|
|
46
|
+
"pytest>=7.0.0",
|
|
47
|
+
"black>=23.0.0",
|
|
48
|
+
"flake8>=6.0.0",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[project.scripts]
|
|
52
|
+
selfclaw = "selfclaw.cli:main"
|
|
53
|
+
|
|
54
|
+
[project.urls]
|
|
55
|
+
"Bug Reports" = "https://github.com/raychiu0202/selfclaw/issues"
|
|
56
|
+
"Source" = "https://github.com/raychiu0202/selfclaw"
|
|
57
|
+
"Documentation" = "https://github.com/raychiu0202/selfclaw/docs"
|
|
58
|
+
|
|
59
|
+
[tool.setuptools]
|
|
60
|
+
packages = ["selfclaw"]
|
|
61
|
+
|
|
62
|
+
[tool.setuptools.package-data]
|
|
63
|
+
selfclaw = ["*.yaml", "*.yml", "*.json", "*.txt"]
|
|
64
|
+
|
|
65
|
+
[tool.black]
|
|
66
|
+
line-length = 88
|
|
67
|
+
target-version = ['py38']
|
|
68
|
+
|
|
69
|
+
[tool.pytest.ini_options]
|
|
70
|
+
testpaths = ["tests"]
|
|
71
|
+
python_files = ["test_*.py"]
|
|
72
|
+
python_classes = ["Test*"]
|
|
73
|
+
python_functions = ["test_*"]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Selfclaw Python Package Requirements
|
|
2
|
+
# 精简依赖,确保最小包体积
|
|
3
|
+
|
|
4
|
+
# Web框架
|
|
5
|
+
fastapi>=0.104.0
|
|
6
|
+
uvicorn[standard]>=0.24.0
|
|
7
|
+
|
|
8
|
+
# 数据库
|
|
9
|
+
sqlalchemy>=2.0.0
|
|
10
|
+
pymysql>=1.1.0
|
|
11
|
+
|
|
12
|
+
# 安全
|
|
13
|
+
cryptography>=41.0.0
|
|
14
|
+
|
|
15
|
+
# 配置
|
|
16
|
+
python-dotenv>=1.0.0
|
|
17
|
+
|
|
18
|
+
# AI模型
|
|
19
|
+
zhipuai>=2.0.0
|
|
20
|
+
|
|
21
|
+
# CLI
|
|
22
|
+
click>=8.1.0
|
|
23
|
+
|
|
24
|
+
# 配置文件解析
|
|
25
|
+
pyyaml>=6.0
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Selfclaw CLI - 命令行接口
|
|
3
|
+
极简设计的命令行工具
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
import json
|
|
9
|
+
import subprocess
|
|
10
|
+
import click
|
|
11
|
+
import shutil
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
# 颜色输出
|
|
15
|
+
def echo_success(message):
|
|
16
|
+
click.echo(click.style(f"✓ {message}", fg="green"))
|
|
17
|
+
|
|
18
|
+
def echo_error(message):
|
|
19
|
+
click.echo(click.style(f"✗ {message}", fg="red"))
|
|
20
|
+
|
|
21
|
+
def echo_info(message):
|
|
22
|
+
click.echo(click.style(f"ℹ {message}", fg="blue"))
|
|
23
|
+
|
|
24
|
+
def echo_warning(message):
|
|
25
|
+
click.echo(click.style(f"⚠ {message}", fg="yellow"))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@click.group()
|
|
29
|
+
@click.version_option("1.0.0")
|
|
30
|
+
def cli():
|
|
31
|
+
"""
|
|
32
|
+
Selfclaw - AI Agent System
|
|
33
|
+
基于GLM-5的智能AI助手系统
|
|
34
|
+
"""
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@cli.command()
|
|
39
|
+
@click.option('--port', default=8000, help='服务端口', type=int)
|
|
40
|
+
@click.option('--debug', is_flag=True, help='调试模式')
|
|
41
|
+
@click.option('--config', help='配置文件路径', type=click.Path(exists=True))
|
|
42
|
+
def start(port, debug, config):
|
|
43
|
+
"""
|
|
44
|
+
启动Selfclaw服务
|
|
45
|
+
"""
|
|
46
|
+
echo_info(f"正在启动Selfclaw服务 (端口: {port})...")
|
|
47
|
+
|
|
48
|
+
# 检查是否已安装
|
|
49
|
+
if not check_installation():
|
|
50
|
+
echo_error("Selfclaw未正确安装,请先运行: selfclaw init")
|
|
51
|
+
sys.exit(1)
|
|
52
|
+
|
|
53
|
+
# 构建启动命令
|
|
54
|
+
backend_dir = get_installation_path("backend")
|
|
55
|
+
frontend_dir = get_installation_path("frontend")
|
|
56
|
+
|
|
57
|
+
if not backend_dir:
|
|
58
|
+
echo_error("后端目录不存在")
|
|
59
|
+
sys.exit(1)
|
|
60
|
+
|
|
61
|
+
# 启动后端
|
|
62
|
+
start_backend(backend_dir, port, debug, config)
|
|
63
|
+
|
|
64
|
+
# 启动前端
|
|
65
|
+
if frontend_dir:
|
|
66
|
+
start_frontend(frontend_dir)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@cli.command()
|
|
70
|
+
def stop():
|
|
71
|
+
"""
|
|
72
|
+
停止Selfclaw服务
|
|
73
|
+
"""
|
|
74
|
+
echo_info("正在停止Selfclaw服务...")
|
|
75
|
+
|
|
76
|
+
# 停止后端和前端服务
|
|
77
|
+
kill_process("uvicorn")
|
|
78
|
+
kill_process("npm")
|
|
79
|
+
|
|
80
|
+
echo_success("Selfclaw服务已停止")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@cli.command()
|
|
84
|
+
def status():
|
|
85
|
+
"""
|
|
86
|
+
查看服务状态
|
|
87
|
+
"""
|
|
88
|
+
echo_info("检查Selfclaw服务状态...")
|
|
89
|
+
|
|
90
|
+
backend_running = check_process("uvicorn")
|
|
91
|
+
frontend_running = check_process("npm")
|
|
92
|
+
|
|
93
|
+
click.echo("\n服务状态:")
|
|
94
|
+
click.echo(f" 后端: {'运行中 ✓' if backend_running else '已停止 ✗'}")
|
|
95
|
+
click.echo(f" 前端: {'运行中 ✓' if frontend_running else '已停止 ✗'}")
|
|
96
|
+
|
|
97
|
+
if backend_running:
|
|
98
|
+
echo_info("后端API: http://localhost:8000")
|
|
99
|
+
echo_info("API文档: http://localhost:8000/docs")
|
|
100
|
+
|
|
101
|
+
if frontend_running:
|
|
102
|
+
echo_info("前端界面: http://localhost:5173")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@cli.command()
|
|
106
|
+
def init():
|
|
107
|
+
"""
|
|
108
|
+
初始化Selfclaw配置
|
|
109
|
+
"""
|
|
110
|
+
echo_info("正在初始化Selfclaw...")
|
|
111
|
+
|
|
112
|
+
# 检查是否已安装
|
|
113
|
+
if check_installation():
|
|
114
|
+
echo_warning("Selfclaw已安装,是否继续?")
|
|
115
|
+
if not click.confirm("继续将覆盖现有配置"):
|
|
116
|
+
return
|
|
117
|
+
|
|
118
|
+
# 创建配置目录
|
|
119
|
+
config_dir = Path.home() / ".selfclaw"
|
|
120
|
+
config_dir.mkdir(exist_ok=True)
|
|
121
|
+
|
|
122
|
+
# 创建示例配置
|
|
123
|
+
config_file = config_dir / "config.yaml"
|
|
124
|
+
if not config_file.exists():
|
|
125
|
+
create_default_config(config_file)
|
|
126
|
+
|
|
127
|
+
# 创建数据库配置
|
|
128
|
+
echo_info("\n配置数据库:")
|
|
129
|
+
db_host = click.prompt("数据库主机", default="localhost")
|
|
130
|
+
db_user = click.prompt("数据库用户", default="root")
|
|
131
|
+
db_password = click.prompt("数据库密码", default="", hide_input=True)
|
|
132
|
+
db_name = click.prompt("数据库名称", default="selfclaw")
|
|
133
|
+
|
|
134
|
+
# 更新配置
|
|
135
|
+
update_config(config_file, {
|
|
136
|
+
"db_host": db_host,
|
|
137
|
+
"db_user": db_user,
|
|
138
|
+
"db_password": db_password,
|
|
139
|
+
"db_name": db_name
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
# 配置API密钥
|
|
143
|
+
echo_info("\n配置GLM API:")
|
|
144
|
+
api_key = click.prompt("GLM API密钥", hide_input=True)
|
|
145
|
+
update_config(config_file, {"glm_api_key": api_key})
|
|
146
|
+
|
|
147
|
+
echo_success(f"配置已保存到: {config_file}")
|
|
148
|
+
echo_info("现在可以运行: selfclaw start")
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
@cli.command()
|
|
152
|
+
@click.option('--api-key', help='设置GLM API密钥')
|
|
153
|
+
@click.option('--db-host', help='数据库主机')
|
|
154
|
+
@click.option('--db-user', help='数据库用户')
|
|
155
|
+
@click.option('--db-password', help='数据库密码')
|
|
156
|
+
@click.option('--db-name', help='数据库名称')
|
|
157
|
+
def config(api_key, db_host, db_user, db_password, db_name):
|
|
158
|
+
"""
|
|
159
|
+
配置Selfclaw
|
|
160
|
+
"""
|
|
161
|
+
config_file = Path.home() / ".selfclaw" / "config.yaml"
|
|
162
|
+
|
|
163
|
+
if not config_file.exists():
|
|
164
|
+
echo_error("配置文件不存在,请先运行: selfclaw init")
|
|
165
|
+
sys.exit(1)
|
|
166
|
+
|
|
167
|
+
updates = {}
|
|
168
|
+
if api_key:
|
|
169
|
+
updates["glm_api_key"] = api_key
|
|
170
|
+
if db_host:
|
|
171
|
+
updates["db_host"] = db_host
|
|
172
|
+
if db_user:
|
|
173
|
+
updates["db_user"] = db_user
|
|
174
|
+
if db_password:
|
|
175
|
+
updates["db_password"] = db_password
|
|
176
|
+
if db_name:
|
|
177
|
+
updates["db_name"] = db_name
|
|
178
|
+
|
|
179
|
+
if updates:
|
|
180
|
+
update_config(config_file, updates)
|
|
181
|
+
echo_success("配置已更新")
|
|
182
|
+
else:
|
|
183
|
+
# 显示当前配置
|
|
184
|
+
show_config(config_file)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@cli.command()
|
|
188
|
+
@click.option('--all', is_flag=True, help='清理所有数据')
|
|
189
|
+
@click.option('--history', is_flag=True, help='清理历史记录')
|
|
190
|
+
@click.option('--cache', is_flag=True, help='清理缓存')
|
|
191
|
+
def clean(all, history, cache):
|
|
192
|
+
"""
|
|
193
|
+
清理数据
|
|
194
|
+
"""
|
|
195
|
+
if all:
|
|
196
|
+
echo_warning("将清理所有数据,是否继续?")
|
|
197
|
+
if not click.confirm("确定要清理所有数据吗?"):
|
|
198
|
+
return
|
|
199
|
+
|
|
200
|
+
# 清理数据库
|
|
201
|
+
backend_dir = get_installation_path("backend")
|
|
202
|
+
if backend_dir:
|
|
203
|
+
db_clean_script = backend_dir / "clean_database.py"
|
|
204
|
+
if db_clean_script.exists():
|
|
205
|
+
subprocess.run([sys.executable, str(db_clean_script)])
|
|
206
|
+
echo_success("数据库已清理")
|
|
207
|
+
|
|
208
|
+
elif history:
|
|
209
|
+
echo_info("清理历史记录...")
|
|
210
|
+
# 实现历史记录清理
|
|
211
|
+
echo_success("历史记录已清理")
|
|
212
|
+
|
|
213
|
+
elif cache:
|
|
214
|
+
echo_info("清理缓存...")
|
|
215
|
+
# 实现缓存清理
|
|
216
|
+
echo_success("缓存已清理")
|
|
217
|
+
|
|
218
|
+
else:
|
|
219
|
+
echo_info("清理临时文件...")
|
|
220
|
+
# 实现临时文件清理
|
|
221
|
+
echo_success("临时文件已清理")
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
@cli.command()
|
|
225
|
+
@click.option('--tail', default=50, help='显示最后N行', type=int)
|
|
226
|
+
@click.option('--follow', is_flag=True, help='持续跟踪日志')
|
|
227
|
+
@click.option('--level', help='日志级别 (debug/info/warning/error)')
|
|
228
|
+
def logs(tail, follow, level):
|
|
229
|
+
"""
|
|
230
|
+
查看日志
|
|
231
|
+
"""
|
|
232
|
+
log_file = Path.home() / ".selfclaw" / "logs" / "selfclaw.log"
|
|
233
|
+
|
|
234
|
+
if not log_file.exists():
|
|
235
|
+
echo_warning("日志文件不存在")
|
|
236
|
+
return
|
|
237
|
+
|
|
238
|
+
echo_info(f"显示日志: {log_file}")
|
|
239
|
+
|
|
240
|
+
if follow:
|
|
241
|
+
subprocess.run(["tail", "-f", str(log_file)])
|
|
242
|
+
else:
|
|
243
|
+
subprocess.run(["tail", "-n", str(tail), str(log_file)])
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
# 辅助函数
|
|
247
|
+
def check_installation():
|
|
248
|
+
"""检查是否已正确安装"""
|
|
249
|
+
backend_dir = get_installation_path("backend")
|
|
250
|
+
return backend_dir is not None and backend_dir.exists()
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def get_installation_path(component):
|
|
254
|
+
"""获取安装路径"""
|
|
255
|
+
# 首先检查包安装目录
|
|
256
|
+
try:
|
|
257
|
+
import selfclaw
|
|
258
|
+
package_dir = Path(selfclaw.__file__).parent
|
|
259
|
+
component_dir = package_dir.parent / component
|
|
260
|
+
if component_dir.exists():
|
|
261
|
+
return component_dir
|
|
262
|
+
except ImportError:
|
|
263
|
+
pass
|
|
264
|
+
|
|
265
|
+
# 检查当前目录
|
|
266
|
+
current_dir = Path.cwd()
|
|
267
|
+
component_dir = current_dir / component
|
|
268
|
+
if component_dir.exists():
|
|
269
|
+
return component_dir
|
|
270
|
+
|
|
271
|
+
return None
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def start_backend(backend_dir, port, debug, config):
|
|
275
|
+
"""启动后端服务"""
|
|
276
|
+
echo_info("启动后端服务...")
|
|
277
|
+
|
|
278
|
+
requirements_file = backend_dir / "requirements.txt"
|
|
279
|
+
main_file = backend_dir / "main.py"
|
|
280
|
+
|
|
281
|
+
if not requirements_file.exists():
|
|
282
|
+
echo_error(f"requirements.txt不存在: {requirements_file}")
|
|
283
|
+
return
|
|
284
|
+
|
|
285
|
+
if not main_file.exists():
|
|
286
|
+
echo_error(f"main.py不存在: {main_file}")
|
|
287
|
+
return
|
|
288
|
+
|
|
289
|
+
# 安装依赖(如果需要)
|
|
290
|
+
install_requirements(requirements_file)
|
|
291
|
+
|
|
292
|
+
# 启动后端
|
|
293
|
+
cmd = [sys.executable, str(main_file)]
|
|
294
|
+
if debug:
|
|
295
|
+
cmd.append("--debug")
|
|
296
|
+
|
|
297
|
+
try:
|
|
298
|
+
process = subprocess.Popen(cmd, cwd=backend_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
299
|
+
echo_success(f"后端服务已启动 (PID: {process.pid})")
|
|
300
|
+
except Exception as e:
|
|
301
|
+
echo_error(f"启动后端失败: {e}")
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def start_frontend(frontend_dir):
|
|
305
|
+
"""启动前端服务"""
|
|
306
|
+
echo_info("启动前端服务...")
|
|
307
|
+
|
|
308
|
+
if not shutil.which("npm"):
|
|
309
|
+
echo_error("npm未安装,请先安装Node.js和npm")
|
|
310
|
+
return
|
|
311
|
+
|
|
312
|
+
try:
|
|
313
|
+
# 先安装依赖
|
|
314
|
+
subprocess.run(["npm", "install"], cwd=frontend_dir, check=True)
|
|
315
|
+
# 启动开发服务器
|
|
316
|
+
process = subprocess.Popen(["npm", "run", "dev"], cwd=frontend_dir)
|
|
317
|
+
echo_success(f"前端服务已启动 (PID: {process.pid})")
|
|
318
|
+
except Exception as e:
|
|
319
|
+
echo_error(f"启动前端失败: {e}")
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def kill_process(name):
|
|
323
|
+
"""杀死进程"""
|
|
324
|
+
try:
|
|
325
|
+
if sys.platform == "darwin":
|
|
326
|
+
subprocess.run(["pkill", "-f", name], check=False)
|
|
327
|
+
else:
|
|
328
|
+
subprocess.run(["taskkill", "/F", "/IM", f"{name}.exe"], check=False)
|
|
329
|
+
except Exception:
|
|
330
|
+
pass
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def check_process(name):
|
|
334
|
+
"""检查进程是否运行"""
|
|
335
|
+
try:
|
|
336
|
+
if sys.platform == "darwin":
|
|
337
|
+
result = subprocess.run(["pgrep", "-f", name], capture_output=True)
|
|
338
|
+
return result.returncode == 0
|
|
339
|
+
else:
|
|
340
|
+
result = subprocess.run(["tasklist", "/FI", f"IMAGENAME eq {name}.exe"], capture_output=True)
|
|
341
|
+
return name.lower() in str(result.stdout).lower()
|
|
342
|
+
except Exception:
|
|
343
|
+
return False
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def install_requirements(requirements_file):
|
|
347
|
+
"""安装Python依赖"""
|
|
348
|
+
try:
|
|
349
|
+
subprocess.run([sys.executable, "-m", "pip", "install", "-r", str(requirements_file)],
|
|
350
|
+
check=True, capture_output=True)
|
|
351
|
+
except subprocess.CalledProcessError:
|
|
352
|
+
echo_warning("依赖安装可能失败,但不影响运行")
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def create_default_config(config_file):
|
|
356
|
+
"""创建默认配置"""
|
|
357
|
+
default_config = {
|
|
358
|
+
"port": 8000,
|
|
359
|
+
"debug": False,
|
|
360
|
+
"db_host": "localhost",
|
|
361
|
+
"db_port": 3306,
|
|
362
|
+
"db_user": "root",
|
|
363
|
+
"db_password": "",
|
|
364
|
+
"db_name": "selfclaw",
|
|
365
|
+
"glm_api_key": "",
|
|
366
|
+
"glm_model": "glm-5",
|
|
367
|
+
"max_concurrent_commands": 2,
|
|
368
|
+
"command_timeout": 30,
|
|
369
|
+
"max_output_size": 10000,
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
import yaml
|
|
373
|
+
with open(config_file, "w", encoding="utf-8") as f:
|
|
374
|
+
yaml.dump(default_config, f, default_flow_style=False, allow_unicode=True)
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def update_config(config_file, updates):
|
|
378
|
+
"""更新配置"""
|
|
379
|
+
try:
|
|
380
|
+
import yaml
|
|
381
|
+
with open(config_file, "r", encoding="utf-8") as f:
|
|
382
|
+
config = yaml.safe_load(f) or {}
|
|
383
|
+
|
|
384
|
+
config.update(updates)
|
|
385
|
+
|
|
386
|
+
with open(config_file, "w", encoding="utf-8") as f:
|
|
387
|
+
yaml.dump(config, f, default_flow_style=False, allow_unicode=True)
|
|
388
|
+
except Exception as e:
|
|
389
|
+
echo_error(f"更新配置失败: {e}")
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def show_config(config_file):
|
|
393
|
+
"""显示当前配置"""
|
|
394
|
+
try:
|
|
395
|
+
import yaml
|
|
396
|
+
with open(config_file, "r", encoding="utf-8") as f:
|
|
397
|
+
config = yaml.safe_load(f) or {}
|
|
398
|
+
|
|
399
|
+
echo_info("当前配置:")
|
|
400
|
+
for key, value in config.items():
|
|
401
|
+
if "password" in key.lower() or "key" in key.lower() and value:
|
|
402
|
+
# 隐藏敏感信息
|
|
403
|
+
click.echo(f" {key}: ********")
|
|
404
|
+
else:
|
|
405
|
+
click.echo(f" {key}: {value}")
|
|
406
|
+
except Exception as e:
|
|
407
|
+
echo_error(f"读取配置失败: {e}")
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def main():
|
|
411
|
+
"""主函数"""
|
|
412
|
+
cli()
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
if __name__ == "__main__":
|
|
416
|
+
main()
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: selfclaw
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Selfclaw - AI Agent System based on GLM-5
|
|
5
|
+
Home-page: https://github.com/raychiu0202/selfclaw
|
|
6
|
+
Author: raychiu0202
|
|
7
|
+
Author-email: raychiu0202 <your-email@example.com>
|
|
8
|
+
Maintainer: raychiu0202
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Bug Reports, https://github.com/raychiu0202/selfclaw/issues
|
|
11
|
+
Project-URL: Source, https://github.com/raychiu0202/selfclaw
|
|
12
|
+
Project-URL: Documentation, https://github.com/raychiu0202/selfclaw/docs
|
|
13
|
+
Keywords: ai,agent,chatbot,llm,glm,terminal,automation
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: fastapi>=0.104.0
|
|
29
|
+
Requires-Dist: uvicorn[standard]>=0.24.0
|
|
30
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
|
31
|
+
Requires-Dist: pymysql>=1.1.0
|
|
32
|
+
Requires-Dist: cryptography>=41.0.0
|
|
33
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
34
|
+
Requires-Dist: zhipuai>=2.0.0
|
|
35
|
+
Requires-Dist: click>=8.1.0
|
|
36
|
+
Requires-Dist: pyyaml>=6.0
|
|
37
|
+
Provides-Extra: dev
|
|
38
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
41
|
+
Dynamic: author
|
|
42
|
+
Dynamic: home-page
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
Dynamic: requires-python
|
|
45
|
+
|
|
46
|
+
# Selfclaw Package
|
|
47
|
+
|
|
48
|
+
基于GLM-5的智能AI助手系统 - 发布包
|
|
49
|
+
|
|
50
|
+
## 安装
|
|
51
|
+
|
|
52
|
+
### NPM安装
|
|
53
|
+
```bash
|
|
54
|
+
npm install -g selfclaw
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### pip安装
|
|
58
|
+
```bash
|
|
59
|
+
pip install selfclaw
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 快速开始
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# 初始化配置
|
|
66
|
+
selfclaw init
|
|
67
|
+
|
|
68
|
+
# 启动服务
|
|
69
|
+
selfclaw start
|
|
70
|
+
|
|
71
|
+
# 查看服务状态
|
|
72
|
+
selfclaw status
|
|
73
|
+
|
|
74
|
+
# 停止服务
|
|
75
|
+
selfclaw stop
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 命令参考
|
|
79
|
+
|
|
80
|
+
- `selfclaw init` - 初始化配置
|
|
81
|
+
- `selfclaw start` - 启动服务
|
|
82
|
+
- `selfclaw stop` - 停止服务
|
|
83
|
+
- `selfclaw status` - 查看服务状态
|
|
84
|
+
- `selfclaw config` - 配置设置
|
|
85
|
+
- `selfclaw clean` - 清理数据
|
|
86
|
+
- `selfclaw logs` - 查看日志
|
|
87
|
+
|
|
88
|
+
## 开发信息
|
|
89
|
+
|
|
90
|
+
- 包名: selfclaw
|
|
91
|
+
- 版本: 1.0.0
|
|
92
|
+
- 作者: raychiu0202
|
|
93
|
+
- 许可证: MIT
|
|
94
|
+
|
|
95
|
+
## 链接
|
|
96
|
+
|
|
97
|
+
- GitHub: https://github.com/raychiu0202/selfclaw
|
|
98
|
+
- 文档: https://github.com/raychiu0202/selfclaw/docs
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
requirements.txt
|
|
6
|
+
setup.py
|
|
7
|
+
selfclaw/__init__.py
|
|
8
|
+
selfclaw/cli.py
|
|
9
|
+
selfclaw.egg-info/PKG-INFO
|
|
10
|
+
selfclaw.egg-info/SOURCES.txt
|
|
11
|
+
selfclaw.egg-info/dependency_links.txt
|
|
12
|
+
selfclaw.egg-info/entry_points.txt
|
|
13
|
+
selfclaw.egg-info/requires.txt
|
|
14
|
+
selfclaw.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
selfclaw
|
selfclaw-1.0.0/setup.cfg
ADDED
selfclaw-1.0.0/setup.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Selfclaw - AI Agent System
|
|
3
|
+
极简设计的AI智能助手系统
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from setuptools import setup, find_packages
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
# 读取README文件
|
|
10
|
+
def read_file(filename):
|
|
11
|
+
with open(os.path.join(os.path.dirname(__file__), filename), encoding='utf-8') as f:
|
|
12
|
+
return f.read()
|
|
13
|
+
|
|
14
|
+
setup(
|
|
15
|
+
name="selfclaw",
|
|
16
|
+
version="1.0.0",
|
|
17
|
+
description="Selfclaw - AI Agent System based on GLM-5",
|
|
18
|
+
long_description=read_file("README.md"),
|
|
19
|
+
long_description_content_type="text/markdown",
|
|
20
|
+
author="raychiu0202",
|
|
21
|
+
author_email="your-email@example.com",
|
|
22
|
+
url="https://github.com/raychiu0202/selfclaw",
|
|
23
|
+
license="MIT",
|
|
24
|
+
|
|
25
|
+
# 包含的包
|
|
26
|
+
packages=find_packages(include=["selfclaw*"]),
|
|
27
|
+
python_requires=">=3.8",
|
|
28
|
+
|
|
29
|
+
# 依赖包 - 精简到最小
|
|
30
|
+
install_requires=[
|
|
31
|
+
"fastapi>=0.104.0",
|
|
32
|
+
"uvicorn[standard]>=0.24.0",
|
|
33
|
+
"sqlalchemy>=2.0.0",
|
|
34
|
+
"pymysql>=1.1.0",
|
|
35
|
+
"cryptography>=41.0.0",
|
|
36
|
+
"python-dotenv>=1.0.0",
|
|
37
|
+
"zhipuai>=2.0.0",
|
|
38
|
+
"click>=8.1.0", # CLI框架
|
|
39
|
+
],
|
|
40
|
+
|
|
41
|
+
# CLI入口点
|
|
42
|
+
entry_points={
|
|
43
|
+
"console_scripts": [
|
|
44
|
+
"selfclaw=selfclaw.cli:main",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
# 包数据
|
|
49
|
+
package_data={
|
|
50
|
+
"selfclaw": ["*.yaml", "*.yml", "*.json", "*.txt"],
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
# 分类信息
|
|
54
|
+
classifiers=[
|
|
55
|
+
"Development Status :: 4 - Beta",
|
|
56
|
+
"Intended Audience :: Developers",
|
|
57
|
+
"License :: OSI Approved :: MIT License",
|
|
58
|
+
"Programming Language :: Python :: 3",
|
|
59
|
+
"Programming Language :: Python :: 3.8",
|
|
60
|
+
"Programming Language :: Python :: 3.9",
|
|
61
|
+
"Programming Language :: Python :: 3.10",
|
|
62
|
+
"Programming Language :: Python :: 3.11",
|
|
63
|
+
"Programming Language :: Python :: 3.12",
|
|
64
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
65
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
66
|
+
],
|
|
67
|
+
|
|
68
|
+
# 关键词
|
|
69
|
+
keywords="ai agent chatbot llm glm-5 terminal automation",
|
|
70
|
+
|
|
71
|
+
# 项目URL
|
|
72
|
+
project_urls={
|
|
73
|
+
"Bug Reports": "https://github.com/raychiu0202/selfclaw/issues",
|
|
74
|
+
"Source": "https://github.com/raychiu0202/selfclaw",
|
|
75
|
+
"Documentation": "https://github.com/raychiu0202/selfclaw/docs",
|
|
76
|
+
},
|
|
77
|
+
)
|