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
//! Dhara — declarative conversation flow management.
//!
//! "Dhara" (ധാര) means flow/stream. Define conversation flows in JSON,
//! implement handlers in Rust, and let the framework wire everything.
//!
//! # Architecture
//!
//! ```text
//! dhara/<flow_id>/
//! dhara.json ← flow graph, prompts, transitions, function schemas
//! functions.rs ← handler implementations
//!
//! main.rs ← load, build, plug into pipeline
//! ```
//!
//! # Usage
//!
//! ```rust,ignore
//! // 1. Register handlers (from your functions.rs)
//! let mut handlers = DharaFunctionRegistry::new();
//! handlers.register("begin_interview", |args, ctx| async move { ... });
//! handlers.register("end_conversation", |args, ctx| async move { ... });
//!
//! // 2. Load and validate the flow
//! let dhara = Dhara::load("dhara/interview")?;
//!
//! // 3. Build runtime pieces for this connection
//! let built = dhara.build(&handlers, my_state, conn_id)?;
//!
//! // 4. Wire into pipeline
//! let mut llm = OpenAILLMHandler::with_shared_registry(config, built.llm_registry);
//! llm.set_transition_hook(built.hook);
//! // ... built.context goes to aggregators, RAVI, etc.
//! // ... after PipelineTask::new(), call built.dhara_ctx.set_push_sender(task.push_sender())
//! ```
//!
//! # Modules
//!
//! ```text
//! dhara/
//! mod.rs ← you are here
//! schema.rs ← JSON deserialization types for dhara.json
//! dctx.rs ← DharaContext (runtime context for handlers)
//! registry.rs ← DharaFunctionRegistry (handler registration)
//! loader.rs ← Dhara (load, validate, build)
//! node.rs ← NodeConfig (legacy, kept for backward compat)
//! transition.rs ← TransitionResult (legacy, kept for backward compat)
//! manager.rs ← DharaManager (legacy, kept for backward compat)
//! ```
// Legacy modules — kept for backward compatibility during migration
// --- New API (preferred) ---
pub use ;
pub use DharaContext;
pub use ;
// --- Legacy API (deprecated, use new API for new flows) ---
pub use ;
pub use ;
pub use TransitionResult;