nexus-agentos 0.99.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 (121) hide show
  1. nexus_agentos-0.99.0/PKG-INFO +219 -0
  2. nexus_agentos-0.99.0/README.md +182 -0
  3. nexus_agentos-0.99.0/agentos/__init__.py +180 -0
  4. nexus_agentos-0.99.0/agentos/agents/market.py +166 -0
  5. nexus_agentos-0.99.0/agentos/api/middleware.py +137 -0
  6. nexus_agentos-0.99.0/agentos/api/server.py +108 -0
  7. nexus_agentos-0.99.0/agentos/api/streaming.py +231 -0
  8. nexus_agentos-0.99.0/agentos/api/versioning.py +114 -0
  9. nexus_agentos-0.99.0/agentos/benchmarks/__init__.py +18 -0
  10. nexus_agentos-0.99.0/agentos/benchmarks/runner.py +186 -0
  11. nexus_agentos-0.99.0/agentos/cache/__init__.py +0 -0
  12. nexus_agentos-0.99.0/agentos/cache/embedder.py +189 -0
  13. nexus_agentos-0.99.0/agentos/cache/llm_cache.py +217 -0
  14. nexus_agentos-0.99.0/agentos/cache/response_cache.py +245 -0
  15. nexus_agentos-0.99.0/agentos/cli/__init__.py +1 -0
  16. nexus_agentos-0.99.0/agentos/cli/init.py +95 -0
  17. nexus_agentos-0.99.0/agentos/cli/main.py +129 -0
  18. nexus_agentos-0.99.0/agentos/cli/serve.py +57 -0
  19. nexus_agentos-0.99.0/agentos/comm/__init__.py +0 -0
  20. nexus_agentos-0.99.0/agentos/comm/layer.py +194 -0
  21. nexus_agentos-0.99.0/agentos/config/__init__.py +3 -0
  22. nexus_agentos-0.99.0/agentos/config/loader.py +393 -0
  23. nexus_agentos-0.99.0/agentos/config/presets.py +208 -0
  24. nexus_agentos-0.99.0/agentos/config/validator.py +220 -0
  25. nexus_agentos-0.99.0/agentos/core/__init__.py +1 -0
  26. nexus_agentos-0.99.0/agentos/core/async_loop.py +239 -0
  27. nexus_agentos-0.99.0/agentos/core/context.py +92 -0
  28. nexus_agentos-0.99.0/agentos/core/loop.py +394 -0
  29. nexus_agentos-0.99.0/agentos/core/session.py +43 -0
  30. nexus_agentos-0.99.0/agentos/core/state_machine.py +227 -0
  31. nexus_agentos-0.99.0/agentos/core/streaming.py +88 -0
  32. nexus_agentos-0.99.0/agentos/cost/token_counter.py +282 -0
  33. nexus_agentos-0.99.0/agentos/cost/tracker.py +120 -0
  34. nexus_agentos-0.99.0/agentos/deployment/__init__.py +1 -0
  35. nexus_agentos-0.99.0/agentos/deployment/docker.py +158 -0
  36. nexus_agentos-0.99.0/agentos/docs/__init__.py +16 -0
  37. nexus_agentos-0.99.0/agentos/docs/generator.py +292 -0
  38. nexus_agentos-0.99.0/agentos/errors/__init__.py +20 -0
  39. nexus_agentos-0.99.0/agentos/errors/handler.py +169 -0
  40. nexus_agentos-0.99.0/agentos/evaluation/__init__.py +9 -0
  41. nexus_agentos-0.99.0/agentos/evaluation/benchmark.py +122 -0
  42. nexus_agentos-0.99.0/agentos/evaluation/scorers.py +266 -0
  43. nexus_agentos-0.99.0/agentos/experiments/__init__.py +0 -0
  44. nexus_agentos-0.99.0/agentos/experiments/runner.py +257 -0
  45. nexus_agentos-0.99.0/agentos/feedback/learner.py +173 -0
  46. nexus_agentos-0.99.0/agentos/health/__init__.py +181 -0
  47. nexus_agentos-0.99.0/agentos/logging/__init__.py +17 -0
  48. nexus_agentos-0.99.0/agentos/logging/formatter.py +110 -0
  49. nexus_agentos-0.99.0/agentos/memory/__init__.py +1 -0
  50. nexus_agentos-0.99.0/agentos/memory/compressor.py +74 -0
  51. nexus_agentos-0.99.0/agentos/memory/conversation.py +250 -0
  52. nexus_agentos-0.99.0/agentos/memory/long_term.py +130 -0
  53. nexus_agentos-0.99.0/agentos/memory/retriever.py +364 -0
  54. nexus_agentos-0.99.0/agentos/memory/short_term.py +64 -0
  55. nexus_agentos-0.99.0/agentos/memory/summarizer.py +226 -0
  56. nexus_agentos-0.99.0/agentos/memory/working.py +43 -0
  57. nexus_agentos-0.99.0/agentos/models/__init__.py +1 -0
  58. nexus_agentos-0.99.0/agentos/models/backends/gemini.py +349 -0
  59. nexus_agentos-0.99.0/agentos/models/resilience.py +282 -0
  60. nexus_agentos-0.99.0/agentos/models/router.py +518 -0
  61. nexus_agentos-0.99.0/agentos/models/routing_strategy.py +79 -0
  62. nexus_agentos-0.99.0/agentos/monitoring/__init__.py +23 -0
  63. nexus_agentos-0.99.0/agentos/monitoring/alerts.py +136 -0
  64. nexus_agentos-0.99.0/agentos/multimodal/__init__.py +0 -0
  65. nexus_agentos-0.99.0/agentos/multimodal/manager.py +224 -0
  66. nexus_agentos-0.99.0/agentos/observability/__init__.py +9 -0
  67. nexus_agentos-0.99.0/agentos/observability/cost_analytics.py +416 -0
  68. nexus_agentos-0.99.0/agentos/observability/metrics.py +297 -0
  69. nexus_agentos-0.99.0/agentos/observability/tracer.py +131 -0
  70. nexus_agentos-0.99.0/agentos/orchestration/__init__.py +1 -0
  71. nexus_agentos-0.99.0/agentos/orchestration/a2a_router.py +96 -0
  72. nexus_agentos-0.99.0/agentos/orchestration/graph.py +173 -0
  73. nexus_agentos-0.99.0/agentos/orchestration/graph_executor.py +312 -0
  74. nexus_agentos-0.99.0/agentos/plugins/__init__.py +17 -0
  75. nexus_agentos-0.99.0/agentos/plugins/lifecycle.py +271 -0
  76. nexus_agentos-0.99.0/agentos/plugins/loader.py +286 -0
  77. nexus_agentos-0.99.0/agentos/plugins/registry.py +212 -0
  78. nexus_agentos-0.99.0/agentos/plugins.py +96 -0
  79. nexus_agentos-0.99.0/agentos/prompts/manager.py +221 -0
  80. nexus_agentos-0.99.0/agentos/protocols/__init__.py +8 -0
  81. nexus_agentos-0.99.0/agentos/protocols/contracts.py +327 -0
  82. nexus_agentos-0.99.0/agentos/protocols/mcp.py +148 -0
  83. nexus_agentos-0.99.0/agentos/queue/__init__.py +0 -0
  84. nexus_agentos-0.99.0/agentos/queue/rate_limiter.py +199 -0
  85. nexus_agentos-0.99.0/agentos/queue/task_queue.py +198 -0
  86. nexus_agentos-0.99.0/agentos/security/__init__.py +1 -0
  87. nexus_agentos-0.99.0/agentos/security/auditor.py +434 -0
  88. nexus_agentos-0.99.0/agentos/security/guard.py +197 -0
  89. nexus_agentos-0.99.0/agentos/security/sandbox.py +114 -0
  90. nexus_agentos-0.99.0/agentos/server/__init__.py +0 -0
  91. nexus_agentos-0.99.0/agentos/server/mcp_server.py +226 -0
  92. nexus_agentos-0.99.0/agentos/storage/__init__.py +3 -0
  93. nexus_agentos-0.99.0/agentos/storage/base.py +73 -0
  94. nexus_agentos-0.99.0/agentos/subagent/__init__.py +1 -0
  95. nexus_agentos-0.99.0/agentos/subagent/manager.py +103 -0
  96. nexus_agentos-0.99.0/agentos/swarm/__init__.py +8 -0
  97. nexus_agentos-0.99.0/agentos/swarm/coordinator.py +307 -0
  98. nexus_agentos-0.99.0/agentos/swarm/patterns.py +352 -0
  99. nexus_agentos-0.99.0/agentos/testing/__init__.py +20 -0
  100. nexus_agentos-0.99.0/agentos/testing/fixtures.py +185 -0
  101. nexus_agentos-0.99.0/agentos/tools/__init__.py +9 -0
  102. nexus_agentos-0.99.0/agentos/tools/base.py +86 -0
  103. nexus_agentos-0.99.0/agentos/tools/code_agent.py +120 -0
  104. nexus_agentos-0.99.0/agentos/tools/file_tools.py +105 -0
  105. nexus_agentos-0.99.0/agentos/tools/function_calling.py +231 -0
  106. nexus_agentos-0.99.0/agentos/tools/generator.py +241 -0
  107. nexus_agentos-0.99.0/agentos/tools/orchestrator.py +422 -0
  108. nexus_agentos-0.99.0/agentos/tools/registry.py +71 -0
  109. nexus_agentos-0.99.0/agentos/tools/web_tools.py +46 -0
  110. nexus_agentos-0.99.0/agentos/vectorstore/db.py +209 -0
  111. nexus_agentos-0.99.0/agentos/workflows/__init__.py +3 -0
  112. nexus_agentos-0.99.0/agentos/workflows/engine.py +141 -0
  113. nexus_agentos-0.99.0/agentos/workflows/templates.py +311 -0
  114. nexus_agentos-0.99.0/nexus_agentos.egg-info/PKG-INFO +219 -0
  115. nexus_agentos-0.99.0/nexus_agentos.egg-info/SOURCES.txt +120 -0
  116. nexus_agentos-0.99.0/nexus_agentos.egg-info/dependency_links.txt +1 -0
  117. nexus_agentos-0.99.0/nexus_agentos.egg-info/entry_points.txt +2 -0
  118. nexus_agentos-0.99.0/nexus_agentos.egg-info/requires.txt +21 -0
  119. nexus_agentos-0.99.0/nexus_agentos.egg-info/top_level.txt +1 -0
  120. nexus_agentos-0.99.0/pyproject.toml +59 -0
  121. nexus_agentos-0.99.0/setup.cfg +4 -0
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: nexus-agentos
3
+ Version: 0.99.0
4
+ Summary: Agent Operating System — Production-ready multi-model agent framework with TokenCounter, SemanticMemoryRetriever, ConfigPresets, ToolRegistry, WorkflowTemplate, ResponseCache, AgentGraph, StreamingAgent, ConversationMemory, AsyncAgentLoop, SwarmPatterns, CI/CD pipeline, and 30+ production modules
5
+ Author: AgentOS Team
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/agentos/agentos
8
+ Project-URL: Documentation, https://docs.agentos.dev
9
+ Project-URL: Repository, https://github.com/agentos/agentos.git
10
+ Keywords: agent,llm,ai,framework,multi-agent
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: openai>=1.0.0
19
+ Requires-Dist: httpx>=0.27.0
20
+ Requires-Dist: pyyaml>=6.0
21
+ Requires-Dist: pydantic>=2.0
22
+ Requires-Dist: aiosqlite>=0.20.0
23
+ Requires-Dist: langsmith>=0.1.0
24
+ Requires-Dist: fastapi>=0.110.0
25
+ Requires-Dist: uvicorn[standard]>=0.29.0
26
+ Requires-Dist: numpy>=1.26.0
27
+ Provides-Extra: full
28
+ Requires-Dist: faiss-cpu>=1.8.0; extra == "full"
29
+ Requires-Dist: chromadb>=0.5.0; extra == "full"
30
+ Requires-Dist: sentence-transformers>=3.0.0; extra == "full"
31
+ Requires-Dist: opentelemetry-api>=1.20.0; extra == "full"
32
+ Requires-Dist: docker>=7.0.0; extra == "full"
33
+ Requires-Dist: mcp>=1.0.0; extra == "full"
34
+ Provides-Extra: test
35
+ Requires-Dist: pytest>=8.0; extra == "test"
36
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "test"
37
+
38
+ # AgentOS v0.99
39
+
40
+ **Agent Operating System** — Production-ready multi-model agent framework.
41
+
42
+ ## Overview
43
+
44
+ AgentOS is a modular, twelve-layered framework for building, orchestrating, and deploying AI agents. It supports OpenAI, Anthropic, Google Gemini, and open-source models through a unified routing layer.
45
+
46
+ ## Quick Start
47
+
48
+ ```bash
49
+ pip install agentos
50
+
51
+ # Create a new project
52
+ agentos init my-agent
53
+
54
+ # Start the API server
55
+ agentos serve --preset production
56
+ ```
57
+
58
+ ```python
59
+ from agentos import AgentLoop, LoopConfig, ModelRouter
60
+
61
+ loop = AgentLoop(
62
+ config=LoopConfig(model="gpt-4o", max_iterations=10),
63
+ router=ModelRouter(),
64
+ )
65
+ result = loop.run("Summarize the key features of AgentOS.")
66
+ print(result.output)
67
+ ```
68
+
69
+ ## Architecture
70
+
71
+ ```
72
+ agentos/
73
+ ├── agents/ Agent marketplace & skill registry
74
+ ├── api/ REST API server, middleware, streaming, versioning
75
+ ├── benchmarks/ Benchmarking & performance testing
76
+ ├── cache/ LLM cache, response cache, embedding cache
77
+ ├── cli/ CLI scaffolding & serve commands
78
+ ├── comm/ Inter-agent communication (blackboard, event bus)
79
+ ├── config/ Configuration loader, validator, presets
80
+ ├── core/ Agent loop, state machine, async loop, streaming
81
+ ├── cost/ Cost tracking, token counting
82
+ ├── deployment/ Docker & Kubernetes deployment
83
+ ├── docs/ API documentation generator
84
+ ├── errors/ Error formatting & handling
85
+ ├── evaluation/ Scoring & evaluation metrics
86
+ ├── experiments/ A/B experiment runner
87
+ ├── feedback/ User feedback collection & learning
88
+ ├── health/ Health checks & monitoring
89
+ ├── logging/ Structured logging
90
+ ├── memory/ Short-term, long-term, working memory, summarizer, retriever
91
+ ├── models/ Model router, resilience, backends (Gemini)
92
+ ├── monitoring/ Alerting & metrics
93
+ ├── multimodal/ Image, audio, document processing
94
+ ├── observability/ Cost analytics, metrics, tracing
95
+ ├── orchestration/ DAG orchestrator, agent graph execution
96
+ ├── plugins/ Plugin system & lifecycle
97
+ ├── prompts/ Prompt registry & templates
98
+ ├── protocols/ Agent contracts & MCP
99
+ ├── queue/ Task queue & rate limiter
100
+ ├── security/ Guardrails, auditor, sandbox
101
+ ├── server/ MCP server
102
+ ├── storage/ Storage backend abstraction
103
+ ├── subagent/ Sub-agent management
104
+ ├── swarm/ Swarm coordination & patterns
105
+ ├── testing/ Test fixtures & mocks
106
+ ├── tools/ Tool registry, function calling, orchestrator, generator
107
+ ├── vectorstore/ Vector database abstraction
108
+ └── workflows/ Workflow engine & templates
109
+ ```
110
+
111
+ ## Key Features
112
+
113
+ ### v0.99 New
114
+ | Module | Description |
115
+ |--------|-------------|
116
+ | `TokenCounter` | Model-aware token counting + cost estimation for OpenAI/Anthropic/Gemini/Llama |
117
+ | `SemanticMemoryRetriever` | Hybrid memory search (semantic + BM25 keyword) across conversation & long-term memory |
118
+ | `ConfigPresets` | 8 ready-to-use config profiles: development, production, testing, budget, creative, deep_research, gemini_fast, gemini_pro |
119
+
120
+ ### Core Features (v0.95 - v0.98)
121
+ | Module | Description |
122
+ |--------|-------------|
123
+ | `ToolRegistry` | Function calling pipeline with JSON Schema validation & batch execution |
124
+ | `WorkflowTemplate` | Declarative workflow templates (YAML/JSON) with 6 step types |
125
+ | `ResponseCache` | TTL cache with LRU eviction & 3 key strategies |
126
+ | `AgentGraph` | DAG execution engine with Mermaid export |
127
+ | `StreamingAgent` | SSE real-time streaming with session management |
128
+ | `ConversationMemory` | 4 window strategies: Sliding, TokenAware, Importance, Hybrid |
129
+ | `AsyncAgentLoop` | Async concurrent execution with p50/p95/p99 latency stats |
130
+ | `SwarmPatterns` | 5 collaboration topologies: Broadcast, Pipeline, Hierarchical, Consensus, RoundRobin |
131
+
132
+ ### Infrastructure (v0.50 - v0.95)
133
+ - **Model Router**: Unified routing across OpenAI, Anthropic, Gemini, Llama
134
+ - **Guardrails**: Content safety, PII sanitization, content hashing
135
+ - **Rate Limiter**: Token bucket, sliding window, concurrency limiter
136
+ - **Circuit Breaker**: Resilience patterns with configurable retry
137
+ - **Cost Analytics**: Budget alerts, cost breakdown, session tracking
138
+ - **Health Checks**: OpenAI connectivity, vector store, disk space, memory
139
+ - **Security Auditor**: Full security audit with severity-based findings
140
+ - **Docker/K8s**: Auto-generate Dockerfile + docker-compose
141
+ - **CI/CD**: GitHub Actions with multi-OS, 3 Python versions, lint, bandit security scan
142
+
143
+ ## Config Presets
144
+
145
+ ```python
146
+ from agentos import get_preset, list_presets
147
+
148
+ # List all presets
149
+ for name in list_presets():
150
+ p = get_preset(name)
151
+ print(f"{p.name}: {p.model} (T={p.temperature})")
152
+
153
+ # Apply a preset
154
+ config = {"max_iterations": 15}
155
+ from agentos import apply_preset
156
+ apply_preset("production", config) # Overrides with prod defaults
157
+ ```
158
+
159
+ | Preset | Model | Temp | Use Case |
160
+ |--------|-------|------|----------|
161
+ | `development` | gpt-4o-mini | 0.8 | Local dev, fast iteration |
162
+ | `production` | gpt-4o | 0.3 | Deployed services |
163
+ | `testing` | gpt-4o-mini | 0.0 | CI/CD tests |
164
+ | `budget` | gpt-4o-mini | 0.5 | Cost-sensitive |
165
+ | `creative` | claude-3.5-sonnet | 0.95 | Creative writing |
166
+ | `deep_research` | claude-3-opus | 0.4 | Research & analysis |
167
+ | `gemini_fast` | gemini-2.0-flash | 0.7 | High throughput |
168
+ | `gemini_pro` | gemini-1.5-pro | 0.5 | 2M context window |
169
+
170
+ ## Token Counting
171
+
172
+ ```python
173
+ from agentos import TokenCounter
174
+
175
+ counter = TokenCounter()
176
+ tokens = counter.count("Hello, agent world!", model="gpt-4o")
177
+ print(f"Tokens: {counter.format_tokens(tokens)}")
178
+
179
+ messages = [
180
+ {"role": "system", "content": "You are a helpful assistant."},
181
+ {"role": "user", "content": "Explain quantum computing in 3 sentences."},
182
+ ]
183
+ total = counter.count_messages(messages, model="gpt-4o")
184
+ cost = counter.estimate_cost(total)
185
+ print(f"Cost: {counter.format_cost(cost)}")
186
+ ```
187
+
188
+ ## Memory Retrieval
189
+
190
+ ```python
191
+ from agentos import SemanticMemoryRetriever, RetrievalStrategy, MemoryEntry
192
+
193
+ retriever = SemanticMemoryRetriever()
194
+
195
+ # Index memories
196
+ retriever.index([
197
+ MemoryEntry(id="1", content="Deployed to production at 3pm UTC", source="long_term"),
198
+ MemoryEntry(id="2", content="User asked about GDPR compliance", source="conversation"),
199
+ MemoryEntry(id="3", content="Database migration scheduled for Friday", source="conversation"),
200
+ ])
201
+
202
+ # Hybrid search (semantic + keyword)
203
+ results = retriever.retrieve("When is the next deployment?")
204
+ for r in results:
205
+ print(f"[{r.score:.2f}] {r.entry.content}")
206
+ ```
207
+
208
+ ## Requirements
209
+
210
+ - Python >= 3.11
211
+ - openai >= 1.0.0
212
+ - httpx >= 0.27.0
213
+ - pyyaml >= 6.0
214
+ - pydantic >= 2.0
215
+ - fastapi >= 0.110.0 (optional, for API server)
216
+
217
+ ## License
218
+
219
+ MIT
@@ -0,0 +1,182 @@
1
+ # AgentOS v0.99
2
+
3
+ **Agent Operating System** — Production-ready multi-model agent framework.
4
+
5
+ ## Overview
6
+
7
+ AgentOS is a modular, twelve-layered framework for building, orchestrating, and deploying AI agents. It supports OpenAI, Anthropic, Google Gemini, and open-source models through a unified routing layer.
8
+
9
+ ## Quick Start
10
+
11
+ ```bash
12
+ pip install agentos
13
+
14
+ # Create a new project
15
+ agentos init my-agent
16
+
17
+ # Start the API server
18
+ agentos serve --preset production
19
+ ```
20
+
21
+ ```python
22
+ from agentos import AgentLoop, LoopConfig, ModelRouter
23
+
24
+ loop = AgentLoop(
25
+ config=LoopConfig(model="gpt-4o", max_iterations=10),
26
+ router=ModelRouter(),
27
+ )
28
+ result = loop.run("Summarize the key features of AgentOS.")
29
+ print(result.output)
30
+ ```
31
+
32
+ ## Architecture
33
+
34
+ ```
35
+ agentos/
36
+ ├── agents/ Agent marketplace & skill registry
37
+ ├── api/ REST API server, middleware, streaming, versioning
38
+ ├── benchmarks/ Benchmarking & performance testing
39
+ ├── cache/ LLM cache, response cache, embedding cache
40
+ ├── cli/ CLI scaffolding & serve commands
41
+ ├── comm/ Inter-agent communication (blackboard, event bus)
42
+ ├── config/ Configuration loader, validator, presets
43
+ ├── core/ Agent loop, state machine, async loop, streaming
44
+ ├── cost/ Cost tracking, token counting
45
+ ├── deployment/ Docker & Kubernetes deployment
46
+ ├── docs/ API documentation generator
47
+ ├── errors/ Error formatting & handling
48
+ ├── evaluation/ Scoring & evaluation metrics
49
+ ├── experiments/ A/B experiment runner
50
+ ├── feedback/ User feedback collection & learning
51
+ ├── health/ Health checks & monitoring
52
+ ├── logging/ Structured logging
53
+ ├── memory/ Short-term, long-term, working memory, summarizer, retriever
54
+ ├── models/ Model router, resilience, backends (Gemini)
55
+ ├── monitoring/ Alerting & metrics
56
+ ├── multimodal/ Image, audio, document processing
57
+ ├── observability/ Cost analytics, metrics, tracing
58
+ ├── orchestration/ DAG orchestrator, agent graph execution
59
+ ├── plugins/ Plugin system & lifecycle
60
+ ├── prompts/ Prompt registry & templates
61
+ ├── protocols/ Agent contracts & MCP
62
+ ├── queue/ Task queue & rate limiter
63
+ ├── security/ Guardrails, auditor, sandbox
64
+ ├── server/ MCP server
65
+ ├── storage/ Storage backend abstraction
66
+ ├── subagent/ Sub-agent management
67
+ ├── swarm/ Swarm coordination & patterns
68
+ ├── testing/ Test fixtures & mocks
69
+ ├── tools/ Tool registry, function calling, orchestrator, generator
70
+ ├── vectorstore/ Vector database abstraction
71
+ └── workflows/ Workflow engine & templates
72
+ ```
73
+
74
+ ## Key Features
75
+
76
+ ### v0.99 New
77
+ | Module | Description |
78
+ |--------|-------------|
79
+ | `TokenCounter` | Model-aware token counting + cost estimation for OpenAI/Anthropic/Gemini/Llama |
80
+ | `SemanticMemoryRetriever` | Hybrid memory search (semantic + BM25 keyword) across conversation & long-term memory |
81
+ | `ConfigPresets` | 8 ready-to-use config profiles: development, production, testing, budget, creative, deep_research, gemini_fast, gemini_pro |
82
+
83
+ ### Core Features (v0.95 - v0.98)
84
+ | Module | Description |
85
+ |--------|-------------|
86
+ | `ToolRegistry` | Function calling pipeline with JSON Schema validation & batch execution |
87
+ | `WorkflowTemplate` | Declarative workflow templates (YAML/JSON) with 6 step types |
88
+ | `ResponseCache` | TTL cache with LRU eviction & 3 key strategies |
89
+ | `AgentGraph` | DAG execution engine with Mermaid export |
90
+ | `StreamingAgent` | SSE real-time streaming with session management |
91
+ | `ConversationMemory` | 4 window strategies: Sliding, TokenAware, Importance, Hybrid |
92
+ | `AsyncAgentLoop` | Async concurrent execution with p50/p95/p99 latency stats |
93
+ | `SwarmPatterns` | 5 collaboration topologies: Broadcast, Pipeline, Hierarchical, Consensus, RoundRobin |
94
+
95
+ ### Infrastructure (v0.50 - v0.95)
96
+ - **Model Router**: Unified routing across OpenAI, Anthropic, Gemini, Llama
97
+ - **Guardrails**: Content safety, PII sanitization, content hashing
98
+ - **Rate Limiter**: Token bucket, sliding window, concurrency limiter
99
+ - **Circuit Breaker**: Resilience patterns with configurable retry
100
+ - **Cost Analytics**: Budget alerts, cost breakdown, session tracking
101
+ - **Health Checks**: OpenAI connectivity, vector store, disk space, memory
102
+ - **Security Auditor**: Full security audit with severity-based findings
103
+ - **Docker/K8s**: Auto-generate Dockerfile + docker-compose
104
+ - **CI/CD**: GitHub Actions with multi-OS, 3 Python versions, lint, bandit security scan
105
+
106
+ ## Config Presets
107
+
108
+ ```python
109
+ from agentos import get_preset, list_presets
110
+
111
+ # List all presets
112
+ for name in list_presets():
113
+ p = get_preset(name)
114
+ print(f"{p.name}: {p.model} (T={p.temperature})")
115
+
116
+ # Apply a preset
117
+ config = {"max_iterations": 15}
118
+ from agentos import apply_preset
119
+ apply_preset("production", config) # Overrides with prod defaults
120
+ ```
121
+
122
+ | Preset | Model | Temp | Use Case |
123
+ |--------|-------|------|----------|
124
+ | `development` | gpt-4o-mini | 0.8 | Local dev, fast iteration |
125
+ | `production` | gpt-4o | 0.3 | Deployed services |
126
+ | `testing` | gpt-4o-mini | 0.0 | CI/CD tests |
127
+ | `budget` | gpt-4o-mini | 0.5 | Cost-sensitive |
128
+ | `creative` | claude-3.5-sonnet | 0.95 | Creative writing |
129
+ | `deep_research` | claude-3-opus | 0.4 | Research & analysis |
130
+ | `gemini_fast` | gemini-2.0-flash | 0.7 | High throughput |
131
+ | `gemini_pro` | gemini-1.5-pro | 0.5 | 2M context window |
132
+
133
+ ## Token Counting
134
+
135
+ ```python
136
+ from agentos import TokenCounter
137
+
138
+ counter = TokenCounter()
139
+ tokens = counter.count("Hello, agent world!", model="gpt-4o")
140
+ print(f"Tokens: {counter.format_tokens(tokens)}")
141
+
142
+ messages = [
143
+ {"role": "system", "content": "You are a helpful assistant."},
144
+ {"role": "user", "content": "Explain quantum computing in 3 sentences."},
145
+ ]
146
+ total = counter.count_messages(messages, model="gpt-4o")
147
+ cost = counter.estimate_cost(total)
148
+ print(f"Cost: {counter.format_cost(cost)}")
149
+ ```
150
+
151
+ ## Memory Retrieval
152
+
153
+ ```python
154
+ from agentos import SemanticMemoryRetriever, RetrievalStrategy, MemoryEntry
155
+
156
+ retriever = SemanticMemoryRetriever()
157
+
158
+ # Index memories
159
+ retriever.index([
160
+ MemoryEntry(id="1", content="Deployed to production at 3pm UTC", source="long_term"),
161
+ MemoryEntry(id="2", content="User asked about GDPR compliance", source="conversation"),
162
+ MemoryEntry(id="3", content="Database migration scheduled for Friday", source="conversation"),
163
+ ])
164
+
165
+ # Hybrid search (semantic + keyword)
166
+ results = retriever.retrieve("When is the next deployment?")
167
+ for r in results:
168
+ print(f"[{r.score:.2f}] {r.entry.content}")
169
+ ```
170
+
171
+ ## Requirements
172
+
173
+ - Python >= 3.11
174
+ - openai >= 1.0.0
175
+ - httpx >= 0.27.0
176
+ - pyyaml >= 6.0
177
+ - pydantic >= 2.0
178
+ - fastapi >= 0.110.0 (optional, for API server)
179
+
180
+ ## License
181
+
182
+ MIT
@@ -0,0 +1,180 @@
1
+ """
2
+ AgentOS v0.99 — 多模型通用 Agent 框架。
3
+
4
+ 十二层架构 + 生产就绪增强 + CI/CD 发布管线。
5
+ v0.99新增: TokenCounter(模型感知Token计数+成本估算+多Provider定价) + SemanticMemoryRetriever(语义记忆检索+BM25关键词+混合搜索) + ConfigPresets(8种场景预设配置: Development/Production/Budget/Creative/Research等)。
6
+ v0.98基线: ToolRegistry + WorkflowTemplate + ResponseCache。
7
+ """
8
+
9
+ __version__ = "0.99.0"
10
+
11
+ from agentos.core.loop import AgentLoop, AgentResult, LoopConfig, LoopState, MaxIterationsExceeded, StepTimeoutError, ReflectionResult, HumanInterruptNeeded, StepResult
12
+ from agentos.cost.tracker import CostTracker, PRICING
13
+ from agentos.agents.market import AgentMarket, AgentSkill, AgentCategory
14
+ from agentos.prompts.manager import PromptRegistry, PromptTemplate, DEFAULT_PROMPTS
15
+ from agentos.feedback.learner import FeedbackCollector, FeedbackRecord, FeedbackType, PreferenceLearner
16
+ from agentos.vectorstore.db import FAISSVectorStore, ChromaVectorStore, VectorEntry
17
+ from agentos.api.server import AgentAPI
18
+ from agentos.swarm.coordinator import SwarmCoordinator, SwarmTopology, AgentRole, SwarmTask, TaskResult, SwarmResult, MessageBus
19
+ from agentos.comm.layer import CommunicationLayer, AgentMessage, ChannelType, Blackboard, EventBus, AgentMailbox
20
+ from agentos.server.mcp_server import MCPServer, MCPClient, MCPServerConfig, MCPTool, MCPResource, MCPPrompt
21
+ from agentos.queue.task_queue import TaskQueue, ScheduledTask, TaskState, TaskPriority, MemoryQueue
22
+ from agentos.cache.llm_cache import LLMCache, LRUCache, SemanticCache, CacheStats
23
+ from agentos.multimodal.manager import MultimodalManager, MultimodalBlock, Modality, ImageProcessor, AudioProcessor, DocumentParser
24
+ from agentos.experiments.runner import ExperimentRunner, ExperimentConfig, ExperimentReport, PromptVariant, TrialResult, Evaluator
25
+ from agentos.models.router import ModelRouter, ModelConfig, ModelSpec, ModelResponse, RECOMMENDED_CONFIG
26
+ from agentos.tools.generator import OpenAPIToolGenerator, GeneratedTool
27
+ from agentos.cache.embedder import BaseEmbedder, OpenAIEmbedder, LocalEmbedder, CohereEmbedder, get_embedder, cosine_similarity
28
+ from agentos.security.guard import Guardrails, GuardResult, ContentRisk, PIISanitizer, ContentHasher
29
+ from agentos.queue.rate_limiter import RateLimiter, RateLimitConfig, TokenBucket, SlidingWindow, ConcurrencyLimiter, QuotaManager
30
+ from agentos.core.state_machine import AgentStateMachine, AgentState, StateMachineConfig, StateTransition
31
+ from agentos.memory.summarizer import MemorySummarizer, MemoryChunk, ConversationMemory, ImportanceScorer
32
+ from agentos.models.resilience import CircuitBreaker, CircuitBreakerConfig, RetryConfig, retry_with_backoff, ResilientCall
33
+ from agentos.config.loader import (
34
+ AgentOSConfig, ModelConfig, LoopCfg, MemoryCfg,
35
+ SecurityCfg, ObservabilityCfg, ReflectionCfg, CostCfg,
36
+ FeedbackCfg, APICfg, SwarmCfg, QueueCfg, CacheCfg,
37
+ ExperimentCfg, MultimodalCfg, MCPServerCfg,
38
+ GuardrailsCfg, RateLimitCfg, StateMachineCfg, ResilienceCfg,
39
+ PluginsCfg, GeminiCfg, ContractsCfg, OrchestratorCfg, ScorerCfg,
40
+ BenchmarkCfg, HealthCfg, AuditCfg, DeployCfg, MiddlewareCfg,
41
+ load_config,
42
+ )
43
+
44
+ # v0.70 新增模块
45
+ from agentos.observability.cost_analytics import CostAnalytics, BudgetAlert, CostBreakdown, CostSession
46
+ from agentos.observability.metrics import MetricsCollector, MetricSnapshot, Counter, Gauge, Histogram
47
+ from agentos.plugins.registry import PluginRegistry, PluginManifest, RegisteredPlugin
48
+ from agentos.plugins.loader import PluginLoader, PluginLoadError
49
+ from agentos.plugins.lifecycle import LifecyclePlugin, LifecycleManager, PluginHealth
50
+ from agentos.tools.orchestrator import ToolOrchestrator, DAGSpec, DAGBuilder, DAGResult, NodeResult, NodeState, RetryPolicy, chain_builder, parallel_then_merge, if_then_else
51
+ from agentos.protocols.contracts import ContractRegistry, AgentContract, AgentCapability, CapabilityDomain, CapabilityMatcher, MatchScore, QoSLevel
52
+ from agentos.evaluation.scorers import CompositeScorer, ScoringStrategy, ScoreResult, rouge_l, bleu, semantic_similarity, STRATEGY_CODE_GEN, STRATEGY_QA, STRATEGY_SUMMARY, STRATEGY_TRANSLATION
53
+
54
+ # v0.80 模块
55
+ from agentos.errors.handler import HumanError, ErrorFormatter, ErrorContext, ErrorCategory, format_error, friendly_error
56
+ from agentos.docs.generator import DocGenerator, DocConfig as DocGenConfig, generate_api_docs, generate_quickstart
57
+ from agentos.cli.init import scaffold
58
+ from agentos.cli.serve import ServeConfig, start_api_server
59
+ from agentos.benchmarks.runner import BenchmarkRunner, BenchmarkConfig, BenchmarkReport, BenchmarkScenario, run_benchmark
60
+
61
+ # v0.90 新增模块
62
+ from agentos.security.auditor import SecurityAuditor, AuditReport, AuditFinding, AuditSeverity, full_audit
63
+ from agentos.deployment.docker import DockerConfig, ComposeConfig, ComposeService, generate_dockerfile, generate_docker_compose, write_deployment_files
64
+ from agentos.api.middleware import MiddlewareStack, CORSMiddleware, CORSConfig, AuthMiddleware, AuthConfig, RequestLogMiddleware, RequestIDMiddleware, RequestContext
65
+ from agentos.api.versioning import VersionNegotiator, VersionConfig, APIVersion, VersionStrategy
66
+ from agentos.monitoring import Alert, AlertEvaluator, AlertRule, AlertSeverity, AlertState, MonitoringConfig, WebhookConfig, WebhookDispatcher
67
+ from agentos.config.validator import ValidationResult, ValidationIssue, ValidationLevel, validate_config, validate_config_file
68
+ from agentos.health import HealthChecker, HealthStatus, HealthCheck, CheckResult, create_default_health_checker, check_openai_connectivity, check_vectorstore_health, check_disk_space, check_memory
69
+ from agentos.logging import JSONFormatter, TraceContext, setup_structured_logging, get_logger, audit_log
70
+
71
+ # v0.95 测试基础设施
72
+ from agentos.testing import MockLLMClient, MockLLMResponse, mock_openai_client, mock_model_response, sample_config, sample_loop_config, temp_workspace, mock_memory_store, sample_agent_state, sample_audit_report, sample_health_status, sample_docker_config, sample_middleware_stack, sample_alert_config
73
+
74
+ # v0.96 异步核心 + 增强协作
75
+ from agentos.core.async_loop import AsyncAgentLoop, AsyncLoopConfig, AsyncInvocationResult, AsyncContextManager
76
+ from agentos.swarm.patterns import SwarmPatterns, CollaborationConfig, CollaborationResult, MemberResult, Topology
77
+
78
+ # v0.97 Graph执行 + 流式 + 对话记忆
79
+ from agentos.orchestration.graph_executor import AgentGraph, GraphNode, GraphResult, GraphNodeState, GraphRecipe
80
+ from agentos.api.streaming import StreamingAgent, StreamEvent, StreamSession
81
+ from agentos.memory.conversation import ConversationMemory, WindowConfig, WindowStrategy, ConversationTurn
82
+
83
+ # v0.98 函数调用 + 工作流模板 + 响应缓存
84
+ from agentos.tools.function_calling import ToolRegistry, ToolSchema, ToolCall, ToolResult
85
+ from agentos.workflows.templates import WorkflowTemplate, WorkflowStep, StepType, RetryPolicy, BUILTIN_TEMPLATES
86
+ from agentos.cache.response_cache import ResponseCache, CacheEntry, CacheStats, CacheKeyStrategy
87
+
88
+ # v0.99 Token计数 + 语义记忆检索 + 配置预设
89
+ from agentos.cost.token_counter import TokenCounter, TokenCount, CostEstimate, ModelFamily
90
+ from agentos.memory.retriever import SemanticMemoryRetriever, RetrievalStrategy, RetrievalResult, MemoryEntry as MemEntry
91
+ from agentos.config.presets import AgentOSPreset, PRESETS, get_preset, list_presets, get_preset_names, apply_preset
92
+
93
+ __all__ = [
94
+ "__version__",
95
+ "AgentLoop", "AgentResult", "LoopConfig", "LoopState",
96
+ "MaxIterationsExceeded", "StepTimeoutError", "ReflectionResult", "HumanInterruptNeeded", "StepResult",
97
+ "CostTracker", "PRICING",
98
+ "AgentMarket", "AgentSkill", "AgentCategory",
99
+ "PromptRegistry", "PromptTemplate", "DEFAULT_PROMPTS",
100
+ "FeedbackCollector", "FeedbackRecord", "FeedbackType", "PreferenceLearner",
101
+ "FAISSVectorStore", "ChromaVectorStore", "VectorEntry",
102
+ "AgentAPI",
103
+ # v0.40
104
+ "SwarmCoordinator", "SwarmTopology", "AgentRole", "SwarmTask", "TaskResult", "SwarmResult", "MessageBus",
105
+ "CommunicationLayer", "AgentMessage", "ChannelType", "Blackboard", "EventBus", "AgentMailbox",
106
+ "MCPServer", "MCPClient", "MCPServerConfig", "MCPTool", "MCPResource", "MCPPrompt",
107
+ "TaskQueue", "ScheduledTask", "TaskState", "TaskPriority", "MemoryQueue",
108
+ "LLMCache", "LRUCache", "SemanticCache", "CacheStats",
109
+ "MultimodalManager", "MultimodalBlock", "Modality", "ImageProcessor", "AudioProcessor", "DocumentParser",
110
+ "ExperimentRunner", "ExperimentConfig", "ExperimentReport", "PromptVariant", "TrialResult", "Evaluator",
111
+ # v0.50
112
+ "ModelRouter", "ModelConfig", "ModelSpec", "ModelResponse", "RECOMMENDED_CONFIG",
113
+ "OpenAPIToolGenerator", "GeneratedTool",
114
+ "BaseEmbedder", "OpenAIEmbedder", "LocalEmbedder", "CohereEmbedder", "get_embedder", "cosine_similarity",
115
+ # v0.60
116
+ "Guardrails", "GuardResult", "ContentRisk", "PIISanitizer", "ContentHasher",
117
+ "RateLimiter", "RateLimitConfig", "TokenBucket", "SlidingWindow", "ConcurrencyLimiter", "QuotaManager",
118
+ "AgentStateMachine", "AgentState", "StateMachineConfig", "StateTransition",
119
+ "MemorySummarizer", "MemoryChunk", "ConversationMemory", "ImportanceScorer",
120
+ "CircuitBreaker", "CircuitBreakerConfig", "RetryConfig", "retry_with_backoff", "ResilientCall",
121
+ "AgentOSConfig", "LoopCfg", "MemoryCfg",
122
+ "SecurityCfg", "ObservabilityCfg", "ReflectionCfg", "CostCfg",
123
+ "FeedbackCfg", "APICfg", "SwarmCfg", "QueueCfg", "CacheCfg",
124
+ "ExperimentCfg", "MultimodalCfg", "MCPServerCfg",
125
+ "GuardrailsCfg", "RateLimitCfg", "StateMachineCfg", "ResilienceCfg",
126
+ # v0.70 config
127
+ "PluginsCfg", "GeminiCfg", "ContractsCfg", "OrchestratorCfg", "ScorerCfg",
128
+ "BenchmarkCfg",
129
+ "HealthCfg", "AuditCfg", "DeployCfg", "MiddlewareCfg",
130
+ "load_config",
131
+ # v0.70 modules
132
+ "CostAnalytics", "BudgetAlert", "CostBreakdown", "CostSession",
133
+ "MetricsCollector", "MetricSnapshot", "Counter", "Gauge", "Histogram",
134
+ "PluginRegistry", "PluginManifest", "RegisteredPlugin",
135
+ "PluginLoader", "PluginLoadError",
136
+ "LifecyclePlugin", "LifecycleManager", "PluginHealth",
137
+ "ToolOrchestrator", "DAGSpec", "DAGBuilder", "DAGResult", "NodeResult", "NodeState", "RetryPolicy",
138
+ "chain_builder", "parallel_then_merge", "if_then_else",
139
+ "ContractRegistry", "AgentContract", "AgentCapability", "CapabilityDomain", "CapabilityMatcher", "MatchScore", "QoSLevel",
140
+ "CompositeScorer", "ScoringStrategy", "ScoreResult",
141
+ "rouge_l", "bleu", "semantic_similarity",
142
+ "STRATEGY_CODE_GEN", "STRATEGY_QA", "STRATEGY_SUMMARY", "STRATEGY_TRANSLATION",
143
+ # v0.80 modules
144
+ "HumanError", "ErrorFormatter", "ErrorContext", "ErrorCategory",
145
+ "format_error", "friendly_error",
146
+ "DocGenerator", "DocGenConfig", "generate_api_docs", "generate_quickstart",
147
+ "scaffold",
148
+ "ServeConfig", "start_api_server",
149
+ "BenchmarkRunner", "BenchmarkConfig", "BenchmarkReport", "BenchmarkScenario", "run_benchmark",
150
+ # v0.90 modules
151
+ "SecurityAuditor", "AuditReport", "AuditFinding", "AuditSeverity", "full_audit",
152
+ "DockerConfig", "ComposeConfig", "ComposeService", "generate_dockerfile", "generate_docker_compose", "write_deployment_files",
153
+ "MiddlewareStack", "CORSMiddleware", "CORSConfig", "AuthMiddleware", "AuthConfig", "RequestLogMiddleware", "RequestIDMiddleware", "RequestContext",
154
+ "VersionNegotiator", "VersionConfig", "APIVersion", "VersionStrategy",
155
+ "Alert", "AlertEvaluator", "AlertRule", "AlertSeverity", "AlertState", "MonitoringConfig", "WebhookConfig", "WebhookDispatcher",
156
+ "ValidationResult", "ValidationIssue", "ValidationLevel", "validate_config", "validate_config_file",
157
+ "HealthChecker", "HealthStatus", "HealthCheck", "CheckResult", "create_default_health_checker",
158
+ "check_openai_connectivity", "check_vectorstore_health", "check_disk_space", "check_memory",
159
+ "JSONFormatter", "TraceContext", "setup_structured_logging", "get_logger", "audit_log",
160
+ # v0.95 testing
161
+ "MockLLMClient", "MockLLMResponse", "mock_openai_client", "mock_model_response",
162
+ "sample_config", "sample_loop_config", "temp_workspace", "mock_memory_store",
163
+ "sample_agent_state", "sample_audit_report", "sample_health_status",
164
+ "sample_docker_config", "sample_middleware_stack", "sample_alert_config",
165
+ # v0.96 async + swarm patterns
166
+ "AsyncAgentLoop", "AsyncLoopConfig", "AsyncInvocationResult", "AsyncContextManager",
167
+ "SwarmPatterns", "CollaborationConfig", "CollaborationResult", "MemberResult", "Topology",
168
+ # v0.97 graph + streaming + conversation
169
+ "AgentGraph", "GraphNode", "GraphResult", "GraphNodeState", "GraphRecipe",
170
+ "StreamingAgent", "StreamEvent", "StreamSession",
171
+ "ConversationMemory", "WindowConfig", "WindowStrategy", "ConversationTurn",
172
+ # v0.98 function calling + workflow templates + response cache
173
+ "ToolRegistry", "ToolSchema", "ToolCall", "ToolResult",
174
+ "WorkflowTemplate", "WorkflowStep", "StepType", "RetryPolicy", "BUILTIN_TEMPLATES",
175
+ "ResponseCache", "CacheEntry", "CacheKeyStrategy",
176
+ # v0.99 token counter + semantic retriever + config presets
177
+ "TokenCounter", "TokenCount", "CostEstimate", "ModelFamily",
178
+ "SemanticMemoryRetriever", "RetrievalStrategy", "RetrievalResult", "MemEntry",
179
+ "AgentOSPreset", "PRESETS", "get_preset", "list_presets", "get_preset_names", "apply_preset",
180
+ ]