orqest 0.8.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 (166) hide show
  1. orqest-0.8.0/LICENSE +21 -0
  2. orqest-0.8.0/PKG-INFO +148 -0
  3. orqest-0.8.0/README.md +109 -0
  4. orqest-0.8.0/orqest/__init__.py +50 -0
  5. orqest-0.8.0/orqest/agents/__init__.py +27 -0
  6. orqest-0.8.0/orqest/agents/base_agent.py +520 -0
  7. orqest-0.8.0/orqest/agents/compound_tool.py +156 -0
  8. orqest-0.8.0/orqest/agents/context_manager.py +283 -0
  9. orqest-0.8.0/orqest/agents/retry.py +134 -0
  10. orqest-0.8.0/orqest/agents/session_state.py +87 -0
  11. orqest-0.8.0/orqest/agents/state.py +31 -0
  12. orqest-0.8.0/orqest/agents/tool_wrapper.py +51 -0
  13. orqest-0.8.0/orqest/autonomy/__init__.py +48 -0
  14. orqest-0.8.0/orqest/autonomy/factory.py +254 -0
  15. orqest-0.8.0/orqest/autonomy/meta.py +615 -0
  16. orqest-0.8.0/orqest/autonomy/registry.py +202 -0
  17. orqest-0.8.0/orqest/autonomy/runtime.py +602 -0
  18. orqest-0.8.0/orqest/autonomy/spec.py +149 -0
  19. orqest-0.8.0/orqest/autonomy/tool_factory.py +185 -0
  20. orqest-0.8.0/orqest/autonomy/topology_orchestrator.py +244 -0
  21. orqest-0.8.0/orqest/benchmarks/__init__.py +17 -0
  22. orqest-0.8.0/orqest/benchmarks/bird/__init__.py +29 -0
  23. orqest-0.8.0/orqest/benchmarks/bird/adas/__init__.py +34 -0
  24. orqest-0.8.0/orqest/benchmarks/bird/adas/evaluator.py +145 -0
  25. orqest-0.8.0/orqest/benchmarks/bird/adas/gepa.py +331 -0
  26. orqest-0.8.0/orqest/benchmarks/bird/adas/registry.py +304 -0
  27. orqest-0.8.0/orqest/benchmarks/bird/adas/runner.py +339 -0
  28. orqest-0.8.0/orqest/benchmarks/bird/adas/seed.py +42 -0
  29. orqest-0.8.0/orqest/benchmarks/bird/adas/state.py +144 -0
  30. orqest-0.8.0/orqest/benchmarks/bird/baseline.py +362 -0
  31. orqest-0.8.0/orqest/benchmarks/bird/dataset.py +193 -0
  32. orqest-0.8.0/orqest/benchmarks/spider/__init__.py +37 -0
  33. orqest-0.8.0/orqest/benchmarks/spider/baseline.py +331 -0
  34. orqest-0.8.0/orqest/benchmarks/spider/dataset.py +183 -0
  35. orqest-0.8.0/orqest/benchmarks/spider/harness.py +169 -0
  36. orqest-0.8.0/orqest/compound/__init__.py +5 -0
  37. orqest-0.8.0/orqest/compound/sub_agent_tool.py +261 -0
  38. orqest-0.8.0/orqest/config.py +69 -0
  39. orqest-0.8.0/orqest/healing/__init__.py +49 -0
  40. orqest-0.8.0/orqest/healing/config.py +60 -0
  41. orqest-0.8.0/orqest/healing/fallback.py +248 -0
  42. orqest-0.8.0/orqest/healing/loop.py +87 -0
  43. orqest-0.8.0/orqest/healing/recovery.py +153 -0
  44. orqest-0.8.0/orqest/healing/regression.py +81 -0
  45. orqest-0.8.0/orqest/healing/runner.py +161 -0
  46. orqest-0.8.0/orqest/healing/stall.py +79 -0
  47. orqest-0.8.0/orqest/healing/watchdog.py +55 -0
  48. orqest-0.8.0/orqest/hooks.py +253 -0
  49. orqest-0.8.0/orqest/io_utils/__init__.py +6 -0
  50. orqest-0.8.0/orqest/io_utils/load_sys_prompt.py +59 -0
  51. orqest-0.8.0/orqest/mcp/__init__.py +36 -0
  52. orqest-0.8.0/orqest/mcp/adapter.py +94 -0
  53. orqest-0.8.0/orqest/mcp/client.py +373 -0
  54. orqest-0.8.0/orqest/mcp/config.py +52 -0
  55. orqest-0.8.0/orqest/mcp/discovery.py +232 -0
  56. orqest-0.8.0/orqest/mcp/discovery_hook.py +89 -0
  57. orqest-0.8.0/orqest/mcp/permission.py +50 -0
  58. orqest-0.8.0/orqest/mcp/server.py +116 -0
  59. orqest-0.8.0/orqest/memory/__init__.py +44 -0
  60. orqest-0.8.0/orqest/memory/config.py +56 -0
  61. orqest-0.8.0/orqest/memory/local.py +447 -0
  62. orqest-0.8.0/orqest/memory/store.py +164 -0
  63. orqest-0.8.0/orqest/memory/strategies.py +417 -0
  64. orqest-0.8.0/orqest/metacognition/__init__.py +39 -0
  65. orqest-0.8.0/orqest/metacognition/config.py +35 -0
  66. orqest-0.8.0/orqest/metacognition/enriched.py +59 -0
  67. orqest-0.8.0/orqest/metacognition/hook.py +74 -0
  68. orqest-0.8.0/orqest/metacognition/protocol.py +318 -0
  69. orqest-0.8.0/orqest/metacognition/salience.py +77 -0
  70. orqest-0.8.0/orqest/observability/__init__.py +20 -0
  71. orqest-0.8.0/orqest/observability/event_bus_hook.py +155 -0
  72. orqest-0.8.0/orqest/observability/events.py +108 -0
  73. orqest-0.8.0/orqest/observability/sse_sidecar.py +123 -0
  74. orqest-0.8.0/orqest/observability/tracer.py +140 -0
  75. orqest-0.8.0/orqest/optimization/__init__.py +89 -0
  76. orqest-0.8.0/orqest/optimization/_compat.py +64 -0
  77. orqest-0.8.0/orqest/optimization/adapter.py +283 -0
  78. orqest-0.8.0/orqest/optimization/apply.py +153 -0
  79. orqest-0.8.0/orqest/optimization/bundle.py +208 -0
  80. orqest-0.8.0/orqest/optimization/config.py +119 -0
  81. orqest-0.8.0/orqest/optimization/evaluator.py +296 -0
  82. orqest-0.8.0/orqest/optimization/genome.py +166 -0
  83. orqest-0.8.0/orqest/optimization/meta_agent.py +752 -0
  84. orqest-0.8.0/orqest/optimization/runner.py +321 -0
  85. orqest-0.8.0/orqest/optimization/topology.py +299 -0
  86. orqest-0.8.0/orqest/orchestration/__init__.py +42 -0
  87. orqest-0.8.0/orqest/orchestration/hydrate.py +459 -0
  88. orqest-0.8.0/orqest/orchestration/loop.py +350 -0
  89. orqest-0.8.0/orqest/orchestration/parallel.py +118 -0
  90. orqest-0.8.0/orqest/orchestration/pipeline.py +168 -0
  91. orqest-0.8.0/orqest/orchestration/router.py +141 -0
  92. orqest-0.8.0/orqest/orchestration/spec.py +264 -0
  93. orqest-0.8.0/orqest/orchestration/step.py +128 -0
  94. orqest-0.8.0/orqest/orchestration/types.py +56 -0
  95. orqest-0.8.0/orqest/plan/__init__.py +15 -0
  96. orqest-0.8.0/orqest/plan/execution_plan.py +248 -0
  97. orqest-0.8.0/orqest/sandbox/__init__.py +42 -0
  98. orqest-0.8.0/orqest/sandbox/_compat.py +57 -0
  99. orqest-0.8.0/orqest/sandbox/_static.py +169 -0
  100. orqest-0.8.0/orqest/sandbox/docker.py +478 -0
  101. orqest-0.8.0/orqest/sandbox/docker_runtime/__init__.py +28 -0
  102. orqest-0.8.0/orqest/sandbox/docker_runtime/__main__.py +65 -0
  103. orqest-0.8.0/orqest/sandbox/docker_runtime/auth.py +180 -0
  104. orqest-0.8.0/orqest/sandbox/docker_runtime/executor.py +387 -0
  105. orqest-0.8.0/orqest/sandbox/docker_runtime/server.py +334 -0
  106. orqest-0.8.0/orqest/sandbox/docker_runtime/store.py +274 -0
  107. orqest-0.8.0/orqest/sandbox/helpers.py +192 -0
  108. orqest-0.8.0/orqest/sandbox/inprocess.py +222 -0
  109. orqest-0.8.0/orqest/sandbox/jwt.py +172 -0
  110. orqest-0.8.0/orqest/sandbox/protocol.py +143 -0
  111. orqest-0.8.0/orqest/sandbox/subprocess.py +328 -0
  112. orqest-0.8.0/orqest/skills/__init__.py +17 -0
  113. orqest-0.8.0/orqest/skills/__main__.py +67 -0
  114. orqest-0.8.0/orqest/skills/orqest/SKILL.md +237 -0
  115. orqest-0.8.0/orqest/skills/orqest/references/autonomy.md +215 -0
  116. orqest-0.8.0/orqest/skills/orqest/references/generative-ui.md +170 -0
  117. orqest-0.8.0/orqest/skills/orqest/references/healing.md +133 -0
  118. orqest-0.8.0/orqest/skills/orqest/references/mcp.md +186 -0
  119. orqest-0.8.0/orqest/skills/orqest/references/memory.md +126 -0
  120. orqest-0.8.0/orqest/skills/orqest/references/metacognition.md +146 -0
  121. orqest-0.8.0/orqest/skills/orqest/references/optimization.md +172 -0
  122. orqest-0.8.0/orqest/skills/orqest/references/orchestration.md +174 -0
  123. orqest-0.8.0/orqest/skills/orqest/references/sandbox.md +197 -0
  124. orqest-0.8.0/orqest/tools/__init__.py +17 -0
  125. orqest-0.8.0/orqest/tools/web.py +250 -0
  126. orqest-0.8.0/orqest/ui/__init__.py +146 -0
  127. orqest-0.8.0/orqest/ui/components/__init__.py +132 -0
  128. orqest-0.8.0/orqest/ui/components/badge.py +26 -0
  129. orqest-0.8.0/orqest/ui/components/button.py +28 -0
  130. orqest-0.8.0/orqest/ui/components/chart.py +40 -0
  131. orqest-0.8.0/orqest/ui/components/form.py +40 -0
  132. orqest-0.8.0/orqest/ui/components/image.py +22 -0
  133. orqest-0.8.0/orqest/ui/components/input.py +36 -0
  134. orqest-0.8.0/orqest/ui/components/json_viewer.py +22 -0
  135. orqest-0.8.0/orqest/ui/components/latex.py +21 -0
  136. orqest-0.8.0/orqest/ui/components/layout.py +49 -0
  137. orqest-0.8.0/orqest/ui/components/markdown.py +26 -0
  138. orqest-0.8.0/orqest/ui/components/mermaid.py +21 -0
  139. orqest-0.8.0/orqest/ui/components/plan.py +25 -0
  140. orqest-0.8.0/orqest/ui/components/sandboxed_html.py +34 -0
  141. orqest-0.8.0/orqest/ui/components/table.py +30 -0
  142. orqest-0.8.0/orqest/ui/components/takeover.py +32 -0
  143. orqest-0.8.0/orqest/ui/components/text.py +23 -0
  144. orqest-0.8.0/orqest/ui/components/vega_chart.py +29 -0
  145. orqest-0.8.0/orqest/ui/emitter.py +121 -0
  146. orqest-0.8.0/orqest/ui/events.py +26 -0
  147. orqest-0.8.0/orqest/ui/registry.py +168 -0
  148. orqest-0.8.0/orqest/ui/spec.py +90 -0
  149. orqest-0.8.0/orqest/utils/__init__.py +8 -0
  150. orqest-0.8.0/orqest/utils/llm_model.py +106 -0
  151. orqest-0.8.0/orqest/utils/reasoning.py +133 -0
  152. orqest-0.8.0/orqest/utils/token_counter.py +57 -0
  153. orqest-0.8.0/orqest/workbench/__init__.py +5 -0
  154. orqest-0.8.0/orqest/workbench/workbench.py +278 -0
  155. orqest-0.8.0/orqest.egg-info/PKG-INFO +148 -0
  156. orqest-0.8.0/orqest.egg-info/SOURCES.txt +164 -0
  157. orqest-0.8.0/orqest.egg-info/dependency_links.txt +1 -0
  158. orqest-0.8.0/orqest.egg-info/requires.txt +9 -0
  159. orqest-0.8.0/orqest.egg-info/top_level.txt +1 -0
  160. orqest-0.8.0/pyproject.toml +137 -0
  161. orqest-0.8.0/setup.cfg +4 -0
  162. orqest-0.8.0/tests/test_budget_tool_results.py +275 -0
  163. orqest-0.8.0/tests/test_config.py +70 -0
  164. orqest-0.8.0/tests/test_context_manager.py +470 -0
  165. orqest-0.8.0/tests/test_hook_decision.py +384 -0
  166. orqest-0.8.0/tests/test_hooks.py +154 -0
