#![deny(missing_docs)]
#![deny(rust_2018_idioms)]
#![deny(rustdoc::broken_intra_doc_links)]

//! Core traits and runtime for the klieo agent framework.
//!
//! See the spec at
//! `docs/superpowers/specs/2026-05-04-agent-framework-foundation-design.md`.

pub mod agent;
pub mod bus;
pub mod cancel;
pub mod checkpoint;
pub mod error;
pub mod guardrail;
pub mod ids;
pub mod leader;
pub mod llm;
pub mod memory;
pub mod observability;
pub mod profile;
pub mod rate_limit;
pub mod reaper;
pub mod redact;
pub mod response;
pub mod resume;
pub mod runtime;
pub mod server_outbound;
pub mod summarize;
pub mod tenants;
pub mod tool;

pub use agent::{
    Agent, AgentContext, AgentContextBuilder, AgentContextBuilderError, AgentEvent, SimpleAgent,
};
#[cfg(feature = "otel")]
pub use bus::{extract_traceparent, inject_traceparent};
pub use bus::{
    validate_subject_token, AckHandle, AckHandleImpl, BusHandles, ClaimHandle, ClaimHandleImpl,
    ClaimedJob, Headers, Job, JobQueue, KeyPage, KvEntry, KvStore, Lease, LeaseImpl, Msg,
    MsgStream, Pubsub, RequestReply, Revision,
};
pub use cancel::CancelRegistry;
pub use error::{BusError, ConfigError, Error, LlmError, MemoryError, ToolError};
pub use guardrail::{
    Guardrail, GuardrailOutcome, MaxResponseLengthGuardrail, RefusalKeywordGuardrail,
};
pub use ids::{DurableName, FactId, JobId, RunId, ThreadId};
pub use leader::{LeaderEntry, LeaderHandle, LeaderRegistry, FAILOVER_ATTEMPT_CAP};
pub use llm::{
    Capabilities, CapabilitiesBuilder, ChatChunk, ChatRequest, ChatResponse, ChunkStream,
    Embedding, FinishReason, LlmClient, Message, ResponseFormat, Role, ToolCall, ToolDef, Usage,
};
pub use memory::{
    Episode, EpisodicMemory, Fact, LongTermMemory, MemoryHandles, RunFilter, RunSummary, Scope,
    ShortTermMemory, ToolResult,
};
pub use observability::principal_hash;
pub use profile::{DeploymentProfile, ProfileViolation};
pub use reaper::{spawn_kv_reaper, KvReaperHandle};
pub use redact::{opaque_digest, AuditRedactor};
pub use response::{parse_structured, KlieoResponse};
pub use runtime::{
    gc_checkpoints, resume_from_checkpoint, run_steps, run_steps_streaming, spawn_checkpoint_gc,
    ApprovalDecision, CheckpointGcHandle, NeverReview, ReviewPolicy, RunCheckpoint, RunOptions,
    CHECKPOINT_BUCKET,
};
pub use server_outbound::{ServerOutbound, ServerOutboundError};
pub use summarize::{summarize_history, SummarizeOptions};
pub use tenants::{OwnershipCheck, OwnershipClaim, OwnershipHandle, OwnershipRegistry};
pub use tool::{Tool, ToolCtx, ToolInvoker};

#[cfg(any(test, feature = "test-utils"))]
pub mod test_utils;

/// Re-exports used exclusively by the `klieo-macros` proc-macro
/// expansions (W3.A18). Macro-generated code targets
/// `::klieo_core::__macro_support::...` rather than per-module paths
/// such as `::klieo_core::tool::Tool` so an upstream rename of a
/// submodule does not break downstream `#[tool]` invocations.
///
/// Not part of the public API. Items here may be renamed or removed
/// without a semver bump as long as the corresponding klieo-macros
/// version moves in lockstep.
#[doc(hidden)]
pub mod __macro_support {
    pub use crate::error::ToolError;
    pub use crate::response::{parse_structured, KlieoResponse};
    pub use crate::tool::{Tool, ToolCtx};
}
