wagent-framework 1.4.0__py3-none-any.whl

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.
@@ -0,0 +1,309 @@
1
+ Metadata-Version: 2.4
2
+ Name: wagent-framework
3
+ Version: 1.4.0
4
+ Summary: Python enterprise agent framework with AOP, IOC, and sandbox security
5
+ Home-page: https://github.com/LuckyStar2456/W-Agent-FrameWork
6
+ Author: LuckyStar2456
7
+ Author-email: lucky_star_2456@example.com
8
+ License: MIT
9
+ Project-URL: Bug Reports, https://github.com/LuckyStar2456/W-Agent-FrameWork/issues
10
+ Project-URL: Source, https://github.com/LuckyStar2456/W-Agent-FrameWork
11
+ Keywords: agent framework AOP IOC sandbox
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: pydantic
25
+ Requires-Dist: structlog
26
+ Requires-Dist: cryptography
27
+ Requires-Dist: msgpack
28
+ Requires-Dist: zstandard
29
+ Requires-Dist: pyjwt
30
+ Requires-Dist: asgiref
31
+ Requires-Dist: redis
32
+ Provides-Extra: fastapi
33
+ Requires-Dist: fastapi; extra == "fastapi"
34
+ Requires-Dist: uvicorn; extra == "fastapi"
35
+ Provides-Extra: langchain
36
+ Requires-Dist: langchain; extra == "langchain"
37
+ Provides-Extra: wasm
38
+ Requires-Dist: wasmer; extra == "wasm"
39
+ Provides-Extra: opentelemetry
40
+ Requires-Dist: opentelemetry-api; extra == "opentelemetry"
41
+ Requires-Dist: opentelemetry-sdk; extra == "opentelemetry"
42
+ Requires-Dist: opentelemetry-exporter-otlp; extra == "opentelemetry"
43
+ Provides-Extra: testing
44
+ Requires-Dist: pytest; extra == "testing"
45
+ Requires-Dist: pytest-asyncio; extra == "testing"
46
+ Dynamic: author
47
+ Dynamic: author-email
48
+ Dynamic: classifier
49
+ Dynamic: description
50
+ Dynamic: description-content-type
51
+ Dynamic: home-page
52
+ Dynamic: keywords
53
+ Dynamic: license
54
+ Dynamic: license-file
55
+ Dynamic: project-url
56
+ Dynamic: provides-extra
57
+ Dynamic: requires-dist
58
+ Dynamic: requires-python
59
+ Dynamic: summary
60
+
61
+ # W-Agent v1.4.0
62
+
63
+ [English](./README_EN.md) | 简体中文
64
+
65
+ Python 企业级智能体框架,完整技术架构方案。
66
+
67
+ [![Python Version](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/)
68
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
69
+ [![Stars](https://img.shields.io/github/stars/LuckyStar2456/W-Agent-FrameWork?style=social)](https://github.com/LuckyStar2456/W-Agent-FrameWork/stargazers)
70
+
71
+ ## 📚 目录
72
+
73
+ - [功能特性](#-功能特性)
74
+ - [快速开始](#-快速开始)
75
+ - [项目结构](#-项目结构)
76
+ - [核心模块](#-核心模块)
77
+ - [配置指南](#-配置指南)
78
+ - [示例项目](#-示例项目)
79
+ - [文档](#-文档)
80
+ - [贡献指南](#-贡献指南)
81
+ - [许可证](#-许可证)
82
+
83
+ ## ✨ 功能特性
84
+
85
+ | 特性 | 描述 |
86
+ |------|------|
87
+ | **AOP 面向切面编程** | 支持 AspectJ 切点表达式(execution、within、@annotation、bean、args) |
88
+ | **IOC 依赖注入** | 三级缓存、构造器/字段/setter 注入、@Autowired/@Qualifier 注解 |
89
+ | **沙箱安全** | Wasm/nsjail 沙箱、seccomp 过滤、资源限制 |
90
+ | **弹性模式** | 重试(带退避)、断路器(CLOSED/OPEN/HALF_OPEN 状态) |
91
+ | **可观测性** | OpenTelemetry 集成、链路追踪、指标监控 |
92
+ | **RAG 集成** | 向量检索(Redis/内存)、相似度搜索 |
93
+ | **配置热更新** | 动态配置管理、配置变更事件 |
94
+
95
+ ## 🚀 快速开始
96
+
97
+ ### 安装
98
+
99
+ ```bash
100
+ # 基础安装
101
+ pip install -e .
102
+
103
+ # 安装可选依赖
104
+ pip install -e .[fastapi,langchain,redis]
105
+ ```
106
+
107
+ ### 创建你的第一个 Agent
108
+
109
+ ```python
110
+ import asyncio
111
+ from w_agent.core.agent import BaseAgent
112
+ from w_agent.container.bean_factory import BeanFactory
113
+ from w_agent.core.decorators import AgentComponent
114
+
115
+ @AgentComponent(name="hello_agent")
116
+ class HelloAgent(BaseAgent):
117
+ async def arun(self, prompt: str) -> str:
118
+ return f"Hello, {prompt}!"
119
+
120
+ async def main():
121
+ # 创建 Bean 工厂
122
+ bean_factory = BeanFactory()
123
+
124
+ # 注册 Agent
125
+ agent = HelloAgent()
126
+ bean_factory.register_bean("hello_agent", agent)
127
+
128
+ # 使用 Agent
129
+ agent = await bean_factory.get_bean("hello_agent")
130
+ result = await agent.arun("World")
131
+ print(result) # 输出: Hello, World!
132
+
133
+ asyncio.run(main())
134
+ ```
135
+
136
+ ### 使用配置热更新
137
+
138
+ ```python
139
+ import asyncio
140
+ from w_agent.config.dynamic_config import DynamicConfigManager
141
+
142
+ async def main():
143
+ config_manager = DynamicConfigManager()
144
+
145
+ # 设置配置
146
+ config_manager.set("api_key", "your-api-key")
147
+
148
+ # 绑定配置到属性
149
+ class MyService:
150
+ def __init__(self):
151
+ self.api_key = None
152
+ config_manager.bind("api_key", self, "api_key")
153
+
154
+ async def on_config_change(self, key, new_value, old_value):
155
+ print(f"Config changed: {key} = {new_value}")
156
+
157
+ service = MyService()
158
+ print(service.api_key) # 输出: your-api-key
159
+
160
+ # 动态更新配置
161
+ await config_manager.update_batch({"api_key": "new-api-key"})
162
+ print(service.api_key) # 输出: new-api-key
163
+
164
+ asyncio.run(main())
165
+ ```
166
+
167
+ ## 📁 项目结构
168
+
169
+ ```
170
+ w_agent/
171
+ ├── aop/ # 面向切面编程
172
+ │ ├── aspects.py # 切面实现(重试、断路器)
173
+ │ ├── joinpoint.py # 连接点
174
+ │ ├── pointcut.py # 切点表达式解析
175
+ │ └── proxy_factory.py # 代理工厂
176
+ ├── config/ # 配置管理
177
+ │ └── dynamic_config.py # 动态配置
178
+ ├── container/ # 依赖注入容器
179
+ │ ├── bean_factory.py # Bean 工厂
180
+ │ └── reflection_cache.py # 反射缓存
181
+ ├── core/ # 核心功能
182
+ │ ├── agent.py # Agent 基类
183
+ │ ├── event_bus.py # 事件总线
184
+ │ └── decorators.py # 装饰器
185
+ ├── observability/ # 可观测性
186
+ │ ├── tracing.py # 链路追踪
187
+ │ ├── metrics.py # 指标监控
188
+ │ └── health.py # 健康检查
189
+ ├── skills/ # 技能系统
190
+ │ └── sandbox/ # 沙箱
191
+ │ ├── wasm_sandbox.py
192
+ │ └── nsjail_sandbox.py
193
+ └── ...
194
+ ```
195
+
196
+ ## 🔧 核心模块
197
+
198
+ ### AOP 切面编程
199
+
200
+ ```python
201
+ from w_agent.core.decorators import Retry, CircuitBreaker
202
+ from w_agent.aop.pointcut import AspectJPointcut
203
+
204
+ # 使用重试装饰器
205
+ @Retry(max_attempts=3, delay=0.1, backoff=2.0)
206
+ async def unreliable_operation():
207
+ pass
208
+
209
+ # 使用断路器
210
+ @CircuitBreaker(failure_threshold=5, recovery_timeout=30.0)
211
+ async def protected_operation():
212
+ pass
213
+ ```
214
+
215
+ ### 依赖注入
216
+
217
+ ```python
218
+ from w_agent.core.decorators import Autowired, Qualifier, ServiceComponent
219
+
220
+ @ServiceComponent(name="user_service")
221
+ class UserService:
222
+ @Qualifier(name="redis_client")
223
+ def set_cache(self, cache_client):
224
+ self.cache = cache_client
225
+ ```
226
+
227
+ ### 事件总线
228
+
229
+ ```python
230
+ from w_agent.core.event_bus import EventBus, Event
231
+
232
+ event_bus = EventBus()
233
+
234
+ @event_bus.on("user.created")
235
+ async def on_user_created(event):
236
+ print(f"User created: {event.payload}")
237
+
238
+ await event_bus.emit(Event("user.created", {"user_id": 123}))
239
+ ```
240
+
241
+ ## ⚙️ 配置指南
242
+
243
+ ### 可配置项一览
244
+
245
+ | 配置项 | 类型 | 默认值 | 描述 |
246
+ |--------|------|--------|------|
247
+ | `logging.level` | string | "INFO" | 日志级别 |
248
+ | `container.scan_paths` | list | ["."] | 组件扫描路径 |
249
+ | `sandbox.enabled` | bool | true | 是否启用沙箱 |
250
+ | `resilience.retry.max_attempts` | int | 3 | 最大重试次数 |
251
+ | `distributed.lock.redis.url` | string | "redis://localhost:6379" | Redis 连接 URL |
252
+
253
+ ### 配置文件
254
+
255
+ 创建 `config.json`:
256
+
257
+ ```json
258
+ {
259
+ "logging": {
260
+ "level": "INFO",
261
+ "format": "json"
262
+ },
263
+ "container": {
264
+ "scan_paths": ["src"],
265
+ "skip_paths": ["__pycache__", ".git"]
266
+ }
267
+ }
268
+ ```
269
+
270
+ ### 环境变量
271
+
272
+ ```bash
273
+ export W_AGENT_LOGGING_LEVEL=DEBUG
274
+ export W_AGENT_CONTAINER_SCAN_PATHS=src,components
275
+ ```
276
+
277
+ ## 📖 示例项目
278
+
279
+ 查看 [chat-agent](./chat-agent/) 目录获取完整的聊天智能体示例项目,包含:
280
+
281
+ - Agent 实现
282
+ - Skill 系统
283
+ - RAG 检索增强
284
+ - Redis/MySQL 集成
285
+ - OpenTelemetry 可观测性
286
+
287
+ ## 📄 文档
288
+
289
+ - [架构设计文档](./docs/architecture.md)
290
+ - [API 文档](./docs/api.md)
291
+ - [使用指南](./docs/guide.md)
292
+
293
+ ## 🤝 贡献指南
294
+
295
+ 欢迎提交 Issue 和 Pull Request!
296
+
297
+ 1. Fork 本仓库
298
+ 2. 创建特性分支 (`git checkout -b feature/amazing-feature`)
299
+ 3. 提交更改 (`git commit -m 'Add amazing feature'`)
300
+ 4. 推送分支 (`git push origin feature/amazing-feature`)
301
+ 5. 创建 Pull Request
302
+
303
+ ## 📄 许可证
304
+
305
+ 本项目采用 [MIT 许可证](LICENSE)。
306
+
307
+ ---
308
+
309
+ 如果这个项目对你有帮助,请给我们一个 ⭐!
@@ -0,0 +1,6 @@
1
+ wagent_framework-1.4.0.dist-info/licenses/LICENSE,sha256=kBvObOdHRQrfBkOmeNj-h2U_XmlU0ZAFwnQ-LrbiIOg,1091
2
+ wagent_framework-1.4.0.dist-info/METADATA,sha256=SaKIJMs-kRsEdBCeXKfrpWHf-iefuFYlcojlsK8MBUo,9141
3
+ wagent_framework-1.4.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
4
+ wagent_framework-1.4.0.dist-info/entry_points.txt,sha256=d-SKdVfLJIw5aRfClVzKb-RyqHP-oWPlv0CapJopOp4,45
5
+ wagent_framework-1.4.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
6
+ wagent_framework-1.4.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ w-agent = w_agent.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LuckyStar2456
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.