1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
//! `klieo` — open-source Rust agent framework.
//!
//! This umbrella crate re-exports [`klieo_core`] unconditionally and
//! exposes each implementation crate behind a Cargo feature flag so
//! users can start with just the trait surfaces and opt into concrete
//! implementations one at a time.
//!
//! # Quickstart
//!
//! Add to `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! klieo = { version = "1", features = ["all-foundation"] }
//! ```
//!
//! Then build an agent:
//!
//! ```no_run
//! use klieo::{RunOptions, Error};
//! let opts = RunOptions::default();
//! let _ = opts;
//! ```
//!
//! # Feature flags
//!
//! ## Foundation
//!
//! | Feature | Crate enabled |
//! |---------|---------------|
//! | *(none)* | `klieo-core` trait surfaces only |
//! | `tools` | `klieo-tools` — `ChainedInvoker`, schema validation |
//! | `macros` | `klieo-macros` — `#[tool]` proc-macro |
//! | `llm-ollama` | `klieo-llm-ollama` — Ollama HTTP client |
//! | `memory-sqlite` | `klieo-memory-sqlite` — SQLite-backed memory |
//! | `bus-memory` | `klieo-bus-memory` — in-process bus |
//! | `bus-nats` | `klieo-bus-nats` — NATS JetStream bus |
//! | `mcp` | `klieo-tools-mcp` — MCP adapter (implies `tools`) |
//! | `all-foundation` | All foundation features above |
//!
//! ## LLM providers
//!
//! | Feature | Crate enabled |
//! |---------|---------------|
//! | `llm-openai` | `klieo-llm-openai` |
//! | `llm-anthropic` | `klieo-llm-anthropic` |
//! | `llm-gemini` | `klieo-llm-gemini` (Google Gemini) |
//! | `all-llm` | All LLM providers (incl. Ollama) |
//!
//! ## Memory backends
//!
//! | Feature | Crate enabled |
//! |---------|---------------|
//! | `memory-neo4j` | `klieo-memory-neo4j` |
//! | `memory-qdrant` | `klieo-memory-qdrant` |
//! | `embed-common` | `klieo-embed-common` — shared `Embedder` trait |
//! | `memory-fastembed` | `memory-sqlite` + real CPU embeddings |
//! | `memory-sqlite-vec` | `memory-sqlite` + k-NN sqlite-vec index |
//! | `all-memory` | All memory backends (incl. GraphRAG cluster) |
//!
//! ## GraphRAG cluster
//!
//! Stable at 1.x per [ADR-039](https://github.com/mohrimic/klieo/blob/main/docs/adr/adr-039-graphrag-1-0-promotion.md).
//!
//! | Feature | Crate enabled |
//! |---------|---------------|
//! | `memory-graph` | `klieo-memory-graph` — `KnowledgeGraph` trait + `InMemoryGraph` |
//! | `memory-graph-neo4j` | `klieo-memory-graph-neo4j` — Neo4j-backed `KnowledgeGraph` (implies `memory-graph` + `memory-neo4j`) |
//! | `memory-graph-rag` | `klieo-memory-graph-rag` — graph-first RAG composer (implies `memory-graph` + `memory-qdrant`) |
//! | `graph-projector` | `klieo-graph-projector` — Episode→Graph projector (implies `memory-graph`) |
//!
//! ## Composition + protocol
//!
//! | Feature | Crate enabled |
//! |---------|---------------|
//! | `flows` | `klieo-flows` — Sequential/Parallel/Loop/Graph |
//! | `workflow` | `klieo-workflow` — declarative no-code workflow substrate |
//! | `a2a` | `klieo-a2a` — durable Agent-to-Agent v1.0 |
//! | `spec` | `klieo-spec` — quality-loop runner |
//! | `hitl` | `klieo-hitl` — human-in-the-loop review gate |
//!
//! ## Observability + provenance
//!
//! | Feature | Crate enabled |
//! |---------|---------------|
//! | `runlog` | `klieo-runlog` — RunLog projection + replay |
//! | `runlog-sqlite` | `runlog` + SQLite store |
//! | `runlog-compaction-llm` | `runlog` + LLM-summarise compaction |
//! | `provenance` | `klieo-provenance` — Merkle hash chain |
//! | `otel` | `klieo-otel` — OpenTelemetry OTLP exporter |
//! | `all-observability` | `runlog` + `provenance` + `otel` |
//!
//! ## Aggregates
//!
//! | Feature | Enables |
//! |---------|---------|
//! | `full` | Every impl crate — heavy build, for integration tests |
//! | `test-utils` | `klieo-core/test-utils` for downstream test deps |
// ── core ──────────────────────────────────────────────────────────────────────
/// Re-exports every public item from `klieo-core`.
pub use *;
/// Re-exports the runtime crates that `klieo-macros`-emitted code
/// references via absolute paths. Marked `#[doc(hidden)]`: end-user
/// code should never reference these by hand.
///
/// The `#[klieo::tool]` proc-macro emits paths like
/// `::klieo::__private::klieo_core::__macro_support::Tool`, so
/// downstream crates need only `klieo` as a direct dependency —
/// `klieo-core` is no longer required in the user's `Cargo.toml`.
/// Re-exported `klieo_core::test_utils` (in-memory fakes for the
/// memory traits, fake LLM client, fake tool invoker).
///
/// Enabled by the `test-utils` feature flag. The glob re-export
/// above transitively exposes this module, but an explicit `pub use`
/// pins the contract so future `klieo-core` reorganisations cannot
/// accidentally hide it from downstream consumers.
pub use test_utils;
/// Common imports for klieo agent authors.
///
/// `use klieo::prelude::*;` brings in `Agent`, `AgentContext`,
/// `Error`, `LlmClient`, `Message`, `Role`, `RunId`, `ThreadId`,
/// `ToolDef`, `ToolInvoker`, `Tool`, `ToolCtx`, `Episode`,
/// `ToolResult`, `RunOptions`.
/// Fluent assembler that collapses the 13-field `AgentContext` into
/// a one-call wiring surface. See [`App`] for the entry point.
pub use ;
/// Recall-recording wrapper that redacts and length-bounds GraphRAG
/// recall queries before they reach durable episodic storage. See
/// [`RecallRecorder`] for the entry point.
pub use RecallRecorder;
/// Re-exported `secrecy::SecretString`. Activated by the `secrecy`
/// feature, which `bus-nats`, `llm-anthropic`, `llm-openai`,
/// `llm-genai`, `memory-neo4j`, and `memory-qdrant` auto-enable.
///
/// Downstream consumers that interact with any klieo crate accepting
/// credentials can `use klieo::SecretString;` instead of pinning the
/// `secrecy` crate directly — preventing version skew like the
/// 0.8 ↔ 0.10 incompatibility surfaced in adoption eval Plan 02.
pub use SecretString;
/// Re-exported `bytes` crate. Activated by the `bytes` feature,
/// which `bus-nats` auto-enables (klieo-bus-nats's `Job` payload is
/// `bytes::Bytes`).
pub use bytes;
// ── tools ─────────────────────────────────────────────────────────────────────
/// Tool dispatch: [`tools::ChainedInvoker`], [`tools::validate_args`].
///
/// Enabled by the `tools` feature flag.
// ── macros ────────────────────────────────────────────────────────────────────
/// Procedural macros: the `#[macros::tool]` attribute.
///
/// Enabled by the `macros` feature flag.
/// Re-export of the [`#[tool]`][macros::tool] attribute at crate root
/// so `#[klieo::tool(...)]` works without an extra `use`. The full
/// `klieo::macros::tool` path remains valid.
pub use tool;
/// Re-export of the [`#[derive(KlieoResponse)]`][macros::KlieoResponse]
/// derive at crate root so `#[derive(klieo::KlieoResponse)]` works
/// without an extra `use`.
pub use KlieoResponse;
// ── llm ───────────────────────────────────────────────────────────────────────
/// Ollama LLM client: [`llm::OllamaClient`].
///
/// Enabled by the `llm-ollama` feature flag.
///
/// For symmetric access alongside other providers, see
/// [`llm_openai`], [`llm_anthropic`], [`llm_gemini`].
/// OpenAI Chat Completions client.
///
/// Enabled by the `llm-openai` feature flag.
/// Anthropic Messages client.
///
/// Enabled by the `llm-anthropic` feature flag.
/// Google Gemini client.
///
/// Enabled by the `llm-gemini` feature flag.
// ── memory ────────────────────────────────────────────────────────────────────
/// SQLite-backed memory: [`memory_sqlite::MemorySqlite`], [`memory_sqlite::DummyEmbedder`].
///
/// Enabled by the `memory-sqlite` feature flag.
/// Neo4j-backed memory: short-term + episodic.
///
/// Enabled by the `memory-neo4j` feature flag.
/// Qdrant-backed long-term memory (vector recall).
///
/// Enabled by the `memory-qdrant` feature flag.
/// Qdrant connection config — re-exported at the crate root so callers
/// configuring [`AppBuilder::qdrant_with`](app::AppBuilder::qdrant_with)
/// reach it as `klieo::QdrantConfig` without a direct dependency on the
/// `klieo-memory-qdrant` adapter crate.
///
/// Enabled by the `memory-qdrant` feature flag.
pub use QdrantConfig;
/// Neo4j connection config — re-exported at the crate root so callers
/// configuring [`AppBuilder::neo4j_with`](app::AppBuilder::neo4j_with)
/// reach it as `klieo::Neo4jConfig`. Under the `graph-rag` feature the
/// same type is re-exported via the GraphRAG facade (see below); this
/// arm covers `memory-neo4j` without `graph-rag`.
pub use Neo4jConfig;
/// Shared `Embedder` trait + dummy/fake impls.
///
/// Enabled by the `embed-common` feature flag.
/// GraphRAG trait surface — `KnowledgeGraph`, `FilterableLongTermMemory`,
/// `EntityExtractor`, `EntityRef`, `EntityType`, `RecallMetrics`,
/// `InMemoryGraph`, `known_epoch`.
///
/// Enabled by the `memory-graph` feature flag. Stable at 1.0 per ADR-039.
/// Neo4j-backed `KnowledgeGraph` impl: `Neo4jKnowledgeGraph`, `ScopedQuery`.
///
/// Enabled by the `memory-graph-neo4j` feature flag (depends on
/// `memory-graph` and `memory-neo4j`).
/// Graph-first RAG composer: `GraphAwareLongTerm` + extractors +
/// `KnowledgeIngestionPipeline` + `ImportSource`.
///
/// Enabled by the `memory-graph-rag` feature flag (depends on
/// `memory-graph` and `memory-qdrant`).
/// Episode-to-knowledge-graph projector bridge.
///
/// Enabled by the `graph-projector` feature flag (depends on
/// `memory-graph`). Stable at 1.0 per ADR-039.
/// One-line GraphRAG facade configuration — [`graph_rag::GraphRagConfig`].
///
/// Enabled by the `graph-rag` feature flag. Aggregates the full GraphRAG
/// cluster (knowledge graph + vector recall + episode projector + provenance)
/// behind two constructors: [`graph_rag::GraphRagConfig::in_memory`] for
/// zero-infra dev and [`graph_rag::GraphRagConfig::remote`] for production.
pub use ;
// ── bus ───────────────────────────────────────────────────────────────────────
/// In-process bus: [`bus_memory::MemoryBus`].
///
/// Enabled by the `bus-memory` feature flag.
/// NATS JetStream bus: [`bus_nats::NatsBus`], [`bus_nats::NatsBusConfig`].
///
/// Enabled by the `bus-nats` feature flag.
// ── mcp ───────────────────────────────────────────────────────────────────────
/// MCP adapter: [`mcp::McpToolset`], [`mcp::StdioConnectOptions`].
///
/// Enabled by the `mcp` feature flag (implies `tools`).
/// MCP server: publish this process's tools to MCP clients via
/// [`mcp_server::McpServer`]. Pairs with [`App::serve_mcp_stdio`].
///
/// Enabled by the `mcp-server` feature flag.
// ── composition + protocol ────────────────────────────────────────────────────
/// Multi-agent composition shapes: `Sequential` / `Parallel` / `Loop` / `Graph`.
///
/// Enabled by the `flows` feature flag.
/// Declarative no-code workflow substrate: lower a `WorkflowDef` (authored
/// as data) into a runnable flow via [`workflow::compile`].
///
/// Enabled by the `workflow` feature flag.
/// Durable Agent-to-Agent v1.0 protocol layer.
///
/// Enabled by the `a2a` feature flag.
/// Generic decompose / critique / refine traits + `QualityLoop` runner.
///
/// Enabled by the `spec` feature flag.
/// Recall-quality metrics — `hit_rate`, MRR, `precision@k`,
/// `recall@k`, `NDCG@k` — for klieo memory pipelines.
///
/// Enabled by the `eval` feature flag.
/// Durable human-in-the-loop run driver — suspend a run for operator
/// approval, resume on decision (ADR-045).
///
/// Enabled by the `hitl` feature flag.
// ── auth ──────────────────────────────────────────────────────────────────────
/// OAuth 2.0 bearer-token Authenticator for klieo HTTP transports.
///
/// Enabled by the `oauth` feature flag.
// ── observability + provenance ────────────────────────────────────────────────
/// Tier 2 observability — RunLog projection + replay engine.
///
/// Enabled by the `runlog` feature flag.
/// Append-only Merkle hash chain + signed evidence bundles.
///
/// Enabled by the `provenance` feature flag.
/// OpenTelemetry OTLP exporter wired to `tracing` spans.
///
/// Enabled by the `otel` feature flag.
/// Embeddable agent-flow visualizer — mount [`viz::VizRouterBuilder::build`] in
/// your app's `axum` server over your own `EpisodicMemory` / `RunLogStore` to
/// see runs, the cross-run flow canvas, per-step detail + cost, and live updates.
///
/// Enabled by the `observability-viz` feature flag.
// ── lib tests ─────────────────────────────────────────────────────────────────