orqest-0.8.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kareemlsd
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.
orqest-0.8.0/PKG-INFO ADDED
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: orqest
3
+ Version: 0.8.0
4
+ Summary: Typed agent primitives and orchestration on top of pydantic-ai — memory, autonomy, healing, metacognition, generative UI, MCP, optimization.
5
+ Author-email: Kareem El Sayed <k.elsayed@outlook.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Kareemlsd/orqest
8
+ Project-URL: Documentation, https://kareemlsd.github.io/orqest/
9
+ Project-URL: Repository, https://github.com/Kareemlsd/orqest
10
+ Project-URL: Changelog, https://github.com/Kareemlsd/orqest/blob/main/CHANGELOG.md
11
+ Project-URL: Issues, https://github.com/Kareemlsd/orqest/issues
12
+ Keywords: agents,agentic,pydantic-ai,llm,orchestration,mcp,memory,metacognition,self-healing,generative-ui
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Framework :: AsyncIO
23
+ Classifier: Framework :: Pydantic
24
+ Classifier: Framework :: Pydantic :: 2
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.12
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: loguru>=0.7.3
30
+ Requires-Dist: pydantic>=2.11.7
31
+ Requires-Dist: pydantic-ai>=1.37.0
32
+ Requires-Dist: pytest-asyncio>=1.0.0
33
+ Requires-Dist: python-dotenv>=1.1.1
34
+ Requires-Dist: aiosqlite>=0.20.0
35
+ Requires-Dist: mcp>=1.0.0
36
+ Requires-Dist: fastapi>=0.136.0
37
+ Requires-Dist: uvicorn>=0.35.0
38
+ Dynamic: license-file
39
+
40
+ # Orqest
41
+
42
+ A Python library for building **agentic harnesses** on top of [pydantic-ai](https://ai.pydantic.dev). Not an agent framework with a runtime, server, or UI of its own — Orqest ships the plumbing you import to build those: typed agents, composition primitives, lifecycle hooks, memory typology, runtime agent design, metacognition, self-healing, and generative UI. All opt-in.
43
+
44
+ > **Status:** v0.8.0. The five novel cognitive-substrate features shipped in `[0.2.0]` (2026-04-25): runtime agent design, cognitive memory typology, metacognition primitives, self-healing primitives, generative UI. `[0.3.0]`–`[0.4.0]` were the reconcile + advance passes that brought preview-tier capabilities into Tier 1. `[0.8.0]` adds the `orqest.optimization` battery (GEPA-powered prompt + topology evolution), the Tier-2 Docker sandbox with per-user persisted MCP tool library, runtime topology design, dynamic tool spawning, and a provider-agnostic `reasoning` knob. Test count: 1117.
45
+
46
+ ## Install
47
+
48
+ Requires **Python 3.12+**.
49
+
50
+ ```bash
51
+ pip install orqest
52
+ # or
53
+ uv pip install orqest
54
+ ```
55
+
56
+ Create a `.env` file (or set the equivalent env vars):
57
+
58
+ ```bash
59
+ LLM_API_KEY=your_key_here
60
+ LLM_MODEL=openai:gpt-4.1
61
+ ```
62
+
63
+ ## Quickstart
64
+
65
+ The smallest working agent — 10 lines of useful code:
66
+
67
+ ```python
68
+ import asyncio
69
+ from pydantic import BaseModel
70
+ from orqest import load_config
71
+ from orqest.agents import BaseAgent, GlobalState
72
+
73
+
74
+ class Answer(BaseModel):
75
+ text: str
76
+
77
+
78
+ class QAAgent(BaseAgent[GlobalState, Answer]):
79
+ async def _run_implementation(self, state, **kwargs) -> Answer:
80
+ result = await self.call_model(state.get_latest_message("user"), state)
81
+ return result.output
82
+
83
+
84
+ async def main():
85
+ config = load_config()
86
+ agent = QAAgent(
87
+ agent_name="qa",
88
+ system_prompt="Answer concisely.",
89
+ output_type=Answer,
90
+ model=config.llm_model,
91
+ api_key=config.llm_api_key,
92
+ )
93
+ state = GlobalState()
94
+ state.add_message("user", "What is the capital of France?")
95
+ print((await agent.run(state)).text)
96
+
97
+
98
+ asyncio.run(main())
99
+ ```
100
+
101
+ ## What Orqest gives you
102
+
103
+ Eight composable batteries — **opt-in**, picked à-la-carte per application:
104
+
105
+ - **Composition** — `Pipeline`, `Parallel`, `Router`, `RefinementLoop`. Sequence agents, fan out + merge, route by classifier, iterate until "good enough."
106
+ - **Memory** — `LocalMemoryStore` (SQLite + FTS5, or embedding-cosine recall via a pluggable embedder) with typed `semantic` / `episodic` / `procedural` retrieval. Per-kind policy: reliability decay, TTL retention, skill versioning. Pluggable `MemoryStore` Protocol for production backends.
107
+ - **Autonomy** — `AgentSpec` + `AgentFactory` + `ToolRegistry` + `MetaOrchestrator`. Agents that decompose goals and spawn specialists at runtime.
108
+ - **Metacognition** — `EnrichedOutput[OutputT]` carrying `confidence`, `uncertainty_targets`, `capability_boundary`. Three pluggable `ConfidenceProtocol` strategies (free / +1 call / +k calls). Agents that know what they don't know.
109
+ - **Self-healing** — `Watchdog` Protocol + `StallDetector` / `LoopDetector` / `RegressionDetector`. `RecoveryAction` discriminated union → `HookDecision` flow. `FallbackModel` for transparent provider failover.
110
+ - **Generative UI** — `UIComponentSpec[T]` typed components — 17 across 3 layers: compositional primitives (Plan, Chart, Table, Form, TakeoverDialog, Layout, Text, Markdown, Image, Badge, Button, Input), declarative grammars (Vega, Mermaid, Latex, JsonViewer), and a sandboxed HTML escape hatch. Agents emit; frontend resolves.
111
+ - **Observability** — `EventBus`, `JSONTracer`, `sse_sidecar` (with replay + heartbeat + ring buffer). Wire once, every tool emits.
112
+ - **MCP** — client (`MCPServerManager`) + server (`create_orqest_server`) + auto-discovery (`get_or_discover` + `DiscoveryHook` + `PermissionGate`).
113
+
114
+ ## Building an application
115
+
116
+ **Read [`SKILLS.md`](SKILLS.md) first.** It's the playbook for integrating Orqest into an existing codebase: discovery questions to ask the developer, codebase-walk patterns to identify the existing stack, minimal-surface selection rules, eight pattern recipes, and an end-to-end FastAPI walkthrough. Designed for LLM coding assistants (Claude Code, Cursor) and human developers alike.
117
+
118
+ The flagship reference consumer is [`demo/polymath/`](demo/polymath/) — every Orqest battery lit up end-to-end (chat + dockview workspace + sub-agent roster + memory typology + cognitive gutter + healing toasts + generative UI tabs).
119
+
120
+ ## Supported model providers
121
+
122
+ `provider:model_id` format routes to the right SDK. The full `pydantic-ai` dependency bundles every provider SDK; the lazy import is defensive.
123
+
124
+ | Provider | Format | Example |
125
+ |----------|--------|---------|
126
+ | OpenAI | `openai:model_id` | `openai:gpt-4.1` |
127
+ | Anthropic | `anthropic:model_id` | `anthropic:claude-sonnet-4-6` |
128
+ | Google | `google:model_id` | `google:gemini-2.5-pro` |
129
+ | OpenRouter | `openrouter:model_id` | `openrouter:anthropic/claude-3.5-sonnet` |
130
+
131
+ ## Documentation
132
+
133
+ - **[SKILLS.md](SKILLS.md)** — how to build with Orqest (discovery → codebase walk → minimal surface → recipes)
134
+ - **[Notebooks](notebooks/)** — *start here if you're evaluating Orqest*: a 12-notebook tour from the cognitive substrate → meta-orchestrator → generative UI → orchestrated workflow → reasoning → optimization (basic + compound) → topology search (basic + GEPA) → runtime topology → dynamic tools → autonomous-coder combo
135
+ - **[Benchmarks](benchmarks/)** — reproducible head-to-heads measuring what each battery delivers over a baseline. Current: [`coding/`](benchmarks/coding/) — test-driven refinement loop beats single-shot by +17pp pass@1 (3-trial average)
136
+ - **[Concepts](https://kareemlsd.github.io/orqest/concepts/agents/)** — agents, state, composition, memory, metacognition, healing, generative UI
137
+ - **[API Reference](https://kareemlsd.github.io/orqest/api/agents/)** — auto-generated from source
138
+ - **[Examples](examples/)** — runnable per-primitive references (basic agent → streaming → pipeline → refinement → memory → observability)
139
+ - **[CLAUDE.md](CLAUDE.md)** — agent-instructions ground truth
140
+ - **[Changelog](CHANGELOG.md)**
141
+
142
+ ## Contributing
143
+
144
+ Contributions welcome. Open an issue or PR; new subsystems land as tracer-bullet tests-first slices.
145
+
146
+ ## License
147
+
148
+ [MIT](LICENSE)
orqest-0.8.0/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # Orqest
2
+
3
+ A Python library for building **agentic harnesses** on top of [pydantic-ai](https://ai.pydantic.dev). Not an agent framework with a runtime, server, or UI of its own — Orqest ships the plumbing you import to build those: typed agents, composition primitives, lifecycle hooks, memory typology, runtime agent design, metacognition, self-healing, and generative UI. All opt-in.
4
+
5
+ > **Status:** v0.8.0. The five novel cognitive-substrate features shipped in `[0.2.0]` (2026-04-25): runtime agent design, cognitive memory typology, metacognition primitives, self-healing primitives, generative UI. `[0.3.0]`–`[0.4.0]` were the reconcile + advance passes that brought preview-tier capabilities into Tier 1. `[0.8.0]` adds the `orqest.optimization` battery (GEPA-powered prompt + topology evolution), the Tier-2 Docker sandbox with per-user persisted MCP tool library, runtime topology design, dynamic tool spawning, and a provider-agnostic `reasoning` knob. Test count: 1117.
6
+
7
+ ## Install
8
+
9
+ Requires **Python 3.12+**.
10
+
11
+ ```bash
12
+ pip install orqest
13
+ # or
14
+ uv pip install orqest
15
+ ```
16
+
17
+ Create a `.env` file (or set the equivalent env vars):
18
+
19
+ ```bash
20
+ LLM_API_KEY=your_key_here
21
+ LLM_MODEL=openai:gpt-4.1
22
+ ```
23
+
24
+ ## Quickstart
25
+
26
+ The smallest working agent — 10 lines of useful code:
27
+
28
+ ```python
29
+ import asyncio
30
+ from pydantic import BaseModel
31
+ from orqest import load_config
32
+ from orqest.agents import BaseAgent, GlobalState
33
+
34
+
35
+ class Answer(BaseModel):
36
+ text: str
37
+
38
+
39
+ class QAAgent(BaseAgent[GlobalState, Answer]):
40
+ async def _run_implementation(self, state, **kwargs) -> Answer:
41
+ result = await self.call_model(state.get_latest_message("user"), state)
42
+ return result.output
43
+
44
+
45
+ async def main():
46
+ config = load_config()
47
+ agent = QAAgent(
48
+ agent_name="qa",
49
+ system_prompt="Answer concisely.",
50
+ output_type=Answer,
51
+ model=config.llm_model,
52
+ api_key=config.llm_api_key,
53
+ )
54
+ state = GlobalState()
55
+ state.add_message("user", "What is the capital of France?")
56
+ print((await agent.run(state)).text)
57
+
58
+
59
+ asyncio.run(main())
60
+ ```
61
+
62
+ ## What Orqest gives you
63
+
64
+ Eight composable batteries — **opt-in**, picked à-la-carte per application:
65
+
66
+ - **Composition** — `Pipeline`, `Parallel`, `Router`, `RefinementLoop`. Sequence agents, fan out + merge, route by classifier, iterate until "good enough."
67
+ - **Memory** — `LocalMemoryStore` (SQLite + FTS5, or embedding-cosine recall via a pluggable embedder) with typed `semantic` / `episodic` / `procedural` retrieval. Per-kind policy: reliability decay, TTL retention, skill versioning. Pluggable `MemoryStore` Protocol for production backends.
68
+ - **Autonomy** — `AgentSpec` + `AgentFactory` + `ToolRegistry` + `MetaOrchestrator`. Agents that decompose goals and spawn specialists at runtime.
69
+ - **Metacognition** — `EnrichedOutput[OutputT]` carrying `confidence`, `uncertainty_targets`, `capability_boundary`. Three pluggable `ConfidenceProtocol` strategies (free / +1 call / +k calls). Agents that know what they don't know.
70
+ - **Self-healing** — `Watchdog` Protocol + `StallDetector` / `LoopDetector` / `RegressionDetector`. `RecoveryAction` discriminated union → `HookDecision` flow. `FallbackModel` for transparent provider failover.
71
+ - **Generative UI** — `UIComponentSpec[T]` typed components — 17 across 3 layers: compositional primitives (Plan, Chart, Table, Form, TakeoverDialog, Layout, Text, Markdown, Image, Badge, Button, Input), declarative grammars (Vega, Mermaid, Latex, JsonViewer), and a sandboxed HTML escape hatch. Agents emit; frontend resolves.
72
+ - **Observability** — `EventBus`, `JSONTracer`, `sse_sidecar` (with replay + heartbeat + ring buffer). Wire once, every tool emits.
73
+ - **MCP** — client (`MCPServerManager`) + server (`create_orqest_server`) + auto-discovery (`get_or_discover` + `DiscoveryHook` + `PermissionGate`).
74
+
75
+ ## Building an application
76
+
77
+ **Read [`SKILLS.md`](SKILLS.md) first.** It's the playbook for integrating Orqest into an existing codebase: discovery questions to ask the developer, codebase-walk patterns to identify the existing stack, minimal-surface selection rules, eight pattern recipes, and an end-to-end FastAPI walkthrough. Designed for LLM coding assistants (Claude Code, Cursor) and human developers alike.
78
+
79
+ The flagship reference consumer is [`demo/polymath/`](demo/polymath/) — every Orqest battery lit up end-to-end (chat + dockview workspace + sub-agent roster + memory typology + cognitive gutter + healing toasts + generative UI tabs).
80
+
81
+ ## Supported model providers
82
+
83
+ `provider:model_id` format routes to the right SDK. The full `pydantic-ai` dependency bundles every provider SDK; the lazy import is defensive.
84
+
85
+ | Provider | Format | Example |
86
+ |----------|--------|---------|
87
+ | OpenAI | `openai:model_id` | `openai:gpt-4.1` |
88
+ | Anthropic | `anthropic:model_id` | `anthropic:claude-sonnet-4-6` |
89
+ | Google | `google:model_id` | `google:gemini-2.5-pro` |
90
+ | OpenRouter | `openrouter:model_id` | `openrouter:anthropic/claude-3.5-sonnet` |
91
+
92
+ ## Documentation
93
+
94
+ - **[SKILLS.md](SKILLS.md)** — how to build with Orqest (discovery → codebase walk → minimal surface → recipes)
95
+ - **[Notebooks](notebooks/)** — *start here if you're evaluating Orqest*: a 12-notebook tour from the cognitive substrate → meta-orchestrator → generative UI → orchestrated workflow → reasoning → optimization (basic + compound) → topology search (basic + GEPA) → runtime topology → dynamic tools → autonomous-coder combo
96
+ - **[Benchmarks](benchmarks/)** — reproducible head-to-heads measuring what each battery delivers over a baseline. Current: [`coding/`](benchmarks/coding/) — test-driven refinement loop beats single-shot by +17pp pass@1 (3-trial average)
97
+ - **[Concepts](https://kareemlsd.github.io/orqest/concepts/agents/)** — agents, state, composition, memory, metacognition, healing, generative UI
98
+ - **[API Reference](https://kareemlsd.github.io/orqest/api/agents/)** — auto-generated from source
99
+ - **[Examples](examples/)** — runnable per-primitive references (basic agent → streaming → pipeline → refinement → memory → observability)
100
+ - **[CLAUDE.md](CLAUDE.md)** — agent-instructions ground truth
101
+ - **[Changelog](CHANGELOG.md)**
102
+
103
+ ## Contributing
104
+
105
+ Contributions welcome. Open an issue or PR; new subsystems land as tracer-bullet tests-first slices.
106
+
107
+ ## License
108
+
109
+ [MIT](LICENSE)
@@ -0,0 +1,50 @@
1
+ from .config import OrqestConfig, get_default_config, load_config
2
+ from .healing import HealingConfig
3
+ from .hooks import (
4
+ Abort,
5
+ Continue,
6
+ HookAbortError,
7
+ HookDecision,
8
+ HookRunner,
9
+ Redirect,
10
+ Skip,
11
+ ToolHook,
12
+ )
13
+ from .metacognition import EnrichedOutput, MetacognitionConfig
14
+ from .optimization import MetaAgentConfig, OptimizationConfig
15
+ from .orchestration import (
16
+ Parallel,
17
+ Pipeline,
18
+ RefinementLoop,
19
+ Router,
20
+ )
21
+ from .plan import ExecutionPlan, PlanStatus, PlanSubtask, PlanTask
22
+ from .workbench import Workbench
23
+
24
+ __all__ = [
25
+ "Abort",
26
+ "Continue",
27
+ "EnrichedOutput",
28
+ "ExecutionPlan",
29
+ "HealingConfig",
30
+ "HookAbortError",
31
+ "HookDecision",
32
+ "HookRunner",
33
+ "MetaAgentConfig",
34
+ "MetacognitionConfig",
35
+ "OptimizationConfig",
36
+ "OrqestConfig",
37
+ "Parallel",
38
+ "Pipeline",
39
+ "PlanStatus",
40
+ "PlanSubtask",
41
+ "PlanTask",
42
+ "Redirect",
43
+ "RefinementLoop",
44
+ "Router",
45
+ "Skip",
46
+ "ToolHook",
47
+ "Workbench",
48
+ "get_default_config",
49
+ "load_config",
50
+ ]
@@ -0,0 +1,27 @@
1
+ from ..utils.reasoning import ReasoningEffort
2
+ from .base_agent import (
3
+ BaseAgent,
4
+ Prompt,
5
+ budget_tool_results,
6
+ keep_recent_messages,
7
+ )
8
+ from .compound_tool import CompoundTool
9
+ from .context_manager import ContextManager
10
+ from .retry import run_with_retry
11
+ from .session_state import BaseSessionState
12
+ from .state import GlobalState
13
+ from .tool_wrapper import as_tool
14
+
15
+ __all__ = [
16
+ "BaseAgent",
17
+ "BaseSessionState",
18
+ "CompoundTool",
19
+ "ContextManager",
20
+ "GlobalState",
21
+ "Prompt",
22
+ "ReasoningEffort",
23
+ "as_tool",
24
+ "budget_tool_results",
25
+ "keep_recent_messages",
26
+ "run_with_retry",
27
+ ]