Skip to main content

Crate weirdnet_agent

Crate weirdnet_agent 

Source
Expand description

Weirdnet agent runtime.

A model-agnostic agent loop shared by WeirdBrains apps. Apps supply a ModelBackend, tool sources and an Approver; this crate runs the turn loop, enforces the approval Policy and research Budget, and records a Trace whose Citations are checked against the steps that fetched them.

  • session: AgentSession, the turn loop with streaming AgentEvents.
  • cancel: CancelToken, checked between model and tool steps.
  • tool: Tool, ToolSource (local now, MCP and remote nodes later) and ToolRegistry.
  • policy: tiers, per-companion per-site grants, task approvals and standing allows.
  • budget: searches, pages, concurrency and time limits.
  • trace: steps, citations and the cited-step check.
  • model: the model backend trait and chat messages, whose Content is text or parts (text, images, audio) with the Modalities a model needs to read them.
  • remote: protocols between one user’s nodes over an app-supplied channel: inference (infer/2 with priorities, queueing, reasoning, tool calls, embeddings and resume; infer/1 kept for 0.3 nodes), the model catalog, remote tasks (Node companions), and the transport-neutral remote::pool::Pool that fails over and resumes answers across nodes.
  • pool (feature): the pool over Weirdnet: inference nodes among the user’s linked devices.
  • serve (feature): serve inference and the catalog on a Weirdnet node, checking callers against the device roster.

Nothing here is app-specific: browser tools, panels and storage live in the app.

Public enums are #[non_exhaustive]: match them with a wildcard arm.

Re-exports§

pub use budget::Budget;
pub use budget::BudgetExceeded;
pub use budget::BudgetTracker;
pub use budget::BudgetUsage;
pub use budget::ToolTimer;
pub use cancel::CancelToken;
pub use identity::AgentId;
pub use identity::AgentIdentity;
pub use identity::AgentKind;
pub use model::Content;
pub use model::ContentPart;
pub use model::DeltaSink;
pub use model::ImageUrl;
pub use model::InputAudio;
pub use model::Message;
pub use model::Modalities;
pub use model::ModelBackend;
pub use model::ModelError;
pub use model::ModelNotice;
pub use model::ModelTurn;
pub use model::Role;
pub use model::ToolCall;
pub use policy::ActionRequest;
pub use policy::AllowRule;
pub use policy::ApprovalPrompt;
pub use policy::CompanionScope;
pub use policy::Decision;
pub use policy::DenyReason;
pub use policy::Policy;
pub use policy::PolicyError;
pub use policy::Scope;
pub use policy::SharedPolicy;
pub use policy::SiteLevel;
pub use policy::SkipNotice;
pub use policy::StandingAllow;
pub use policy::TaskApprovals;
pub use policy::Tier;
pub use policy::site_of;
pub use remote::Admitted;
pub use remote::Authorize;
pub use remote::Caller;
pub use remote::RemoteError;
pub use session::AgentConfig;
pub use session::AgentEvent;
pub use session::AgentSession;
pub use session::ApprovalAnswer;
pub use session::Approver;
pub use session::Outcome;
pub use session::PagesPrompt;
pub use session::StopReason;
pub use tool::BudgetCharge;
pub use tool::CallTarget;
pub use tool::LocalTools;
pub use tool::RegistryError;
pub use tool::SourceKind;
pub use tool::Tool;
pub use tool::ToolAnnotations;
pub use tool::ToolContext;
pub use tool::ToolError;
pub use tool::ToolOutput;
pub use tool::ToolRegistry;
pub use tool::ToolSource;
pub use tool::ToolSpec;
pub use trace::ApprovalOutcome;
pub use trace::Citation;
pub use trace::CitationError;
pub use trace::CitationTarget;
pub use trace::SessionMark;
pub use trace::StepId;
pub use trace::StepKind;
pub use trace::Trace;
pub use trace::TraceStep;
pub use trace::retain_valid;
pub use trace::validate_citations;

Modules§

budget
Research budgets: searches, pages, concurrency and time.
cancel
Cooperative cancellation shared between a session, its tools and the UI.
identity
Who an agent (a “companion” in Morph) is.
model
The model backend trait and chat messages. Inference lives elsewhere (weirdnet-model, remote nodes); this crate only drives it.
policy
Approval policy: tiers, per-companion per-site grants, task approvals and standing “Always allow” rules.
pool
The pool feature: the app side of remote inference over weirdnet-net.
remote
Remote inference and remote tasks between one user’s own nodes.
serve
The serve feature: the inference side of remote inference over weirdnet-net.
session
The agent loop.
testing
Test doubles: a scripted model, a scripted approver and closure-backed tools. Enabled in this crate’s tests and, for downstream crates, with the testing feature.
tool
Tools, tool sources and the registry.
trace
Traces, steps and citations.