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//! - [`remote`]: remote inference (offload a model turn to another node, with fallback) and
16//! remote tasks (Node companions) over an app-supplied channel.
17//!
18//! Nothing here is app-specific: browser tools, panels and storage live in the app.
19
20pub mod budget;
21pub mod cancel;
22pub mod identity;
23pub mod model;
24pub mod policy;
25pub mod remote;
26pub mod session;
27#[cfg(any(test, feature = "testing"))]
28pub mod testing;
29pub mod tool;
30pub mod trace;
31
32pub use budget::{Budget, BudgetExceeded, BudgetTracker, BudgetUsage, ToolTimer};
33pub use cancel::CancelToken;
34pub use identity::{AgentId, AgentIdentity, AgentKind};
35pub use model::{DeltaSink, Message, ModelBackend, ModelError, ModelTurn, Role, ToolCall};
36pub use policy::{
37 ActionRequest, AllowRule, ApprovalPrompt, CompanionScope, Decision, DenyReason, Policy, PolicyError, Scope, SharedPolicy, SiteLevel, SkipNotice,
38 StandingAllow, TaskApprovals, Tier, site_of,
39};
40pub use session::{AgentConfig, AgentEvent, AgentSession, ApprovalAnswer, Approver, Outcome, PagesPrompt, StopReason};
41pub use tool::{
42 BudgetCharge, CallTarget, LocalTools, RegistryError, SourceKind, Tool, ToolAnnotations, ToolContext, ToolError, ToolOutput, ToolRegistry,
43 ToolSource, ToolSpec,
44};
45pub use trace::{
46 ApprovalOutcome, Citation, CitationError, CitationTarget, SessionMark, StepId, StepKind, Trace, TraceStep, retain_valid, validate_citations,
47};