txcode-sdk 0.1.0__tar.gz → 0.2.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.
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/PKG-INFO +66 -58
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/README.md +7 -3
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/pyproject.toml +17 -11
- txcode_sdk-0.2.0/setup.cfg +4 -0
- txcode_sdk-0.2.0/setup.py +34 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/example/code_example.py +2 -2
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/example/code_session.py +1 -1
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/example/code_tool.py +1 -1
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/example/constants.py +1 -1
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/example/query_session.py +4 -2
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/__init__.py +17 -1
- txcode_sdk-0.2.0/src/txcode_sdk/_compat/__init__.py +5 -0
- txcode_sdk-0.2.0/src/txcode_sdk/_compat/dataclasses.py +121 -0
- txcode_sdk-0.2.0/src/txcode_sdk/_compat/resources.py +19 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/__init__.py +33 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/base_agent.py +31 -28
- txcode_sdk-0.2.0/src/txcode_sdk/agent/chat/agent_tool.py +5 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/chat/chat_agent.py +4 -2
- txcode_sdk-0.2.0/src/txcode_sdk/agent/chat/prompts/__init__.py +1 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/code/code_agent.py +4 -2
- txcode_sdk-0.2.0/src/txcode_sdk/agent/code/prompts/__init__.py +1 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/common/common_agent.py +5 -1
- txcode_sdk-0.2.0/src/txcode_sdk/agent/common/prompt/__init__.py +0 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/design/__init__.py +4 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/design/agent_tool.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/design/design_agent.py +28 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/design/prompts/__init__.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/design/prompts/role.txt +36 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/discuss/__init__.py +4 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/discuss/agent_tool.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/discuss/discuss_agent.py +28 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/discuss/prompts/__init__.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/discuss/prompts/role.txt +28 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/dream/__init__.py +4 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/dream/agent_tool.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/dream/dream_agent.py +28 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/dream/prompts/__init__.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/dream/prompts/role.txt +21 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/mem/mem_agent.py +8 -8
- txcode_sdk-0.2.0/src/txcode_sdk/agent/mem/prompts/__init__.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/name/__init__.py +3 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/name/name_agent.py +55 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/name/prompts/__init__.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/name/prompts/role.txt +8 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/plan/__init__.py +4 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/plan/agent_tool.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/plan/plan_agent.py +30 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/plan/prompts/__init__.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/plan/prompts/role.txt +47 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/shell/__init__.py +4 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/shell/agent_tool.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/shell/prompts/__init__.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/shell/prompts/role.txt +29 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/shell/shell_agent.py +28 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/skill/__init__.py +4 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/skill/agent_tool.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/skill/prompts/__init__.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/skill/prompts/role.txt +62 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/skill/skill_agent.py +80 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/summarizer/prompts/__init__.py +1 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/summarizer/summarizer_agent.py +7 -7
- txcode_sdk-0.2.0/src/txcode_sdk/agent/task/prompts/__init__.py +1 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/task/task_agent.py +4 -2
- txcode_sdk-0.2.0/src/txcode_sdk/agent/test/__init__.py +4 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/test/agent_tool.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/test/prompts/__init__.py +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/test/prompts/role.txt +21 -0
- txcode_sdk-0.2.0/src/txcode_sdk/agent/test/test_agent.py +32 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/tool_registry.py +21 -16
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/client.py +122 -17
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/compact/compressor.py +6 -5
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/hooks/__init__.py +1 -1
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/hooks/handlers/base.py +3 -2
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/hooks/handlers/memory.py +1 -1
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/hooks/processor.py +4 -3
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/hooks/queue.py +5 -5
- txcode_sdk-0.2.0/src/txcode_sdk/hooks/types.py +12 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/provider/base.py +8 -8
- txcode_sdk-0.2.0/src/txcode_sdk/provider/deepseek_provider.py +13 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/provider/openai_provider.py +52 -40
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/provider/router.py +1 -1
- txcode_sdk-0.2.0/src/txcode_sdk/provider/txcode_ai.py +200 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/session/manager.py +16 -15
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/skills/__init__.py +9 -5
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/specs/__init__.py +24 -14
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/bash_tool.py +3 -3
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/edit_file.py +12 -11
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/glob_tool.py +5 -4
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/grep_tool.py +5 -4
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/memory_tool.py +1 -1
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/read_file.py +6 -5
- txcode_sdk-0.2.0/src/txcode_sdk/tools/todo_read.py +40 -0
- txcode_sdk-0.2.0/src/txcode_sdk/tools/todo_read.txt +15 -0
- txcode_sdk-0.2.0/src/txcode_sdk/tools/todo_write.py +66 -0
- txcode_sdk-0.2.0/src/txcode_sdk/tools/todo_write.txt +47 -0
- txcode_sdk-0.2.0/src/txcode_sdk/tools/web_shell_exec.py +77 -0
- txcode_sdk-0.2.0/src/txcode_sdk/tools/web_shell_exec.txt +14 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/write_file.py +3 -3
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/types.py +33 -30
- txcode_sdk-0.2.0/src/txcode_sdk.egg-info/PKG-INFO +66 -0
- txcode_sdk-0.2.0/src/txcode_sdk.egg-info/SOURCES.txt +143 -0
- txcode_sdk-0.2.0/src/txcode_sdk.egg-info/dependency_links.txt +1 -0
- txcode_sdk-0.2.0/src/txcode_sdk.egg-info/top_level.txt +2 -0
- txcode_sdk-0.2.0/tests/test_compat.py +149 -0
- txcode_sdk-0.2.0/tests/test_design_agent.py +47 -0
- txcode_sdk-0.2.0/tests/test_discuss_agent.py +35 -0
- txcode_sdk-0.2.0/tests/test_dream_agent.py +35 -0
- txcode_sdk-0.2.0/tests/test_name_agent.py +56 -0
- txcode_sdk-0.2.0/tests/test_plan_agent.py +54 -0
- txcode_sdk-0.2.0/tests/test_shell_agent.py +62 -0
- txcode_sdk-0.2.0/tests/test_skill_agent.py +70 -0
- txcode_sdk-0.2.0/tests/test_test_agent.py +126 -0
- txcode_sdk-0.2.0/tests/test_txcode_ai.py +208 -0
- txcode_sdk-0.1.0/.gitignore +0 -27
- txcode_sdk-0.1.0/docs/api/agent.html +0 -84
- txcode_sdk-0.1.0/docs/api/client.html +0 -147
- txcode_sdk-0.1.0/docs/api/session.html +0 -126
- txcode_sdk-0.1.0/docs/api/tools.html +0 -139
- txcode_sdk-0.1.0/docs/assets/style.css +0 -198
- txcode_sdk-0.1.0/docs/example/hello-world.html +0 -104
- txcode_sdk-0.1.0/docs/example/tool-calling.html +0 -158
- txcode_sdk-0.1.0/docs/guide/configuration.html +0 -118
- txcode_sdk-0.1.0/docs/guide/installation.html +0 -98
- txcode_sdk-0.1.0/docs/guide/quickstart.html +0 -99
- txcode_sdk-0.1.0/docs/index.html +0 -92
- txcode_sdk-0.1.0/src/example/README.md +0 -27
- txcode_sdk-0.1.0/src/txcode_sdk/agent/__init__.py +0 -17
- txcode_sdk-0.1.0/src/txcode_sdk/agent/chat/agent_tool.py +0 -1
- txcode_sdk-0.1.0/src/txcode_sdk/hooks/types.py +0 -10
- txcode_sdk-0.1.0/src/txcode_sdk/provider/deepseek_provider.py +0 -60
- txcode_sdk-0.1.0/tests/__init__.py +0 -1
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/LICENSE +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/example/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/chat/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/chat/prompts/role.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/code/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/code/agent_tool.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/code/prompts/role.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/common/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/common/prompt/role.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/mem/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/mem/agent_tool.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/mem/prompts/role.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/summarizer/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/summarizer/prompts/role.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/task/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/task/agent_tool.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/agent/task/prompts/role.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/compact/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/hooks/handlers/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/provider/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/session/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/__init__.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/bash.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/edit_file.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/glob.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/grep.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/read_file.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/src/txcode_sdk/tools/write_file.txt +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/tests/test_client.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/tests/test_session.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/tests/test_session_query.py +0 -0
- {txcode_sdk-0.1.0 → txcode_sdk-0.2.0}/tests/test_tools.py +0 -0
|
@@ -1,58 +1,66 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: txcode-sdk
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: AI Agent SDK with built-in tools for Python projects
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Classifier:
|
|
11
|
-
Classifier:
|
|
12
|
-
Classifier:
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: txcode-sdk
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: AI Agent SDK with built-in tools for Python projects
|
|
5
|
+
Author: homecommunity
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/homecommunity/txcode-sdk
|
|
8
|
+
Keywords: ai,agent,openai,tools,react
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Requires-Python: >=3.6
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
Dynamic: requires-python
|
|
25
|
+
|
|
26
|
+
# txcode-sdk
|
|
27
|
+
|
|
28
|
+
AI Agent SDK with built-in tools for Python projects.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
- 要求:**Python >= 3.6**(含 3.6/3.7/3.8/3.9/3.10/3.11/3.12)
|
|
33
|
+
- **零第三方运行时依赖**(仅标准库,适合门禁设备等离线环境)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install txcode-sdk
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import asyncio
|
|
43
|
+
from txcode_sdk import TxCodeClient
|
|
44
|
+
|
|
45
|
+
async def main():
|
|
46
|
+
client = TxCodeClient(
|
|
47
|
+
api_key="sk-xxx",
|
|
48
|
+
base_url="https://api.openai.com/v1",
|
|
49
|
+
model="gpt-4",
|
|
50
|
+
)
|
|
51
|
+
result = await client.chat("Hello!")
|
|
52
|
+
print(result.answer)
|
|
53
|
+
|
|
54
|
+
asyncio.get_event_loop().run_until_complete(main())
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Features
|
|
58
|
+
|
|
59
|
+
- ReAct Agent loop with tool calling
|
|
60
|
+
- Multiple agent types: code, chat, common, task, plan, shell, skill, test, design, discuss, dream, name
|
|
61
|
+
- 10 built-in tools: read_file, write_file, edit_file, glob, grep, bash, memory, web_shell_exec, todo_read, todo_write
|
|
62
|
+
- Session management with JSON file persistence
|
|
63
|
+
- Context compression for long conversations
|
|
64
|
+
- Multimodal input support (images)
|
|
65
|
+
- Extensible custom tools
|
|
66
|
+
- Self-developed HTTP client (urllib, no openai/tiktoken dependency), supports OpenAI / DeepSeek / any OpenAI-compatible API
|
|
@@ -4,6 +4,9 @@ AI Agent SDK with built-in tools for Python projects.
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
+
- 要求:**Python >= 3.6**(含 3.6/3.7/3.8/3.9/3.10/3.11/3.12)
|
|
8
|
+
- **零第三方运行时依赖**(仅标准库,适合门禁设备等离线环境)
|
|
9
|
+
|
|
7
10
|
```bash
|
|
8
11
|
pip install txcode-sdk
|
|
9
12
|
```
|
|
@@ -23,15 +26,16 @@ async def main():
|
|
|
23
26
|
result = await client.chat("Hello!")
|
|
24
27
|
print(result.answer)
|
|
25
28
|
|
|
26
|
-
asyncio.
|
|
29
|
+
asyncio.get_event_loop().run_until_complete(main())
|
|
27
30
|
```
|
|
28
31
|
|
|
29
32
|
## Features
|
|
30
33
|
|
|
31
34
|
- ReAct Agent loop with tool calling
|
|
32
|
-
- Multiple agent types: code, chat, common, task
|
|
33
|
-
-
|
|
35
|
+
- Multiple agent types: code, chat, common, task, plan, shell, skill, test, design, discuss, dream, name
|
|
36
|
+
- 10 built-in tools: read_file, write_file, edit_file, glob, grep, bash, memory, web_shell_exec, todo_read, todo_write
|
|
34
37
|
- Session management with JSON file persistence
|
|
35
38
|
- Context compression for long conversations
|
|
36
39
|
- Multimodal input support (images)
|
|
37
40
|
- Extensible custom tools
|
|
41
|
+
- Self-developed HTTP client (urllib, no openai/tiktoken dependency), supports OpenAI / DeepSeek / any OpenAI-compatible API
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["
|
|
3
|
-
build-backend = "
|
|
2
|
+
requires = ["setuptools>=40.8.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "txcode-sdk"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.0"
|
|
8
8
|
description = "AI Agent SDK with built-in tools for Python projects"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
11
|
-
requires-python = ">=3.
|
|
11
|
+
requires-python = ">=3.6"
|
|
12
12
|
authors = [
|
|
13
13
|
{ name = "homecommunity" }
|
|
14
14
|
]
|
|
@@ -18,18 +18,24 @@ classifiers = [
|
|
|
18
18
|
"Intended Audience :: Developers",
|
|
19
19
|
"License :: OSI Approved :: MIT License",
|
|
20
20
|
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.6",
|
|
22
|
+
"Programming Language :: Python :: 3.7",
|
|
23
|
+
"Programming Language :: Python :: 3.8",
|
|
24
|
+
"Programming Language :: Python :: 3.9",
|
|
21
25
|
"Programming Language :: Python :: 3.10",
|
|
22
26
|
"Programming Language :: Python :: 3.11",
|
|
23
27
|
"Programming Language :: Python :: 3.12",
|
|
24
28
|
]
|
|
25
|
-
dependencies = [
|
|
26
|
-
"openai>=1.0.0",
|
|
27
|
-
"tiktoken>=0.5.0",
|
|
28
|
-
]
|
|
29
|
+
dependencies = []
|
|
29
30
|
|
|
30
31
|
[project.urls]
|
|
31
32
|
Repository = "https://github.com/homecommunity/txcode-sdk"
|
|
32
33
|
|
|
33
|
-
[tool.
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
testpaths = ["tests"]
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.packages.find]
|
|
38
|
+
where = ["src"]
|
|
39
|
+
|
|
40
|
+
[tool.setuptools.package-data]
|
|
41
|
+
txcode_sdk = ["**/*.txt"]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""setuptools 传统入口(兼容老版本 pip 离线安装,Python 3.6)。
|
|
2
|
+
|
|
3
|
+
pyproject.toml 中的 [tool.setuptools] 配置与 setup.cfg 等价;
|
|
4
|
+
此文件仅为老版本 pip(不支持 PEP 517)提供回退入口。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from setuptools import find_packages, setup
|
|
8
|
+
|
|
9
|
+
setup(
|
|
10
|
+
name="txcode-sdk",
|
|
11
|
+
version="0.2.0",
|
|
12
|
+
description="AI Agent SDK with built-in tools for Python projects",
|
|
13
|
+
long_description=open("README.md", encoding="utf-8").read(),
|
|
14
|
+
long_description_content_type="text/markdown",
|
|
15
|
+
license="MIT",
|
|
16
|
+
python_requires=">=3.6",
|
|
17
|
+
packages=find_packages("src"),
|
|
18
|
+
package_dir={"": "src"},
|
|
19
|
+
package_data={"txcode_sdk": ["**/*.txt"]},
|
|
20
|
+
install_requires=[],
|
|
21
|
+
classifiers=[
|
|
22
|
+
"Development Status :: 3 - Alpha",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"License :: OSI Approved :: MIT License",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Programming Language :: Python :: 3.6",
|
|
27
|
+
"Programming Language :: Python :: 3.7",
|
|
28
|
+
"Programming Language :: Python :: 3.8",
|
|
29
|
+
"Programming Language :: Python :: 3.9",
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
32
|
+
"Programming Language :: Python :: 3.12",
|
|
33
|
+
],
|
|
34
|
+
)
|
|
@@ -38,7 +38,7 @@ async def _verify_last_message(client: TxCodeClient, session_id: str):
|
|
|
38
38
|
print(f"\nTotal messages in session: {len(messages)}")
|
|
39
39
|
|
|
40
40
|
ai_messages = [m for m in messages if m.get("role") in ("assistant", "tool")]
|
|
41
|
-
errors: list
|
|
41
|
+
errors: list = []
|
|
42
42
|
|
|
43
43
|
for i, msg in enumerate(ai_messages):
|
|
44
44
|
role = msg.get("role", "")
|
|
@@ -93,4 +93,4 @@ async def main():
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
if __name__ == "__main__":
|
|
96
|
-
asyncio.
|
|
96
|
+
asyncio.get_event_loop().run_until_complete(main())
|
|
@@ -29,7 +29,8 @@ def demo_get_session_messages(session_id: str):
|
|
|
29
29
|
try:
|
|
30
30
|
print(f" {pm}")
|
|
31
31
|
except UnicodeEncodeError:
|
|
32
|
-
|
|
32
|
+
safe_pm = pm.encode("ascii", errors="replace").decode("ascii")
|
|
33
|
+
print(f" {safe_pm}")
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
def demo_step_print():
|
|
@@ -54,7 +55,8 @@ def demo_step_print():
|
|
|
54
55
|
try:
|
|
55
56
|
print(msg)
|
|
56
57
|
except UnicodeEncodeError:
|
|
57
|
-
|
|
58
|
+
safe_msg = msg.encode("ascii", errors="replace").decode("ascii")
|
|
59
|
+
print(safe_msg)
|
|
58
60
|
|
|
59
61
|
|
|
60
62
|
if __name__ == "__main__":
|
|
@@ -20,6 +20,14 @@ from .types import (
|
|
|
20
20
|
ToolResultInfo,
|
|
21
21
|
)
|
|
22
22
|
from .agent.summarizer import SummarizerAgent, CompactCheck as SummarizerCompactCheck, CompactResult as SummarizerCompactResult
|
|
23
|
+
from .agent.design import DesignAgent
|
|
24
|
+
from .agent.discuss import DiscussionAgent
|
|
25
|
+
from .agent.dream import DreamAgent
|
|
26
|
+
from .agent.name import NameAgent
|
|
27
|
+
from .agent.plan import PlanAgent
|
|
28
|
+
from .agent.shell import ShellAgent
|
|
29
|
+
from .agent.skill import SkillAgent
|
|
30
|
+
from .agent.test import TestAgent
|
|
23
31
|
|
|
24
32
|
__all__ = [
|
|
25
33
|
"TxCodeClient",
|
|
@@ -44,6 +52,14 @@ __all__ = [
|
|
|
44
52
|
"SummarizerAgent",
|
|
45
53
|
"SummarizerCompactCheck",
|
|
46
54
|
"SummarizerCompactResult",
|
|
55
|
+
"DesignAgent",
|
|
56
|
+
"DiscussionAgent",
|
|
57
|
+
"DreamAgent",
|
|
58
|
+
"NameAgent",
|
|
59
|
+
"PlanAgent",
|
|
60
|
+
"ShellAgent",
|
|
61
|
+
"SkillAgent",
|
|
62
|
+
"TestAgent",
|
|
47
63
|
]
|
|
48
64
|
|
|
49
|
-
__version__ = "0.
|
|
65
|
+
__version__ = "0.2.0"
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""Python 3.6 兼容的 dataclasses 迷你实现。
|
|
2
|
+
|
|
3
|
+
仅实现本项目使用到的特性:
|
|
4
|
+
- ``@dataclass`` 装饰器(含 ``@dataclass()`` 括号形式)
|
|
5
|
+
- 字段默认值(``name: int = 0``)
|
|
6
|
+
- ``field(default=..., default_factory=...)``(hooks/types.py 的 metadata 用到)
|
|
7
|
+
- 自动生成 ``__init__`` / ``__repr__`` / ``__eq__``
|
|
8
|
+
|
|
9
|
+
不实现 frozen / slots / order / field 校验等高级特性。
|
|
10
|
+
自 Python 3.7 起标准库 dataclasses 存在,本模块仅在 3.6 环境被使用;
|
|
11
|
+
为保持行为一致,3.7+ 环境下可直接改用标准库。
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class _MISSING_TYPE(object):
|
|
16
|
+
def __repr__(self):
|
|
17
|
+
return "MISSING"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
MISSING = _MISSING_TYPE()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class _Field(object):
|
|
24
|
+
__slots__ = ("default", "default_factory")
|
|
25
|
+
|
|
26
|
+
def __init__(self, default=MISSING, default_factory=MISSING):
|
|
27
|
+
self.default = default
|
|
28
|
+
self.default_factory = default_factory
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def field(*, default=MISSING, default_factory=MISSING):
|
|
32
|
+
"""为 dataclass 字段提供默认值 / 默认工厂的声明。"""
|
|
33
|
+
if default is not MISSING and default_factory is not MISSING:
|
|
34
|
+
raise TypeError("cannot specify both default and default_factory")
|
|
35
|
+
return _Field(default=default, default_factory=default_factory)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def dataclass(cls=None, *, init=True, repr=True, eq=True):
|
|
39
|
+
"""类装饰器:根据类注解自动生成 __init__ / __repr__ / __eq__。"""
|
|
40
|
+
|
|
41
|
+
def wrap(target):
|
|
42
|
+
return _process_class(target, init=init, repr=repr, eq=eq)
|
|
43
|
+
|
|
44
|
+
if cls is None:
|
|
45
|
+
return wrap
|
|
46
|
+
return wrap(cls)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _collect_fields(cls):
|
|
50
|
+
"""按 __annotations__ 顺序收集 (name, default, default_factory)。"""
|
|
51
|
+
annotations = getattr(cls, "__annotations__", None) or {}
|
|
52
|
+
fields = []
|
|
53
|
+
for name in annotations:
|
|
54
|
+
raw = getattr(cls, name, MISSING)
|
|
55
|
+
if isinstance(raw, _Field):
|
|
56
|
+
default = raw.default
|
|
57
|
+
default_factory = raw.default_factory
|
|
58
|
+
elif raw is not MISSING:
|
|
59
|
+
default = raw
|
|
60
|
+
default_factory = MISSING
|
|
61
|
+
else:
|
|
62
|
+
default = MISSING
|
|
63
|
+
default_factory = MISSING
|
|
64
|
+
fields.append((name, default, default_factory))
|
|
65
|
+
return fields
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _make_init(fields):
|
|
69
|
+
args = []
|
|
70
|
+
for name, default, default_factory in fields:
|
|
71
|
+
if default is not MISSING:
|
|
72
|
+
args.append("%s=%r" % (name, default))
|
|
73
|
+
else:
|
|
74
|
+
args.append("%s=MISSING" % name)
|
|
75
|
+
lines = ["def __init__(self, %s):" % ", ".join(args)]
|
|
76
|
+
for name, default, default_factory in fields:
|
|
77
|
+
if default_factory is not MISSING:
|
|
78
|
+
lines.append(" if %s is MISSING:" % name)
|
|
79
|
+
lines.append(" %s = _factory_%s()" % (name, name))
|
|
80
|
+
lines.append(" self.%s = %s" % (name, name))
|
|
81
|
+
ns = {"MISSING": MISSING}
|
|
82
|
+
for name, default, default_factory in fields:
|
|
83
|
+
if default_factory is not MISSING:
|
|
84
|
+
ns["_factory_%s" % name] = default_factory
|
|
85
|
+
exec("\n".join(lines), ns)
|
|
86
|
+
return ns["__init__"]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _make_repr(cls, fields):
|
|
90
|
+
names = [name for name, _, _ in fields]
|
|
91
|
+
|
|
92
|
+
def __repr__(self):
|
|
93
|
+
parts = ", ".join("%s=%r" % (name, getattr(self, name)) for name in names)
|
|
94
|
+
return "%s(%s)" % (cls.__name__, parts)
|
|
95
|
+
|
|
96
|
+
return __repr__
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _make_eq(fields):
|
|
100
|
+
names = [name for name, _, _ in fields]
|
|
101
|
+
|
|
102
|
+
def __eq__(self, other):
|
|
103
|
+
if other.__class__ is not self.__class__:
|
|
104
|
+
return NotImplemented
|
|
105
|
+
for name in names:
|
|
106
|
+
if getattr(self, name) != getattr(other, name):
|
|
107
|
+
return False
|
|
108
|
+
return True
|
|
109
|
+
|
|
110
|
+
return __eq__
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _process_class(cls, init, repr, eq):
|
|
114
|
+
fields = _collect_fields(cls)
|
|
115
|
+
if init:
|
|
116
|
+
cls.__init__ = _make_init(fields)
|
|
117
|
+
if repr:
|
|
118
|
+
cls.__repr__ = _make_repr(cls, fields)
|
|
119
|
+
if eq:
|
|
120
|
+
cls.__eq__ = _make_eq(fields)
|
|
121
|
+
return cls
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""importlib.resources 的 Python 3.6 兼容封装(基于 pkgutil.get_data)。
|
|
2
|
+
|
|
3
|
+
``pkgutil.get_data`` 自 Python 3.x 一直可用,且支持 zip 导入(wheel / zip 安装场景),
|
|
4
|
+
替代 Python 3.9+ 的 ``importlib.resources.files(...).joinpath(...).read_text()``。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pkgutil
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_resource(package, filename):
|
|
11
|
+
"""读取包内文本资源并返回字符串(UTF-8 解码)。"""
|
|
12
|
+
data = pkgutil.get_data(package, filename)
|
|
13
|
+
if data is None:
|
|
14
|
+
raise FileNotFoundError(
|
|
15
|
+
"No resource %r found in package %r" % (filename, package)
|
|
16
|
+
)
|
|
17
|
+
if isinstance(data, bytes):
|
|
18
|
+
return data.decode("utf-8")
|
|
19
|
+
return data
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from .base_agent import BaseAgent
|
|
2
|
+
from .tool_registry import ToolRegistry, get_builtin_tools, get_builtin_tool_list
|
|
3
|
+
from .code.code_agent import CodeAgent
|
|
4
|
+
from .chat.chat_agent import ChatAgent
|
|
5
|
+
from .common.common_agent import CommonAgent
|
|
6
|
+
from .task.task_agent import TaskAgent
|
|
7
|
+
from .design.design_agent import DesignAgent
|
|
8
|
+
from .discuss.discuss_agent import DiscussionAgent
|
|
9
|
+
from .dream.dream_agent import DreamAgent
|
|
10
|
+
from .name.name_agent import NameAgent
|
|
11
|
+
from .plan.plan_agent import PlanAgent
|
|
12
|
+
from .shell.shell_agent import ShellAgent
|
|
13
|
+
from .skill.skill_agent import SkillAgent
|
|
14
|
+
from .test.test_agent import TestAgent
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"BaseAgent",
|
|
18
|
+
"ToolRegistry",
|
|
19
|
+
"get_builtin_tools",
|
|
20
|
+
"get_builtin_tool_list",
|
|
21
|
+
"CodeAgent",
|
|
22
|
+
"ChatAgent",
|
|
23
|
+
"CommonAgent",
|
|
24
|
+
"TaskAgent",
|
|
25
|
+
"DesignAgent",
|
|
26
|
+
"DiscussionAgent",
|
|
27
|
+
"DreamAgent",
|
|
28
|
+
"NameAgent",
|
|
29
|
+
"PlanAgent",
|
|
30
|
+
"ShellAgent",
|
|
31
|
+
"SkillAgent",
|
|
32
|
+
"TestAgent",
|
|
33
|
+
]
|