hz-agent-base 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.
Files changed (73) hide show
  1. hz_agent_base-0.1.0/.env-example +59 -0
  2. hz_agent_base-0.1.0/.gitignore +75 -0
  3. hz_agent_base-0.1.0/LICENSE +21 -0
  4. hz_agent_base-0.1.0/PKG-INFO +571 -0
  5. hz_agent_base-0.1.0/README.md +539 -0
  6. hz_agent_base-0.1.0/docs/api_reference.md +445 -0
  7. hz_agent_base-0.1.0/docs/technical_roadmap.md +536 -0
  8. hz_agent_base-0.1.0/examples/basic_agent.py +14 -0
  9. hz_agent_base-0.1.0/examples/custom_middleware.py +91 -0
  10. hz_agent_base-0.1.0/examples/custom_permissions.py +29 -0
  11. hz_agent_base-0.1.0/examples/full_featured.py +269 -0
  12. hz_agent_base-0.1.0/examples/multi_agent.py +39 -0
  13. hz_agent_base-0.1.0/examples/multi_user.py +40 -0
  14. hz_agent_base-0.1.0/examples/server_integration.py +62 -0
  15. hz_agent_base-0.1.0/examples/with_filesystem.py +29 -0
  16. hz_agent_base-0.1.0/examples/with_hooks.py +29 -0
  17. hz_agent_base-0.1.0/examples/with_knowledge.py +90 -0
  18. hz_agent_base-0.1.0/examples/with_memory.py +30 -0
  19. hz_agent_base-0.1.0/examples/with_prompts.py +51 -0
  20. hz_agent_base-0.1.0/pyproject.toml +56 -0
  21. hz_agent_base-0.1.0/requirements-dev.txt +5 -0
  22. hz_agent_base-0.1.0/requirements.txt +13 -0
  23. hz_agent_base-0.1.0/src/hz_agent_base/__init__.py +45 -0
  24. hz_agent_base-0.1.0/src/hz_agent_base/agent.py +305 -0
  25. hz_agent_base-0.1.0/src/hz_agent_base/backends/__init__.py +30 -0
  26. hz_agent_base-0.1.0/src/hz_agent_base/cli.py +237 -0
  27. hz_agent_base-0.1.0/src/hz_agent_base/config.py +87 -0
  28. hz_agent_base-0.1.0/src/hz_agent_base/coordinator/__init__.py +15 -0
  29. hz_agent_base-0.1.0/src/hz_agent_base/coordinator/coordinator.py +96 -0
  30. hz_agent_base-0.1.0/src/hz_agent_base/coordinator/team.py +56 -0
  31. hz_agent_base-0.1.0/src/hz_agent_base/coordinator/worker.py +30 -0
  32. hz_agent_base-0.1.0/src/hz_agent_base/hooks/__init__.py +33 -0
  33. hz_agent_base-0.1.0/src/hz_agent_base/hooks/events.py +22 -0
  34. hz_agent_base-0.1.0/src/hz_agent_base/hooks/executor.py +458 -0
  35. hz_agent_base-0.1.0/src/hz_agent_base/hooks/registry.py +48 -0
  36. hz_agent_base-0.1.0/src/hz_agent_base/hooks/schemas.py +90 -0
  37. hz_agent_base-0.1.0/src/hz_agent_base/knowledge/__init__.py +5 -0
  38. hz_agent_base-0.1.0/src/hz_agent_base/knowledge/protocol.py +53 -0
  39. hz_agent_base-0.1.0/src/hz_agent_base/memory/__init__.py +19 -0
  40. hz_agent_base-0.1.0/src/hz_agent_base/memory/cache.py +133 -0
  41. hz_agent_base-0.1.0/src/hz_agent_base/memory/manager.py +218 -0
  42. hz_agent_base-0.1.0/src/hz_agent_base/memory/relevance.py +237 -0
  43. hz_agent_base-0.1.0/src/hz_agent_base/middleware/__init__.py +30 -0
  44. hz_agent_base-0.1.0/src/hz_agent_base/middleware/filesystem.py +318 -0
  45. hz_agent_base-0.1.0/src/hz_agent_base/middleware/hook.py +127 -0
  46. hz_agent_base-0.1.0/src/hz_agent_base/middleware/knowledge.py +92 -0
  47. hz_agent_base-0.1.0/src/hz_agent_base/middleware/memory.py +97 -0
  48. hz_agent_base-0.1.0/src/hz_agent_base/middleware/permission.py +42 -0
  49. hz_agent_base-0.1.0/src/hz_agent_base/middleware/resilient.py +116 -0
  50. hz_agent_base-0.1.0/src/hz_agent_base/permissions/__init__.py +15 -0
  51. hz_agent_base-0.1.0/src/hz_agent_base/permissions/checker.py +191 -0
  52. hz_agent_base-0.1.0/src/hz_agent_base/permissions/modes.py +16 -0
  53. hz_agent_base-0.1.0/src/hz_agent_base/permissions/settings.py +80 -0
  54. hz_agent_base-0.1.0/src/hz_agent_base/prompts/__init__.py +5 -0
  55. hz_agent_base-0.1.0/src/hz_agent_base/prompts/manager.py +171 -0
  56. hz_agent_base-0.1.0/src/hz_agent_base/resilience/__init__.py +15 -0
  57. hz_agent_base-0.1.0/src/hz_agent_base/resilience/protocols.py +79 -0
  58. hz_agent_base-0.1.0/src/hz_agent_base/tools/__init__.py +9 -0
  59. hz_agent_base-0.1.0/tests/conftest.py +12 -0
  60. hz_agent_base-0.1.0/tests/test_agent.py +114 -0
  61. hz_agent_base-0.1.0/tests/test_concurrency.py +452 -0
  62. hz_agent_base-0.1.0/tests/test_config.py +62 -0
  63. hz_agent_base-0.1.0/tests/test_coordinator.py +241 -0
  64. hz_agent_base-0.1.0/tests/test_filesystem.py +286 -0
  65. hz_agent_base-0.1.0/tests/test_hooks.py +189 -0
  66. hz_agent_base-0.1.0/tests/test_knowledge.py +241 -0
  67. hz_agent_base-0.1.0/tests/test_memory.py +172 -0
  68. hz_agent_base-0.1.0/tests/test_memory_cache.py +219 -0
  69. hz_agent_base-0.1.0/tests/test_middleware.py +246 -0
  70. hz_agent_base-0.1.0/tests/test_permissions.py +146 -0
  71. hz_agent_base-0.1.0/tests/test_prompts.py +190 -0
  72. hz_agent_base-0.1.0/tests/test_resilient.py +490 -0
  73. hz_agent_base-0.1.0/tests/test_security.py +404 -0
