Skip to main content

Crate tkach

Crate tkach 

Source
Expand description

§tkach

A provider-independent agent runtime for Rust with built-in tools.

The agent is stateless — callers own the message history and pass it in on every call.

§Quick Start

use tkach::{Agent, CancellationToken, Message, providers::Anthropic, tools};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let agent = Agent::builder()
        .provider(Anthropic::from_env())
        .model(tkach::model::claude::SONNET)
        .system("You are a helpful coding assistant.")
        .tools(tools::defaults())
        .build()?;

    let mut history = vec![Message::user_text(
        "What files are in the current directory?",
    )];
    let result = agent.run(history.clone(), CancellationToken::new()).await?;
    history.extend(result.new_messages);
    println!("{}", result.text);
    Ok(())
}

Re-exports§

pub use agent::Agent;
pub use agent::AgentBuilder;
pub use agent::AgentResult;
pub use agent::AgentStream;
pub use agent::BuildError;
pub use approval::ApprovalDecision;
pub use approval::ApprovalHandler;
pub use approval::AutoApprove;
pub use error::AgentError;
pub use error::ProviderError;
pub use error::ToolError;
pub use executor::AllowAll;
pub use executor::ConcurrencyConfig;
pub use executor::ToolCall;
pub use executor::ToolConcurrency;
pub use executor::ToolExecutor;
pub use executor::ToolPolicy;
pub use executor::ToolRegistry;
pub use guard::AgentSnapshot;
pub use guard::ContinuationGuard;
pub use guard::GuardDecision;
pub use guard::GuardError;
pub use guard::GuardEscape;
pub use guard::GuardId;
pub use guard::GuardTrigger;
pub use handle::AgentHandle;
pub use message::CacheControl;
pub use message::CacheTtl;
pub use message::Content;
pub use message::Message;
pub use message::Role;
pub use message::StopReason;
pub use message::ThinkingMetadata;
pub use message::ThinkingProvider;
pub use message::Usage;
pub use mode::AcceptEditsMode;
pub use mode::AgentMode;
pub use mode::DefaultMode;
pub use mode::ModeAuthority;
pub use mode::ModeDecision;
pub use mode::ModeError;
pub use mode::PlanMode;
pub use policy::AllowList;
pub use policy::IntersectPolicy;
pub use prompt_policy::IntentMatcher;
pub use prompt_policy::PolicyError;
pub use prompt_policy::PolicyId;
pub use prompt_policy::PolicyMetadata;
pub use prompt_policy::PolicyScope;
pub use prompt_policy::PolicyTrigger;
pub use prompt_policy::PolicyTriggerMetadata;
pub use prompt_policy::PromptPolicy;
pub use provider::LlmProvider;
pub use provider::Request;
pub use provider::Response;
pub use provider::SystemBlock;
pub use provider::ThinkingConfig;
pub use provider::ThinkingEffort;
pub use provider::ToolDefinition;
pub use steering::InterruptError;
pub use steering::InterruptOutcome;
pub use steering::InterruptReason;
pub use steering::InterruptTarget;
pub use steering::IntoQueueContent;
pub use steering::SteerError;
pub use steering::TurnId;
pub use stream::ProviderEventStream;
pub use stream::StreamEvent;
pub use tool::Tool;
pub use tool::ToolClass;
pub use tool::ToolContext;
pub use tool::ToolOutput;
pub use user_input::Answer;
pub use user_input::AskUserError;
pub use user_input::BridgeError;
pub use user_input::Question;
pub use user_input::QuestionOption;
pub use user_input::QuestionSet;
pub use user_input::UserInputBridge;
pub use user_input::UserInputResponse;

Modules§

agent
approval
User-approval gate for tool calls.
error
executor
Tool dispatch: registry, policy, executor, and concurrency configuration.
guard
Continuation guards for predicate-driven agent loops.
handle
Caller-facing handle for steering a running agent.
message
mode
Runtime mode gates for steering-aware agents.
model
Canonical model name constants.
policy
Tool-policy implementations and safe composition helpers.
prompt_policy
Runtime prompt policies installed through crate::AgentHandle.
provider
providers
steering
Mid-task steering primitives.
stream
Streaming primitives.
tool
tools
user_input
Operator input bridge for root-agent elicitation.

Structs§

CancellationToken
A token which can be used to signal a cancellation request to one or more tasks.