Skip to main content

machi_runtime/
lib.rs

1//! Turn runtime and session host for the Machi kernel.
2//!
3//! Maturity: **core** (turn, host, session, spawn); **stable** workflow host adapter.
4
5#![forbid(unsafe_code)]
6// Dev-dependencies (toolkit, tempfile) are only used by integration tests.
7#![allow(
8    unused_crate_dependencies,
9    reason = "dev-deps for integration tests appear unused on lib target"
10)]
11
12pub mod gates;
13pub mod host;
14pub mod isolation;
15pub mod lifecycle;
16pub mod metrics;
17pub mod schema;
18pub mod session;
19pub mod side_effects;
20pub mod spawn_tool;
21pub mod state;
22pub mod stationarity;
23pub mod turn;
24pub mod workflow_host;
25
26pub use gates::{CompletionToolGate, GateChain, GateDecision, StopGate, evaluate_stop_gates};
27pub use host::{
28    AgentRunResult, DEFAULT_MAX_CONCURRENT_CHILDREN, DEFAULT_MAX_SPAWN_DEPTH, InProcessHost,
29    SessionHost, SpawnOpts,
30};
31pub use isolation::{InProcessIsolation, IsolationBackend, IsolationEnv, isolation_error};
32pub use lifecycle::{LifecycleFanout, NoopLifecycle, TurnAbortReason, TurnLifecycleContributor};
33pub use stationarity::{
34    HARD_STOP_THRESHOLD, NUDGE_THRESHOLD, StationarityAction, StationarityTracker,
35    fingerprint_batch, nudge_message,
36};
37// re-export compaction strategy surface used by hosts
38pub use machi_compaction::{CompactionOutcome, CompactionStrategy, MaxMessages, TokenThreshold};
39pub use metrics::{
40    METRIC_COMPACTIONS_TOTAL, METRIC_SAMPLE_DURATION_MS, METRIC_SPAWNS_TOTAL, METRIC_TOKENS_TOTAL,
41    METRIC_TOOL_CALLS_TOTAL, METRIC_TOOL_DURATION_MS, METRIC_TURN_DURATION_MS, METRIC_TURN_STEPS,
42    METRIC_TURNS_TOTAL, METRIC_WORKFLOW_AGENTS_TOTAL, METRIC_WORKFLOW_RUNS_TOTAL, MetricsSink,
43    NoopMetrics, SharedMetrics, record_compaction, record_sample, record_spawn, record_tool_call,
44    record_turn, record_workflow_agents, record_workflow_run, required_metric_names,
45};
46pub use schema::{
47    STRUCTURED_OUTPUT_MAX_RETRIES, compile_schema, schema_retry_reminder,
48    validate_structured_output,
49};
50pub use session::Session;
51pub use side_effects::WorkflowSideEffects;
52pub use spawn_tool::SpawnAgentTool;
53pub use state::{ConversationState, VecConversationState, estimate_messages_tokens};
54pub use turn::{TurnInput, TurnOptions, TurnOutcome, TurnRuntime, estimate_conversation_tokens};
55pub use workflow_host::{
56    run_workflow_configured, run_workflow_on_host, run_workflow_on_host_with_metrics,
57};