pocketexpert-harness 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.
- pocketexpert_harness-0.1.0/LICENSE +202 -0
- pocketexpert_harness-0.1.0/NOTICE +6 -0
- pocketexpert_harness-0.1.0/PKG-INFO +335 -0
- pocketexpert_harness-0.1.0/README.md +310 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/__init__.py +6 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/agent.py +213 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/builtin_skills/data-analysis/SKILL.md +20 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/builtin_skills/research-brief/SKILL.md +23 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/builtin_skills/writing-polish/SKILL.md +17 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/cli.py +299 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/config.py +129 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/kernel/EXPORT.json +17 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/kernel/__init__.py +9 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/kernel/hooks.py +231 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/kernel/loop.py +652 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/kernel/skill_format.py +104 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/llm.py +171 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/mcp.py +401 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/memory.py +148 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/prompt.py +41 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/server.py +229 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/sessions.py +101 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/skills.py +99 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/tools/__init__.py +102 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/tools/local.py +135 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/tools/web.py +238 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/web/app.css +188 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/web/app.js +397 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness/web/index.html +88 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness.egg-info/PKG-INFO +335 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness.egg-info/SOURCES.txt +42 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness.egg-info/dependency_links.txt +1 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness.egg-info/entry_points.txt +3 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness.egg-info/requires.txt +8 -0
- pocketexpert_harness-0.1.0/pocketexpert_harness.egg-info/top_level.txt +1 -0
- pocketexpert_harness-0.1.0/pyproject.toml +53 -0
- pocketexpert_harness-0.1.0/setup.cfg +4 -0
- pocketexpert_harness-0.1.0/tests/test_agent.py +178 -0
- pocketexpert_harness-0.1.0/tests/test_kernel_export.py +33 -0
- pocketexpert_harness-0.1.0/tests/test_llm.py +82 -0
- pocketexpert_harness-0.1.0/tests/test_mcp.py +100 -0
- pocketexpert_harness-0.1.0/tests/test_server.py +64 -0
- pocketexpert_harness-0.1.0/tests/test_skills_memory.py +72 -0
- pocketexpert_harness-0.1.0/tests/test_tools.py +124 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
PocketExpertHarness
|
|
2
|
+
Copyright 2026 AgentsDance
|
|
3
|
+
|
|
4
|
+
This product includes software developed at AgentsDance (https://agentsdance.ai/).
|
|
5
|
+
The files under pocketexpert_harness/kernel/ are exported unchanged from the
|
|
6
|
+
engine that runs PocketExpert AI (口袋专家 AI) in production.
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pocketexpert-harness
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The open-core agent harness behind PocketExpert AI: ReAct engine, MCP, skills, long-term memory, CLI and web chat.
|
|
5
|
+
Author: AgentsDance
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://agentsdance.ai
|
|
8
|
+
Project-URL: Repository, https://github.com/AgentsDanceAI/PocketExpertHarness
|
|
9
|
+
Project-URL: Issues, https://github.com/AgentsDanceAI/PocketExpertHarness/issues
|
|
10
|
+
Keywords: agent,llm,react,mcp,skills,harness,openai-compatible,deepseek,qwen
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
License-File: NOTICE
|
|
17
|
+
Requires-Dist: httpx>=0.27
|
|
18
|
+
Requires-Dist: fastapi>=0.110
|
|
19
|
+
Requires-Dist: uvicorn>=0.29
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
22
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
23
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
<h1 align="center">
|
|
27
|
+
<img src="https://raw.githubusercontent.com/AgentsDanceAI/PocketExpertHarness/main/docs/logo.png" alt="PocketExpertHarness" width="88"><br>
|
|
28
|
+
PocketExpertHarness
|
|
29
|
+
</h1>
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<b>口袋专家 AI 的开源智能体内核</b><br>
|
|
33
|
+
让 AI 自己决定下一步: 搜索、读网页、跑代码、读写文件、调 MCP 工具和技能, 一直做到把事办完。
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<b>简体中文</b> · <a href="https://github.com/AgentsDanceAI/PocketExpertHarness/blob/main/README.en.md">English</a>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
<a href="#-5-分钟跑起来"><img src="https://img.shields.io/badge/5_分钟-跑起来-06B6D4?style=for-the-badge" alt="5 分钟跑起来"></a>
|
|
42
|
+
<a href="#-什么是智能体内核"><img src="https://img.shields.io/badge/先看-背景-F59E0B?style=for-the-badge" alt="先看背景"></a>
|
|
43
|
+
<a href="https://agentsdance.ai"><img src="https://img.shields.io/badge/在线体验-免注册-8B5CF6?style=for-the-badge" alt="在线体验"></a>
|
|
44
|
+
<a href="https://github.com/AgentsDanceAI/PocketExpertHarness/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache_2.0-22C55E?style=for-the-badge" alt="Apache-2.0"></a>
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
<p align="center">
|
|
48
|
+
<img src="https://img.shields.io/badge/python-≥3.10-3776AB?logo=python&logoColor=white" alt="Python ≥3.10">
|
|
49
|
+
<img src="https://img.shields.io/badge/Docker-一条命令-2496ED?logo=docker&logoColor=white" alt="Docker">
|
|
50
|
+
<img src="https://img.shields.io/badge/MCP-stdio_·_HTTP-111111" alt="MCP">
|
|
51
|
+
<img src="https://img.shields.io/badge/技能-SKILL.md-8B5CF6" alt="SKILL.md">
|
|
52
|
+
<a href="https://github.com/AgentsDanceAI/PocketExpertHarness/actions/workflows/ci.yml"><img src="https://github.com/AgentsDanceAI/PocketExpertHarness/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
53
|
+
<a href="https://x.com/AgentsDanceAI"><img src="https://img.shields.io/badge/X-@AgentsDanceAI-000000?logo=x&logoColor=white" alt="X"></a>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
<p align="center">
|
|
57
|
+
<img src="https://raw.githubusercontent.com/AgentsDanceAI/PocketExpertHarness/main/docs/screenshot.png" alt="网页聊天界面" width="820">
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
> **不想装? 直接在线体验 (免注册):** <https://agentsdance.ai>
|
|
61
|
+
>
|
|
62
|
+
> **手机上用:** iPhone / iPad 在 [App Store 下载口袋专家 AI](https://apps.apple.com/app/%E5%8F%A3%E8%A2%8B%E4%B8%93%E5%AE%B6ai/id6801482441); Android、微信小程序和电脑客户端见 [下载页](https://agentsdance.ai/download)。
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 🤔 什么是智能体内核
|
|
67
|
+
|
|
68
|
+
大模型本身只会「说」: 你给它一段话, 它回一段话。要它真的把事办完 —— 查资料、读网页、算数、改文件、调别的服务 —— 还缺一层替它「动手」的东西: 把工具交给它, 它想调哪个就去执行, 把结果喂回去, 再让它决定下一步; 顺带管好对话太长怎么压缩、调用失败怎么重试、卡住了怎么收尾、哪些事不许做。
|
|
69
|
+
|
|
70
|
+
这一层就叫 **agent harness (智能体内核)**。**模型负责想, 内核负责动手、记事、守规矩。**
|
|
71
|
+
|
|
72
|
+
<p align="center">
|
|
73
|
+
<code>智能体 = 模型 (想) + 内核 (循环 · 工具 · 记忆 · 技能 · 安全边界)</code>
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
PocketExpertHarness 就是 [口袋专家 AI](https://agentsdance.ai) 线上每天在跑的那个内核, 连同一套拿来就能用的外壳 (网页聊天、命令行、联网搜索、MCP、技能、长期记忆) 一起开源。适合:
|
|
77
|
+
|
|
78
|
+
- **想要一个自己部署的 AI 助手**: 5 分钟用 Docker 跑起来, 接自己的模型 Key, 数据都留在自己机器上;
|
|
79
|
+
- **想弄明白 AI 助手是怎么干活的**: 内核只有几个文件, 事件流把每一步想了什么、调了什么都摊开给你看;
|
|
80
|
+
- **想在它上面做自己的东西**: 换模型、加工具、写技能、接 MCP, 或者在 Python 里直接调用。
|
|
81
|
+
|
|
82
|
+
## ✨ 它和别的 agent 框架有什么不同
|
|
83
|
+
|
|
84
|
+
- **和生产同一个引擎。** `pocketexpert_harness/kernel/` 是从口袋专家 AI 线上每天在跑的回合驱动器原样导出的, 不是另写的演示版。
|
|
85
|
+
- **下一步由模型决定。** 内核不做意图分类, 没有写死的流程, 也不预设"先搜再读"。它只负责循环本身: 收件箱、会话日志、上下文压缩、失败重试、卡住检测、收尾。
|
|
86
|
+
- **跑的过程中可以插话。** 回答还没出来时继续输入, 它在下一步开始前就会读到并调整方向。
|
|
87
|
+
- **国内开箱能用。** 内置 DeepSeek、通义千问、硅基流动预设; 网页端不依赖任何境外 CDN 或字体; 自带 SearXNG 免费联网搜索。
|
|
88
|
+
- **MCP、技能、长期记忆都是现成的。** MCP 配置格式与 Claude Desktop 相同; 技能兼容 SKILL.md; 记忆就是两个你能直接编辑的文件。
|
|
89
|
+
|
|
90
|
+
## 📰 最新动态
|
|
91
|
+
|
|
92
|
+
- **2026-09-24** 🎉 **v0.1.0 首次开源** —— 内核与口袋专家 AI 线上同一份; 网页聊天 (可以中途插话、随时停止) + 命令行; MCP (stdio / Streamable HTTP)、SKILL.md 技能、长期记忆; DeepSeek / 通义千问 / 硅基流动 / OpenAI / OpenRouter / Ollama 预设; `docker compose` 自带 SearXNG 联网搜索。
|
|
93
|
+
|
|
94
|
+
## 🚀 5 分钟跑起来
|
|
95
|
+
|
|
96
|
+
### 0. 准备一个模型 Key
|
|
97
|
+
|
|
98
|
+
任选一家, 拿到 API Key 就行:
|
|
99
|
+
|
|
100
|
+
| 想用 | 去哪拿 | `.env` 里填 |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| DeepSeek (推荐, 便宜好用) | [DeepSeek 开放平台](https://platform.deepseek.com/api_keys) | `PEH_PROVIDER=deepseek`<br>`LLM_API_KEY=sk-...` |
|
|
103
|
+
| 通义千问 | [阿里云百炼](https://bailian.console.aliyun.com/) | `PEH_PROVIDER=qwen`<br>`DASHSCOPE_API_KEY=sk-...` |
|
|
104
|
+
| 完全免费、数据不出本机 | 装好 [Ollama](https://ollama.com) 后 `ollama pull qwen2.5:7b` | `PEH_PROVIDER=ollama` |
|
|
105
|
+
|
|
106
|
+
其余预设和自定义接口见下面的 [模型](#-模型) 一节。
|
|
107
|
+
|
|
108
|
+
### 1. 用 Docker 跑 (推荐, 自带联网搜索)
|
|
109
|
+
|
|
110
|
+
先装好 [Docker](https://docs.docker.com/get-docker/) (Windows / macOS 装 Docker Desktop), 然后:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
git clone https://github.com/AgentsDanceAI/PocketExpertHarness.git
|
|
114
|
+
cd PocketExpertHarness
|
|
115
|
+
cp .env.example .env # 打开 .env, 填上面那两行
|
|
116
|
+
docker compose up -d # 第一次要构建镜像, 等几分钟
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
浏览器打开 <http://127.0.0.1:8080> 就能用了。会话、记忆和工作区文件都在 `./data` 下, 删了容器也不丢。
|
|
120
|
+
|
|
121
|
+
- 换端口: `.env` 里加一行 `PEH_PORT=8090`
|
|
122
|
+
- 更新到最新版: `git pull && docker compose up -d --build`
|
|
123
|
+
- 停掉: `docker compose down`
|
|
124
|
+
|
|
125
|
+
### 2. 或者直接在本机跑 (一行, 不用下载代码)
|
|
126
|
+
|
|
127
|
+
装好 [uv](https://docs.astral.sh/uv/) (Python 世界的 `npx`; 没有的话 `pip install uv`), 然后:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
export PEH_PROVIDER=deepseek LLM_API_KEY=sk-...
|
|
131
|
+
uvx --from git+https://github.com/AgentsDanceAI/PocketExpertHarness peh serve # 浏览器打开 http://127.0.0.1:8080
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
第一次会自动下载并装好依赖 (几秒钟), 以后秒开。想长期用、以后直接敲 `peh`:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
uv tool install git+https://github.com/AgentsDanceAI/PocketExpertHarness # 或者 pipx install git+https://github.com/AgentsDanceAI/PocketExpertHarness
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
要改代码就 clone 下来 `pip install -e .`。
|
|
141
|
+
|
|
142
|
+
**`peh` 是什么**: 就是这个项目本身的命令 (PocketExpert Harness 的缩写), 用上面任一种方式装好就有。常用的几个:
|
|
143
|
+
|
|
144
|
+
| 命令 | 做什么 |
|
|
145
|
+
|---|---|
|
|
146
|
+
| `peh serve` | 起网页聊天 (和 Docker 方式同一个界面) |
|
|
147
|
+
| `peh` | 直接在终端里聊天 |
|
|
148
|
+
| `peh run "问题"` | 问一句、答完就退出, 适合写进脚本 |
|
|
149
|
+
| `peh doctor` | 检查模型、搜索、MCP 有没有配好 |
|
|
150
|
+
|
|
151
|
+
**联网搜索 (本机方式要自己接一个, 不接也能用, 只是不能上网搜)** —— 三选一:
|
|
152
|
+
|
|
153
|
+
- **自己起一个 SearXNG (免费, 不用 Key, 推荐)**: 需要 Docker, 先取一份现成的配置再起:
|
|
154
|
+
```bash
|
|
155
|
+
curl -fsSLo searxng.yml https://raw.githubusercontent.com/AgentsDanceAI/PocketExpertHarness/main/deploy/searxng/settings.yml
|
|
156
|
+
docker run -d --name searxng -p 127.0.0.1:8888:8080 -e SEARXNG_SECRET=换一串随机字符 \
|
|
157
|
+
-v "$PWD/searxng.yml:/etc/searxng/settings.yml:ro" searxng/searxng
|
|
158
|
+
export SEARXNG_URL=http://127.0.0.1:8888
|
|
159
|
+
```
|
|
160
|
+
- **Tavily**: 在 [tavily.com](https://tavily.com) 注册拿 Key, `export TAVILY_API_KEY=tvly-...`
|
|
161
|
+
- **Brave Search**: 在 [Brave Search API](https://brave.com/search/api/) 申请 Key, `export BRAVE_API_KEY=...`
|
|
162
|
+
|
|
163
|
+
配好后跑 `peh doctor`, 「联网搜索」那一行显示 `✓ 联网搜索: searxng` (或 tavily / brave) 就对了。
|
|
164
|
+
Docker 方式不用管这一步: `docker compose up -d` 会把 SearXNG 一起起好。
|
|
165
|
+
|
|
166
|
+
### 遇到问题先跑 `peh doctor`
|
|
167
|
+
|
|
168
|
+
它会真的调一次模型, 再逐项告诉你搜索、代码执行、MCP 的状态。Docker 方式里这样跑: `docker compose exec harness peh doctor`。
|
|
169
|
+
|
|
170
|
+
- **页面能打开, 但一直不回答**: 多半是 Key 填错或余额不足, doctor 的「模型」那一行会给出原始报错。
|
|
171
|
+
- **想让局域网里别的电脑也能用**: 先在 `.env` 设 `PEH_ACCESS_TOKEN` (访问口令), 再把 `docker-compose.yml` 端口映射里的 `127.0.0.1:` 去掉。本机方式 `peh serve --host 0.0.0.0` 不设口令会直接拒绝启动。
|
|
172
|
+
- **联网搜索没结果**: Docker 方式自带的 SearXNG 第一次启动要等它起来; 本机方式要先配上面三选一的搜索服务。
|
|
173
|
+
|
|
174
|
+
## 🧠 模型
|
|
175
|
+
|
|
176
|
+
任何兼容 OpenAI `/chat/completions` 且支持工具调用 (function calling) 的服务都能用。内置预设:
|
|
177
|
+
|
|
178
|
+
| `PEH_PROVIDER` | 默认模型 | Key 环境变量 |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| `deepseek` | `deepseek-chat` | `DEEPSEEK_API_KEY` 或 `LLM_API_KEY` |
|
|
181
|
+
| `qwen` (阿里云百炼) | `qwen-plus` | `DASHSCOPE_API_KEY` |
|
|
182
|
+
| `siliconflow` | `deepseek-ai/DeepSeek-V3` | `SILICONFLOW_API_KEY` |
|
|
183
|
+
| `openai` | `gpt-4o-mini` | `OPENAI_API_KEY` |
|
|
184
|
+
| `openrouter` | `deepseek/deepseek-chat` | `OPENROUTER_API_KEY` |
|
|
185
|
+
| `ollama` (本地) | `qwen2.5:7b` | 不需要 |
|
|
186
|
+
|
|
187
|
+
用 `LLM_MODEL` 换模型, 用 `LLM_BASE_URL` 接任何别的兼容服务。模型越强, 多步任务越稳。
|
|
188
|
+
|
|
189
|
+
## 🔧 工具
|
|
190
|
+
|
|
191
|
+
| 工具 | 做什么 | 开关 |
|
|
192
|
+
|---|---|---|
|
|
193
|
+
| `web_search` | 联网搜索 (SearXNG / Tavily / Brave) | 配了搜索服务才有 |
|
|
194
|
+
| `open_url` | 读网页正文; 默认拒绝内网地址 | 常开 |
|
|
195
|
+
| `list_files` `read_file` `write_file` | 读写工作区文件, 路径逃不出工作区 | 常开 |
|
|
196
|
+
| `run_python` | 运行 Python 代码 (计算、数据分析、画图) | `PEH_PYTHON=on/ask/off` |
|
|
197
|
+
| `use_skill` | 读技能的完整说明和附带文件 | 有技能就有 |
|
|
198
|
+
| `remember` | 记进长期记忆 | 常开 |
|
|
199
|
+
| `mcp__<服务>__<工具>` | 你接入的 MCP 服务的工具 | 见下 |
|
|
200
|
+
|
|
201
|
+
## 🔌 接入 MCP
|
|
202
|
+
|
|
203
|
+
在 `config/mcp.json` (Docker) 或当前目录的 `mcp.json` (本机) 里写, 格式与 Claude Desktop / Cursor 相同:
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"mcpServers": {
|
|
208
|
+
"filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "./workspace"] },
|
|
209
|
+
"remote": { "url": "https://example.com/mcp", "headers": { "Authorization": "Bearer ${REMOTE_TOKEN}" } }
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
支持 stdio 与 Streamable HTTP 两种传输; 值里的 `${ENV}` 会从环境变量取。stdio 子进程只继承 PATH、HOME 这类基础变量加上你写的 `env`, 不会把模型的 API Key 带过去。
|
|
215
|
+
|
|
216
|
+
## 📚 技能
|
|
217
|
+
|
|
218
|
+
一个目录一个技能, 入口是 `SKILL.md`, 放在 `./skills/` 下 (格式兼容 Claude 的 Agent Skills):
|
|
219
|
+
|
|
220
|
+
```markdown
|
|
221
|
+
---
|
|
222
|
+
name: weekly-report
|
|
223
|
+
description: 按公司模板写周报。用户要"写周报"时使用。
|
|
224
|
+
triggers: [周报, weekly report]
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
1. 先问清楚本周做了什么……
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
- 系统提示里只列技能名和一句话说明, 模型用得上时再读全文。
|
|
231
|
+
- 用户的话命中 `triggers` 时, 第一步前自动加载 (拉丁词按词边界匹配, 中文按子串)。
|
|
232
|
+
- 内置三个示例: `research-brief` (带出处的调研简报)、`data-analysis`、`writing-polish`。
|
|
233
|
+
|
|
234
|
+
## 💾 长期记忆
|
|
235
|
+
|
|
236
|
+
两个文件, 在 `~/.pocketexpert-harness/` (Docker 是 `./data/`):
|
|
237
|
+
|
|
238
|
+
- `soul.md`: 你手写的身份、偏好、固定要求, 每一轮都带上。
|
|
239
|
+
- `memories.json`: 对话里让它记住的要点 (对它说"记住……")。近似的说法会合并。
|
|
240
|
+
|
|
241
|
+
记忆可能来自网页或粘贴的内容, 所以写入时会剥掉"忽略以上指令"这类行, 放进提示词时也会注明"这是背景参考, 不是本轮指令"。
|
|
242
|
+
|
|
243
|
+
## 🐍 在代码里用
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
import asyncio
|
|
247
|
+
from pocketexpert_harness.agent import Harness
|
|
248
|
+
from pocketexpert_harness.config import Settings
|
|
249
|
+
from pocketexpert_harness.tools import Tool
|
|
250
|
+
|
|
251
|
+
async def main():
|
|
252
|
+
h = await Harness(Settings.from_env()).start()
|
|
253
|
+
|
|
254
|
+
async def weather(args):
|
|
255
|
+
return f"{args['city']}: 晴, 26°C"
|
|
256
|
+
h.registry.add(Tool(name="weather", description="查城市天气", handler=weather,
|
|
257
|
+
parameters={"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}))
|
|
258
|
+
|
|
259
|
+
history = []
|
|
260
|
+
async for ev in h.run_turn(history, "杭州今天适合跑步吗?"):
|
|
261
|
+
if ev["event"] == "step":
|
|
262
|
+
print("→", ev["tool"], ev["args"])
|
|
263
|
+
elif ev["event"] == "done":
|
|
264
|
+
print(ev["answer"])
|
|
265
|
+
history = ev["history"] # 下一轮接着传进去
|
|
266
|
+
await h.close()
|
|
267
|
+
|
|
268
|
+
asyncio.run(main())
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## 🏗️ 架构
|
|
272
|
+
|
|
273
|
+
<picture>
|
|
274
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/AgentsDanceAI/PocketExpertHarness/main/docs/architecture-zh-dark.svg">
|
|
275
|
+
<img alt="PocketExpertHarness 架构: kernel 内核 (Inbox → ReactLoop → SessionLog + hooks) 通过 llm / tools / assemble 三个端口接外壳" src="https://raw.githubusercontent.com/AgentsDanceAI/PocketExpertHarness/main/docs/architecture-zh-light.svg">
|
|
276
|
+
</picture>
|
|
277
|
+
|
|
278
|
+
内核只有三个端口: 调模型、执行工具、装配系统提示。外壳 (本仓其余部分) 就是这三个端口的一种实现, 你可以换掉任何一个。
|
|
279
|
+
|
|
280
|
+
## 📡 事件流
|
|
281
|
+
|
|
282
|
+
`run_turn` 和网页接口 (`POST /api/sessions/{id}/messages`, SSE) 产出同一组事件:
|
|
283
|
+
|
|
284
|
+
| 事件 | 含义 |
|
|
285
|
+
|---|---|
|
|
286
|
+
| `assistant_delta` | 模型流式输出的一段文字 (可能是思考, 也可能是最终回答) |
|
|
287
|
+
| `step` | 开始调用一个工具: `tool`、`args`、`thought` |
|
|
288
|
+
| `observation` | 工具结果摘要: `ok`、`summary` |
|
|
289
|
+
| `steer` | 用户中途插的话已并入下一步 |
|
|
290
|
+
| `notice` | 重试、截断、自动加载技能、收尾等提示 |
|
|
291
|
+
| `done` | 回合结束: `answer`、`kind` (completed / blocked / error …)、`history` |
|
|
292
|
+
|
|
293
|
+
插话: `POST /api/sessions/{id}/steer`; 停止: `POST /api/sessions/{id}/stop`。
|
|
294
|
+
|
|
295
|
+
## 🛡️ 安全须知
|
|
296
|
+
|
|
297
|
+
- `run_python` **不是安全沙箱**: 在本机跑就是在你的电脑上执行模型写的代码。命令行默认每次先问 (`ask`), 网页服务默认只在容器里开启。子进程拿不到环境变量里的密钥。
|
|
298
|
+
- 网页服务默认只监听 127.0.0.1。要让别的机器访问, 必须先设 `PEH_ACCESS_TOKEN`, 否则拒绝启动。
|
|
299
|
+
- `open_url` 默认拒绝内网与云主机元数据地址, 每一跳重定向都重新检查 (`PEH_ALLOW_PRIVATE_URLS=1` 可放开)。
|
|
300
|
+
- 发现安全问题请看 [SECURITY.md](https://github.com/AgentsDanceAI/PocketExpertHarness/blob/main/SECURITY.md)。
|
|
301
|
+
|
|
302
|
+
## 🧪 和口袋专家 AI 的关系
|
|
303
|
+
|
|
304
|
+
这里开源的是**内核**。完整产品 [口袋专家 AI](https://agentsdance.ai) 在同一个引擎上还有:
|
|
305
|
+
|
|
306
|
+
- 250+ 位行业专家, 以及多位专家一起干活的专家群
|
|
307
|
+
- 先弄明白用户要什么的理解层、分层提示词
|
|
308
|
+
- 一键出 PPT、网页、视频
|
|
309
|
+
- 开箱即用, 不用自己配模型和 Key: 网页、[iPhone / iPad App](https://apps.apple.com/app/%E5%8F%A3%E8%A2%8B%E4%B8%93%E5%AE%B6ai/id6801482441)、Android、微信小程序和电脑客户端同一个账号
|
|
310
|
+
|
|
311
|
+
## 💬 交流
|
|
312
|
+
|
|
313
|
+
- 用得不顺、想要新功能: 提 [issue](https://github.com/AgentsDanceAI/PocketExpertHarness/issues)
|
|
314
|
+
- 关注更新: X [@AgentsDanceAI](https://x.com/AgentsDanceAI)
|
|
315
|
+
- 其他事: support@agentsdance.ai
|
|
316
|
+
|
|
317
|
+
## 🤝 参与贡献
|
|
318
|
+
|
|
319
|
+
欢迎 issue 和 PR, 见 [CONTRIBUTING.md](https://github.com/AgentsDanceAI/PocketExpertHarness/blob/main/CONTRIBUTING.md)。`kernel/` 由上游导出, 请不要在本仓直接修改, 有问题提 issue。
|
|
320
|
+
|
|
321
|
+
## 📄 许可证
|
|
322
|
+
|
|
323
|
+
[Apache License 2.0](https://github.com/AgentsDanceAI/PocketExpertHarness/blob/main/LICENSE)
|
|
324
|
+
|
|
325
|
+
## ⭐ Star History
|
|
326
|
+
|
|
327
|
+
<a href="https://star-history.com/#AgentsDanceAI/PocketExpertHarness&Date">
|
|
328
|
+
<picture>
|
|
329
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=AgentsDanceAI/PocketExpertHarness&type=Date&theme=dark" />
|
|
330
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=AgentsDanceAI/PocketExpertHarness&type=Date" />
|
|
331
|
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=AgentsDanceAI/PocketExpertHarness&type=Date" width="600" />
|
|
332
|
+
</picture>
|
|
333
|
+
</a>
|
|
334
|
+
|
|
335
|
+
觉得有用的话, 点个 ⭐ Star 支持一下。
|