#![allow(missing_docs)]
#[macro_export]
macro_rules! impl_shared_agent_builder_methods {
() => {
pub fn new(model: impl Into<String>) -> Self {
Self {
model: model.into(),
..Default::default()
}
}
pub fn with_id(id: impl Into<String>, model: impl Into<String>) -> Self {
Self {
id: id.into(),
model: model.into(),
..Default::default()
}
}
#[must_use]
pub fn with_system_prompt(mut self, prompt: impl Into<String>) -> Self {
self.system_prompt = prompt.into();
self
}
#[must_use]
pub fn with_max_rounds(mut self, max_rounds: usize) -> Self {
self.max_rounds = max_rounds;
self
}
#[must_use]
pub fn with_chat_options(mut self, options: ChatOptions) -> Self {
self.chat_options = Some(options);
self
}
#[must_use]
pub fn with_fallback_models(mut self, models: Vec<String>) -> Self {
self.fallback_models = models;
self
}
#[must_use]
pub fn with_fallback_model(mut self, model: impl Into<String>) -> Self {
self.fallback_models.push(model.into());
self
}
#[must_use]
pub fn with_llm_retry_policy(mut self, policy: LlmRetryPolicy) -> Self {
self.llm_retry_policy = policy;
self
}
};
}
#[macro_export]
macro_rules! declare_plugin_states {
($($state:ty),+ $(,)?) => {
fn register_lattice_paths(&self, registry: &mut ::tirea_state::LatticeRegistry) {
$(<$state as ::tirea_state::State>::register_lattice(registry);)+
}
fn register_state_scopes(
&self,
registry: &mut $crate::runtime::state::StateScopeRegistry,
) {
$(registry.register::<$state>(<$state as ::tirea_state::StateSpec>::SCOPE);)+
}
fn register_state_action_deserializers(
&self,
registry: &mut $crate::runtime::state::StateActionDeserializerRegistry,
) {
$(registry.register::<$state>();)+
}
};
}
#[cfg(any(test, feature = "test-support"))]
pub mod testing;
pub mod io;
pub mod runtime;
pub mod scope;
pub mod storage;
pub mod thread;
pub mod transport;
pub type RunPolicy = runtime::RunPolicy;
pub type AgentRunConfig = runtime::AgentRunConfig;
pub use thread::{
gen_message_id, CheckpointReason, Message, MessageMetadata, Role, RunMeta, Thread,
ThreadChangeSet, ThreadMetadata, ToolCall, Version, Visibility,
};
pub use io::{
AgentEvent, ResumeDecisionAction, RunRequest, RuntimeInput, RuntimeOutput, ToolCallDecision,
};
pub use runtime::{
build_read_only_context_from_step, reduce_state_actions, Action, ActivityContext,
ActivityManager, AfterInferenceContext, AfterToolExecuteContext, AgentBehavior, AnyStateAction,
BeforeInferenceContext, BeforeToolExecuteContext, DecisionReplayPolicy, Extensions,
NoOpBehavior, Phase, PhaseContext, PhasePolicy, ReadOnlyContext, RunAction, RunContext,
RunDelta, RunEndContext, RunStartContext, ScopeContext, SerializedStateAction,
StateActionDecodeError, StateActionDeserializerRegistry, StateScope, StateScopeRegistry,
StateSpec, StepContext, StepEndContext, StepOutcome, StepStartContext, StoppedReason,
StreamResult, SuspendTicket, Suspension, SuspensionResponse, TerminationReason, TokenUsage,
ToolCallAction, ToolCallContext, ToolCallOutcome, ToolCallProgressSink, ToolCallProgressState,
ToolCallProgressStatus, ToolCallProgressUpdate, ToolExecution, ToolExecutionEffect,
ToolExecutionRequest, ToolExecutionResult, ToolExecutor, ToolExecutorError, ToolGate,
ToolProgressState, TOOL_CALL_PROGRESS_ACTIVITY_TYPE, TOOL_CALL_PROGRESS_SCHEMA,
TOOL_CALL_PROGRESS_TYPE, TOOL_PROGRESS_ACTIVITY_TYPE, TOOL_PROGRESS_ACTIVITY_TYPE_LEGACY,
};
pub use storage::{
paginate_in_memory, paginate_mailbox_entries, paginate_runs_in_memory, Committed, MailboxEntry,
MailboxEntryOrigin, MailboxEntryStatus, MailboxInterrupt, MailboxPage, MailboxQuery,
MailboxReader, MailboxReceiver, MailboxState, MailboxStore, MailboxStoreError, MailboxWriter,
MessagePage, MessageQuery, MessageWithCursor, ReceiveOutcome, RunOrigin, RunPage, RunQuery,
RunReader, RunRecord, RunStore, RunStoreError, RunWriter, SortOrder, ThreadHead,
ThreadListPage, ThreadListQuery, ThreadReader, ThreadStore, ThreadStoreError, ThreadSync,
ThreadWriter, VersionPrecondition,
};
pub use transport::{Identity, Transcoder};