@@ -0,0 +1,59 @@
1
+ # ============================================
2
+ # HZAgentBase 配置文件
3
+ # 复制此文件为 .env 并填入实际值
4
+ # ============================================
5
+
6
+ # --- 模型配置 ---
7
+ # 默认模型,根据名称自动匹配提供商:
8
+ # deepseek-* → DeepSeek
9
+ # gpt-* / o1-* / o3-* → OpenAI
10
+ # claude-* → Anthropic(需 pip install langchain-anthropic)
11
+ # gemini-* → Google Gemini(需 pip install langchain-google-genai)
12
+ # 其他 → OpenAI 兼容(Ollama、vLLM 等本地服务)
13
+ DEFAULT_MODEL=deepseek-v4-flash
14
+
15
+ # API Key(统一配置,所有提供商共用)
16
+ MODEL_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
17
+
18
+ # API Base URL(可选,通常不需要设置,各提供商有默认值)
19
+ # 仅对 OpenAI 兼容 API 生效(DeepSeek、OpenAI、Ollama 等)
20
+ # Anthropic 和 Gemini 使用各自的 SDK,不受此配置影响
21
+ # 常用值:
22
+ # DeepSeek: https://api.deepseek.com/v1(默认)
23
+ # OpenAI: https://api.openai.com/v1(默认)
24
+ # Ollama: http://localhost:11434/v1
25
+ # vLLM: http://localhost:8000/v1
26
+ # MODEL_BASE_URL=https://api.deepseek.com/v1
27
+
28
+ # --- 容错配置 ---
29
+ # LLM API 调用超时(秒,可选,默认: 600)
30
+ # MODEL_REQUEST_TIMEOUT=600
31
+ # LLM 调用失败重试次数(可选,默认: 2)
32
+ # MODEL_MAX_RETRIES=2
33
+ # Agent 最大执行步数,防止死循环(可选,默认: 25)
34
+ # RECURSION_LIMIT=25
35
+
36
+ # --- 权限配置 ---
37
+ # 权限模式: default | plan | full_auto (可选, 默认: default)
38
+ # default — 写操作需用户确认
39
+ # plan — 阻止所有写操作(只读模式)
40
+ # full_auto — 允许所有操作(需谨慎使用)
41
+ # PERMISSION_MODE=default
42
+
43
+ # --- 记忆系统 ---
44
+ # 记忆存储路径 (可选, 默认: .memory)
45
+ # MEMORY_PATH=.memory
46
+
47
+ # --- 文件审计 ---
48
+ # 审计日志路径 (可选, 默认: .audit/audit.jsonl)
49
+ # 开启方式: create_agent(filesystem=True)
50
+ # AUDIT_LOG_PATH=.audit/audit.jsonl
51
+
52
+ # --- 知识库 ---
53
+ # 知识库每次检索条数 (可选, 默认: 5)
54
+ # 需配合 retriever 参数使用: create_agent(retriever=your_retriever)
55
+ # KNOWLEDGE_TOP_K=5
56
+
57
+ # --- 日志 ---
58
+ # 日志级别: DEBUG | INFO | WARNING | ERROR (可选, 默认: INFO)
59
+ # LOG_LEVEL=INFO
@@ -0,0 +1,75 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ **/.venv/
26
+ venv/
27
+ ENV/
28
+ env/
29
+
30
+ # IDE
31
+ .vscode/
32
+ .idea/
33
+ *.swp
34
+ *.swo
35
+ *~
36
+ .project
37
+ .settings/
38
+
39
+ # Testing
40
+ .pytest_cache/
41
+ .coverage
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+
46
+ # OS
47
+ .DS_Store
48
+ Thumbs.db
49
+
50
+ # Project specific
51
+ .memory/
52
+ .my_agent_memory/
53
+ .audit/
54
+ *.log
55
+ tool_usage.log
56
+
57
+ # 技术方案文档(不入库)
58
+ *_plan.md
59
+
60
+ # Secrets and credentials
61
+ **/.env
62
+ **/.env.*
63
+ **/.env.local
64
+ **/.env.production
65
+ **/.env.staging
66
+ *.pem
67
+ *.key
68
+ *.p12
69
+ *.pfx
70
+ credentials.json
71
+ secrets.json
72
+ service-account.json
73
+
74
+ # Claude Code 会话数据
75
+ .claude/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hz
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.