Skip to main content

weirdnet_agent/
lib.rs

1//! Weirdnet agent runtime.
2//!
3//! A model-agnostic agent loop shared by WeirdBrains apps. Apps supply a
4//! [`ModelBackend`], tool sources and an [`Approver`]; this crate runs the turn
5//! loop, enforces the approval [`Policy`] and research [`Budget`], and records a
6//! [`Trace`] whose [`Citation`]s are checked against the steps that fetched them.
7//!
8//! - [`session`]: [`AgentSession`], the turn loop with streaming [`AgentEvent`]s.
9//! - [`cancel`]: [`CancelToken`], checked between model and tool steps.
10//! - [`tool`]: [`Tool`], [`ToolSource`] (local now, MCP and remote nodes later) and [`ToolRegistry`].
11//! - [`policy`]: tiers, per-companion per-site grants, task approvals and standing allows.
12//! - [`budget`]: searches, pages, concurrency and time limits.
13//! - [`trace`]: steps, citations and the cited-step check.
14//! - [`model`]: the model backend trait and chat messages.
15//!
16//! Nothing here is app-specific: browser tools, panels and storage live in the app.
17
18pub mod budget;
19pub mod cancel;
20pub mod identity;
21pub mod model;
22pub mod policy;
23pub mod session;
24#[cfg(any(test, feature = "testing"))]
25pub mod testing;
26pub mod tool;
27pub mod trace;
28
29pub use budget::{Budget, BudgetExceeded, BudgetTracker, BudgetUsage};
30pub use cancel::CancelToken;
31pub use identity::{AgentId, AgentIdentity, AgentKind};
32pub use model::{DeltaSink, Message, ModelBackend, ModelError, ModelTurn, Role, ToolCall};
33pub use policy::{
34    ActionRequest, AllowRule, ApprovalPrompt, CompanionScope, Decision, DenyReason, Policy, PolicyError, Scope, SharedPolicy, SiteLevel, SkipNotice,
35    StandingAllow, TaskApprovals, Tier, site_of,
36};
37pub use session::{AgentConfig, AgentEvent, AgentSession, ApprovalAnswer, Approver, Outcome, StopReason};
38pub use tool::{
39    BudgetCharge, CallTarget, LocalTools, RegistryError, SourceKind, Tool, ToolAnnotations, ToolContext, ToolError, ToolOutput, ToolRegistry,
40    ToolSource, ToolSpec,
41};
42pub use trace::{
43    ApprovalOutcome, Citation, CitationError, CitationTarget, SessionMark, StepId, StepKind, Trace, TraceStep, retain_valid, validate_citations,
44};