base-agentkit 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.
- base_agentkit-0.1.0/LICENSE +183 -0
- base_agentkit-0.1.0/PKG-INFO +142 -0
- base_agentkit-0.1.0/README.md +115 -0
- base_agentkit-0.1.0/pyproject.toml +54 -0
- base_agentkit-0.1.0/src/agentkit/__init__.py +35 -0
- base_agentkit-0.1.0/src/agentkit/agent/__init__.py +7 -0
- base_agentkit-0.1.0/src/agentkit/agent/agent.py +368 -0
- base_agentkit-0.1.0/src/agentkit/agent/budgets.py +48 -0
- base_agentkit-0.1.0/src/agentkit/agent/report.py +166 -0
- base_agentkit-0.1.0/src/agentkit/agent/tool_runtime.py +77 -0
- base_agentkit-0.1.0/src/agentkit/cli/__init__.py +5 -0
- base_agentkit-0.1.0/src/agentkit/cli/main.py +108 -0
- base_agentkit-0.1.0/src/agentkit/config/__init__.py +23 -0
- base_agentkit-0.1.0/src/agentkit/config/loader.py +108 -0
- base_agentkit-0.1.0/src/agentkit/config/provider_defaults.py +96 -0
- base_agentkit-0.1.0/src/agentkit/config/schema.py +148 -0
- base_agentkit-0.1.0/src/agentkit/constants.py +21 -0
- base_agentkit-0.1.0/src/agentkit/errors.py +58 -0
- base_agentkit-0.1.0/src/agentkit/llm/__init__.py +53 -0
- base_agentkit-0.1.0/src/agentkit/llm/base.py +36 -0
- base_agentkit-0.1.0/src/agentkit/llm/factory.py +27 -0
- base_agentkit-0.1.0/src/agentkit/llm/providers/__init__.py +15 -0
- base_agentkit-0.1.0/src/agentkit/llm/providers/anthropic_provider.py +371 -0
- base_agentkit-0.1.0/src/agentkit/llm/providers/gemini_provider.py +396 -0
- base_agentkit-0.1.0/src/agentkit/llm/providers/openai_provider.py +881 -0
- base_agentkit-0.1.0/src/agentkit/llm/providers/qwen_provider.py +34 -0
- base_agentkit-0.1.0/src/agentkit/llm/providers/vllm_provider.py +47 -0
- base_agentkit-0.1.0/src/agentkit/llm/types.py +215 -0
- base_agentkit-0.1.0/src/agentkit/llm/usage.py +72 -0
- base_agentkit-0.1.0/src/agentkit/py.typed +0 -0
- base_agentkit-0.1.0/src/agentkit/runlog/__init__.py +15 -0
- base_agentkit-0.1.0/src/agentkit/runlog/events.py +67 -0
- base_agentkit-0.1.0/src/agentkit/runlog/jsonl.py +90 -0
- base_agentkit-0.1.0/src/agentkit/runlog/recorder.py +94 -0
- base_agentkit-0.1.0/src/agentkit/runlog/sinks.py +15 -0
- base_agentkit-0.1.0/src/agentkit/tools/__init__.py +16 -0
- base_agentkit-0.1.0/src/agentkit/tools/base.py +139 -0
- base_agentkit-0.1.0/src/agentkit/tools/library/__init__.py +8 -0
- base_agentkit-0.1.0/src/agentkit/tools/library/_fs_common.py +330 -0
- base_agentkit-0.1.0/src/agentkit/tools/library/create_file.py +168 -0
- base_agentkit-0.1.0/src/agentkit/tools/library/fs_tools.py +21 -0
- base_agentkit-0.1.0/src/agentkit/tools/library/str_replace.py +241 -0
- base_agentkit-0.1.0/src/agentkit/tools/library/view.py +372 -0
- base_agentkit-0.1.0/src/agentkit/tools/library/word_count.py +138 -0
- base_agentkit-0.1.0/src/agentkit/tools/loader.py +81 -0
- base_agentkit-0.1.0/src/agentkit/tools/registry.py +284 -0
- base_agentkit-0.1.0/src/agentkit/tools/types.py +98 -0
- base_agentkit-0.1.0/src/agentkit/workspace/__init__.py +6 -0
- base_agentkit-0.1.0/src/agentkit/workspace/fs.py +288 -0
- base_agentkit-0.1.0/src/agentkit/workspace/layout.py +33 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
|
34
|
+
available under the License, as indicated by a copyright notice that is included
|
|
35
|
+
in or attached to the work (an example is provided in the Appendix below).
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
41
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
42
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the original version
|
|
45
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
46
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
47
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
48
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
|
49
|
+
"submitted" means any form of electronic, verbal, or written communication sent
|
|
50
|
+
to the Licensor or its representatives, including but not limited to
|
|
51
|
+
communication on electronic mailing lists, source code control systems, and
|
|
52
|
+
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
|
53
|
+
the purpose of discussing and improving the Work, but excluding communication
|
|
54
|
+
that is conspicuously marked or otherwise designated in writing by the copyright
|
|
55
|
+
owner as "Not a Contribution."
|
|
56
|
+
|
|
57
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
58
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
59
|
+
incorporated within the Work.
|
|
60
|
+
|
|
61
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
62
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
63
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
64
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
65
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
66
|
+
Object form.
|
|
67
|
+
|
|
68
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
|
69
|
+
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
70
|
+
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
|
71
|
+
license to make, have made, use, offer to sell, sell, import, and otherwise
|
|
72
|
+
transfer the Work, where such license applies only to those patent claims
|
|
73
|
+
licensable by such Contributor that are necessarily infringed by their
|
|
74
|
+
Contribution(s) alone or by combination of their Contribution(s) with the Work
|
|
75
|
+
to which such Contribution(s) was submitted. If You institute patent litigation
|
|
76
|
+
against any entity (including a cross-claim or counterclaim in a lawsuit)
|
|
77
|
+
alleging that the Work or a Contribution incorporated within the Work
|
|
78
|
+
constitutes direct or contributory patent infringement, then any patent licenses
|
|
79
|
+
granted to You under this License for that Work shall terminate as of the date
|
|
80
|
+
such litigation is filed.
|
|
81
|
+
|
|
82
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
83
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
84
|
+
Source or Object form, provided that You meet the following conditions:
|
|
85
|
+
|
|
86
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
87
|
+
this License; and
|
|
88
|
+
|
|
89
|
+
(b) You must cause any modified files to carry prominent notices stating that You
|
|
90
|
+
changed the files; and
|
|
91
|
+
|
|
92
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
93
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
94
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
95
|
+
of the Derivative Works; and
|
|
96
|
+
|
|
97
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
98
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
99
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
100
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
101
|
+
following places: within a NOTICE text file distributed as part of the
|
|
102
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
103
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
104
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
105
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
106
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
107
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
108
|
+
provided that such additional attribution notices cannot be construed as
|
|
109
|
+
modifying the License.
|
|
110
|
+
|
|
111
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
112
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
113
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
114
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
115
|
+
with the conditions stated in this License.
|
|
116
|
+
|
|
117
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
118
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
119
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
120
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
121
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
122
|
+
executed with Licensor regarding such Contributions.
|
|
123
|
+
|
|
124
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
125
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
126
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
127
|
+
reproducing the content of the NOTICE file.
|
|
128
|
+
|
|
129
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
130
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
131
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
132
|
+
KIND, either express or implied, including, without limitation, any warranties
|
|
133
|
+
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
134
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
135
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
136
|
+
associated with Your exercise of permissions under this License.
|
|
137
|
+
|
|
138
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
139
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
140
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
141
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
142
|
+
direct, indirect, special, incidental, or consequential damages of any character
|
|
143
|
+
arising as a result of this License or out of the use or inability to use the
|
|
144
|
+
Work (including but not limited to damages for loss of goodwill, work stoppage,
|
|
145
|
+
computer failure or malfunction, or any and all other commercial damages or
|
|
146
|
+
losses), even if such Contributor has been advised of the possibility of such
|
|
147
|
+
damages.
|
|
148
|
+
|
|
149
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
150
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
151
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
152
|
+
and/or rights consistent with this License. However, in accepting such
|
|
153
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
154
|
+
responsibility, not on behalf of any other Contributor, and only if You agree to
|
|
155
|
+
indemnify, defend, and hold each Contributor harmless for any liability incurred
|
|
156
|
+
by, or claims asserted against, such Contributor by reason of your accepting any
|
|
157
|
+
such warranty or additional liability.
|
|
158
|
+
|
|
159
|
+
END OF TERMS AND CONDITIONS
|
|
160
|
+
|
|
161
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
162
|
+
|
|
163
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
164
|
+
notice, with the fields enclosed by brackets "[]" replaced with your own
|
|
165
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
166
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
167
|
+
recommend that a file or class name and description of purpose be included on
|
|
168
|
+
the same "printed page" as the copyright notice for easier identification within
|
|
169
|
+
third-party archives.
|
|
170
|
+
|
|
171
|
+
Copyright [yyyy] [name of copyright owner]
|
|
172
|
+
|
|
173
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
174
|
+
you may not use this file except in compliance with the License.
|
|
175
|
+
You may obtain a copy of the License at
|
|
176
|
+
|
|
177
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
178
|
+
|
|
179
|
+
Unless required by applicable law or agreed to in writing, software
|
|
180
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
181
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
182
|
+
See the License for the specific language governing permissions and
|
|
183
|
+
limitations under the License.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: base-agentkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Workspace-isolated Python framework for building tool-using LLM agents.
|
|
5
|
+
Keywords: agents,llm,tool-calling,workspace,ai
|
|
6
|
+
Author: sii-nyc
|
|
7
|
+
Author-email: sii-nyc <253108120111@sii.edu.cn>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Dist: openai>=2.21.0
|
|
18
|
+
Requires-Dist: pydantic>=2.12.5
|
|
19
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
20
|
+
Requires-Dist: requests>=2.32.5
|
|
21
|
+
Requires-Python: >=3.12
|
|
22
|
+
Project-URL: Homepage, https://github.com/Inkjourney/agentkit
|
|
23
|
+
Project-URL: Repository, https://github.com/Inkjourney/agentkit
|
|
24
|
+
Project-URL: Documentation, https://github.com/Inkjourney/agentkit/tree/main/docs/agentkit
|
|
25
|
+
Project-URL: Issues, https://github.com/Inkjourney/agentkit/issues
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# AgentKit
|
|
29
|
+
|
|
30
|
+
一个基于 LLM 的通用 Agent 框架,支持 workspace 隔离、统一 LLM 抽象、工具调用循环、CLI 与 Python SDK。
|
|
31
|
+
|
|
32
|
+
## 当前能力
|
|
33
|
+
|
|
34
|
+
- workspace 强隔离:所有读写通过 `WorkspaceFS`
|
|
35
|
+
- 统一 LLM 抽象:`ConversationItem` / `ConversationState` / `UnifiedLLMRequest` / `UnifiedLLMResponse`
|
|
36
|
+
- Provider 支持(同步、非流式、文本)
|
|
37
|
+
- OpenAI (`responses` / `chat_completions`)
|
|
38
|
+
- Anthropic (`messages`)
|
|
39
|
+
- Gemini (`generateContent`)
|
|
40
|
+
- Qwen(OpenAI-compatible `chat_completions`)
|
|
41
|
+
- vLLM(OpenAI-compatible `chat_completions`)
|
|
42
|
+
- 工具系统:注册式工具机制,工具模块放在 `src/agentkit/tools/library/`
|
|
43
|
+
- Agent loop:模型推理与工具执行闭环,受 step/time budget 约束
|
|
44
|
+
- runlog:每次任务写入 `workspace/logs/run_<run_id>.jsonl`
|
|
45
|
+
|
|
46
|
+
## 状态
|
|
47
|
+
|
|
48
|
+
- 当前仓库包含针对 Agent loop、CLI、工具系统、runlog 以及 OpenAI / Anthropic / Gemini / Qwen / vLLM provider 适配层的单元测试
|
|
49
|
+
- 尚未提供针对真实上游 API 的集成 smoke test,因此正式发布前仍建议用目标模型做一次端到端验证
|
|
50
|
+
|
|
51
|
+
## 文档
|
|
52
|
+
|
|
53
|
+
详细使用说明和完整文档见 `docs/agentkit/`。
|
|
54
|
+
|
|
55
|
+
## 从源码安装
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
uv sync
|
|
59
|
+
uv run agentkit --help
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 从 PyPI 安装
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install base-agentkit
|
|
66
|
+
agentkit --help
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
安装后的导入路径和 CLI 名称保持不变:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from agentkit import create_agent
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 配置示例
|
|
76
|
+
|
|
77
|
+
### vLLM
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
workspace:
|
|
81
|
+
root: "./vllm_workspace"
|
|
82
|
+
|
|
83
|
+
provider:
|
|
84
|
+
kind: "vllm"
|
|
85
|
+
model: "glm-5"
|
|
86
|
+
openai_api_variant: "chat_completions"
|
|
87
|
+
conversation_mode: "auto"
|
|
88
|
+
base_url: "http://localhost:8000/v1"
|
|
89
|
+
api_key: "empty"
|
|
90
|
+
temperature: 0.8
|
|
91
|
+
timeout_s: 600
|
|
92
|
+
retries: 2
|
|
93
|
+
enable_thinking: true
|
|
94
|
+
|
|
95
|
+
agent:
|
|
96
|
+
system_prompt: "You are a helpful agent. Use tools when needed."
|
|
97
|
+
budget:
|
|
98
|
+
max_steps: 200
|
|
99
|
+
time_budget_s: 1800
|
|
100
|
+
max_input_chars: 180000
|
|
101
|
+
|
|
102
|
+
tools:
|
|
103
|
+
allowed:
|
|
104
|
+
- "view"
|
|
105
|
+
- "create_file"
|
|
106
|
+
- "str_replace"
|
|
107
|
+
- "word_count"
|
|
108
|
+
|
|
109
|
+
runlog:
|
|
110
|
+
enabled: true
|
|
111
|
+
redact: true
|
|
112
|
+
max_text_chars: 20000
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## CLI 运行
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
export OPENAI_API_KEY="your-key"
|
|
119
|
+
uv run agentkit --config path/to/config.yaml run --task "列出当前 workspace 的文件"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Python SDK
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from agentkit import create_agent
|
|
126
|
+
|
|
127
|
+
agent = create_agent("path/to/config.yaml")
|
|
128
|
+
report = agent.run("在 workspace 里新建 notes/todo.txt 并写入今天计划")
|
|
129
|
+
print(report.final_output)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 项目结构
|
|
133
|
+
|
|
134
|
+
核心实现位于 `src/agentkit/`:
|
|
135
|
+
|
|
136
|
+
- `config/`: 配置结构与加载
|
|
137
|
+
- `workspace/`: 强隔离文件系统和目录布局
|
|
138
|
+
- `llm/`: 统一抽象、provider base/factory 与四平台 adapter
|
|
139
|
+
- `tools/`: 工具抽象、注册表与自动加载
|
|
140
|
+
- `agent/`: budget、report、runtime、Agent loop
|
|
141
|
+
- `runlog/`: 结构化事件、event sink 与 JSONL runlog
|
|
142
|
+
- `cli/`: 命令行入口
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# AgentKit
|
|
2
|
+
|
|
3
|
+
一个基于 LLM 的通用 Agent 框架,支持 workspace 隔离、统一 LLM 抽象、工具调用循环、CLI 与 Python SDK。
|
|
4
|
+
|
|
5
|
+
## 当前能力
|
|
6
|
+
|
|
7
|
+
- workspace 强隔离:所有读写通过 `WorkspaceFS`
|
|
8
|
+
- 统一 LLM 抽象:`ConversationItem` / `ConversationState` / `UnifiedLLMRequest` / `UnifiedLLMResponse`
|
|
9
|
+
- Provider 支持(同步、非流式、文本)
|
|
10
|
+
- OpenAI (`responses` / `chat_completions`)
|
|
11
|
+
- Anthropic (`messages`)
|
|
12
|
+
- Gemini (`generateContent`)
|
|
13
|
+
- Qwen(OpenAI-compatible `chat_completions`)
|
|
14
|
+
- vLLM(OpenAI-compatible `chat_completions`)
|
|
15
|
+
- 工具系统:注册式工具机制,工具模块放在 `src/agentkit/tools/library/`
|
|
16
|
+
- Agent loop:模型推理与工具执行闭环,受 step/time budget 约束
|
|
17
|
+
- runlog:每次任务写入 `workspace/logs/run_<run_id>.jsonl`
|
|
18
|
+
|
|
19
|
+
## 状态
|
|
20
|
+
|
|
21
|
+
- 当前仓库包含针对 Agent loop、CLI、工具系统、runlog 以及 OpenAI / Anthropic / Gemini / Qwen / vLLM provider 适配层的单元测试
|
|
22
|
+
- 尚未提供针对真实上游 API 的集成 smoke test,因此正式发布前仍建议用目标模型做一次端到端验证
|
|
23
|
+
|
|
24
|
+
## 文档
|
|
25
|
+
|
|
26
|
+
详细使用说明和完整文档见 `docs/agentkit/`。
|
|
27
|
+
|
|
28
|
+
## 从源码安装
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
uv sync
|
|
32
|
+
uv run agentkit --help
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 从 PyPI 安装
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install base-agentkit
|
|
39
|
+
agentkit --help
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
安装后的导入路径和 CLI 名称保持不变:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from agentkit import create_agent
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 配置示例
|
|
49
|
+
|
|
50
|
+
### vLLM
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
workspace:
|
|
54
|
+
root: "./vllm_workspace"
|
|
55
|
+
|
|
56
|
+
provider:
|
|
57
|
+
kind: "vllm"
|
|
58
|
+
model: "glm-5"
|
|
59
|
+
openai_api_variant: "chat_completions"
|
|
60
|
+
conversation_mode: "auto"
|
|
61
|
+
base_url: "http://localhost:8000/v1"
|
|
62
|
+
api_key: "empty"
|
|
63
|
+
temperature: 0.8
|
|
64
|
+
timeout_s: 600
|
|
65
|
+
retries: 2
|
|
66
|
+
enable_thinking: true
|
|
67
|
+
|
|
68
|
+
agent:
|
|
69
|
+
system_prompt: "You are a helpful agent. Use tools when needed."
|
|
70
|
+
budget:
|
|
71
|
+
max_steps: 200
|
|
72
|
+
time_budget_s: 1800
|
|
73
|
+
max_input_chars: 180000
|
|
74
|
+
|
|
75
|
+
tools:
|
|
76
|
+
allowed:
|
|
77
|
+
- "view"
|
|
78
|
+
- "create_file"
|
|
79
|
+
- "str_replace"
|
|
80
|
+
- "word_count"
|
|
81
|
+
|
|
82
|
+
runlog:
|
|
83
|
+
enabled: true
|
|
84
|
+
redact: true
|
|
85
|
+
max_text_chars: 20000
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## CLI 运行
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
export OPENAI_API_KEY="your-key"
|
|
92
|
+
uv run agentkit --config path/to/config.yaml run --task "列出当前 workspace 的文件"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Python SDK
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from agentkit import create_agent
|
|
99
|
+
|
|
100
|
+
agent = create_agent("path/to/config.yaml")
|
|
101
|
+
report = agent.run("在 workspace 里新建 notes/todo.txt 并写入今天计划")
|
|
102
|
+
print(report.final_output)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## 项目结构
|
|
106
|
+
|
|
107
|
+
核心实现位于 `src/agentkit/`:
|
|
108
|
+
|
|
109
|
+
- `config/`: 配置结构与加载
|
|
110
|
+
- `workspace/`: 强隔离文件系统和目录布局
|
|
111
|
+
- `llm/`: 统一抽象、provider base/factory 与四平台 adapter
|
|
112
|
+
- `tools/`: 工具抽象、注册表与自动加载
|
|
113
|
+
- `agent/`: budget、report、runtime、Agent loop
|
|
114
|
+
- `runlog/`: 结构化事件、event sink 与 JSONL runlog
|
|
115
|
+
- `cli/`: 命令行入口
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "base-agentkit"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Workspace-isolated Python framework for building tool-using LLM agents."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [{ name = "sii-nyc", email = "253108120111@sii.edu.cn" }]
|
|
7
|
+
requires-python = ">=3.12"
|
|
8
|
+
license = "Apache-2.0"
|
|
9
|
+
license-files = ["LICENSE"]
|
|
10
|
+
keywords = ["agents", "llm", "tool-calling", "workspace", "ai"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"License :: OSI Approved :: Apache Software License",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Typing :: Typed",
|
|
19
|
+
]
|
|
20
|
+
dependencies = [
|
|
21
|
+
"openai>=2.21.0",
|
|
22
|
+
"pydantic>=2.12.5",
|
|
23
|
+
"pyyaml>=6.0.3",
|
|
24
|
+
"requests>=2.32.5",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.scripts]
|
|
28
|
+
agentkit = "agentkit.cli.main:main"
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/Inkjourney/agentkit"
|
|
32
|
+
Repository = "https://github.com/Inkjourney/agentkit"
|
|
33
|
+
Documentation = "https://github.com/Inkjourney/agentkit/tree/main/docs/agentkit"
|
|
34
|
+
Issues = "https://github.com/Inkjourney/agentkit/issues"
|
|
35
|
+
|
|
36
|
+
[dependency-groups]
|
|
37
|
+
dev = [
|
|
38
|
+
"mkdocs>=1.6.1,<2",
|
|
39
|
+
"mkdocs-material>=9.7.1",
|
|
40
|
+
"mkdocstrings[python]>=1.0.3",
|
|
41
|
+
"pytest>=8.4.2",
|
|
42
|
+
"ruff>=0.15.5",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[build-system]
|
|
46
|
+
requires = ["uv_build>=0.9.17,<0.10.0"]
|
|
47
|
+
build-backend = "uv_build"
|
|
48
|
+
|
|
49
|
+
[tool.uv.build-backend]
|
|
50
|
+
module-name = "agentkit"
|
|
51
|
+
|
|
52
|
+
[tool.pytest.ini_options]
|
|
53
|
+
testpaths = ["tests"]
|
|
54
|
+
addopts = "-ra"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Generic LLM agent framework."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from .agent.agent import Agent
|
|
8
|
+
from .config.loader import load_config
|
|
9
|
+
from .config.schema import AgentkitConfig
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def create_agent(
|
|
13
|
+
config_or_path: AgentkitConfig | str | Path,
|
|
14
|
+
) -> Agent:
|
|
15
|
+
"""Build an :class:`Agent` from config data or a config file.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
config_or_path: Either a fully instantiated framework config object or a
|
|
19
|
+
filesystem path to a YAML/JSON config file.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
Agent: A configured agent instance ready to execute tasks.
|
|
23
|
+
|
|
24
|
+
Raises:
|
|
25
|
+
agentkit.errors.ConfigError: If the config file is invalid or missing required
|
|
26
|
+
fields.
|
|
27
|
+
"""
|
|
28
|
+
if isinstance(config_or_path, AgentkitConfig):
|
|
29
|
+
config = config_or_path
|
|
30
|
+
else:
|
|
31
|
+
config = load_config(config_or_path)
|
|
32
|
+
return Agent.from_config(config)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
__all__ = ["Agent", "AgentkitConfig", "create_agent", "load_config"]
|