Skip to main content

phi_agent/
lib.rs

1//! phi-agent: General-purpose AI Agent framework
2//!
3//! Built on agent-base and agent-works, providing builder factory, renderer,
4//! config resolution, session management, and other infrastructure.
5//! **Does not bundle any tools** — tools are injected by consumers.
6
7pub mod agent;
8pub mod bridge;
9pub mod cli;
10pub mod config;
11pub mod event_log;
12pub mod prompt;
13pub mod render;
14pub mod session;
15
16// ── Common agent-base types ──
17// Only re-export the types consumers use most often.
18// For the full type set, import directly from agent-base.
19pub use agent_base::{
20    AgentBuilder, AgentError, AgentResult, AgentRuntime, ApprovalHandler, ConsecutiveFailureRecovery, LlmClient,
21    OpenAiClient, PlanItem, PlanStepStatus, ReasoningConfig, ReasoningEffort, RunOutcome, RuntimeEvent, SafetyConfig,
22    SessionId, Tool, ToolContext, ToolControlFlow, ToolMetadata, ToolOutput, TurnFactMiddleware,
23    TurnToolLimitMiddleware, UpdatePlanTool,
24};
25
26// ── phi-telemetry (metrics types and storage) ──
27#[cfg(feature = "telemetry")]
28pub use phi_telemetry::{
29    SessionMetrics, SessionOutcome, SessionSummary, TurnMetrics, TurnOutcome, list_all_metrics, load_metrics,
30    save_metrics, try_load_metrics,
31};
32
33// ── agent-works ──
34pub use agent_works::focus::{Context as FocusContext, Focus, FocusError, FocusInput, FocusOutput};
35
36// ── phi-agent types ──
37pub use agent::{CompressionConfig, PhiAgent, PhiAgentConfig, SummarizingMiddleware, base_agent_builder};
38pub use cli::{ApprovalMode, AutoApprovalHandler};
39pub use config::{LlmConfig, resolve_llm_config};
40pub use event_log::{event_to_jsonl, event_to_value, save_turn_log};
41pub use prompt::{build_system_prompt, build_system_prompt_cn};
42pub use render::{
43    EventRenderer, JsonStreamRenderer, NullRenderer, OutputFormat, create_renderer, create_stdout_renderer,
44};
45pub use session::SessionContext;