OpenAgentID documentation
Source referencesRust module referenceopenagent-sdk

openagent-sdk · agent

Declared module signatures, types, configuration, and source documentation.

Source: openagent-sdk/sdks/rust/src/agent.rs. SHA-256: 1538f167ae4c05d66cb606308a74ffbb53fe3171efcb40787d53077a38312219.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

agent::CreateAgentOptions

Options for creating a new agent in one call.

Mirrors the JS / TS pattern of "one big options bag" so the call site stays flat. Most fields are optional and have sensible defaults.

#[derive(Debug, Default)]
pub struct CreateAgentOptions<'a> {
/// Parent DID to derive this agent from. When `None`, a fresh Human Root

/// (HMR) identity is minted under the configured namespace.

pub parent: Option<ParsedDid>,
/// Required: a short, human-readable name (becomes the DID identifier).

pub name: &'a str,
/// Default scopes the agent will request from the Arsenal broker. May be

/// overridden per-credential-call.

pub scopes: &'a [&'a str],
/// Optional kind override (defaults to `"agent"` when deriving from a

/// parent, or `"hmr"` when no parent is supplied).

pub kind: Option<&'a str>,
/// Optional derivation path. Defaults to `"<kind>/<name>"`.

pub derivation_path: Option<&'a str>
}

Source line: 43.

agent::OpenAgent

A fully-constructed agent.

OpenAgent is Clone-cheap (everything inside is Arc-shared) so the same agent handle can flow through every layer of an application.

#[derive(Clone)]
pub struct OpenAgent {

}

Source line: 68.

agent::OpenAgent::from_parts

Construct an [OpenAgent] from already-built parts.

Most callers should use [crate::builder::OpenAgentBuilder] or [OpenAgent::create_agent] instead. This constructor exists so test harnesses (and the builder itself) can wire pre-built components.

The signature varies with the enabled Cargo features: credentials exists only with arsenal, verifier only with aegis. A subsystem left disabled is absent from the type, not silently stubbed.

pub fn from_parts(
        record: AgentIdentityRecord,
        config: OpenAgentConfig,
        #[cfg(feature = "arsenal")] credentials: Option<CredentialClient>,
        #[cfg(feature = "aegis")] verifier: Option<Verifier>,
        skills: SkillsPolicyHandle,
        default_scopes: Vec<String>,
    ) -> Self;

Source line: 93.

agent::OpenAgent::create_agent

Create a new agent with default SDK configuration.

This is the boring, batteries-included path:

  1. If parent is supplied, derive a child identity under that parent. Otherwise mint a fresh HMR under the SDK's default namespace.
  2. Skip the credentials layer (no broker is configured by default — use [crate::builder::OpenAgentBuilder::with_arsenal_client] for that).
  3. Skip the AEGIS verifier (same reason).
  4. Use a deny-all default skills policy.

Errors

Returns [OpenAgentError::Identity] if document construction fails.

pub async fn create_agent(opts: CreateAgentOptions<'_>) -> Result<Self>;

Source line: 130.

agent::OpenAgent::create_agent_with_config

Like [Self::create_agent] but with a custom [OpenAgentConfig].

Errors

Returns [OpenAgentError::Identity] if document construction fails.

pub async fn create_agent_with_config(
        opts: CreateAgentOptions<'_>,
        config: OpenAgentConfig,
    ) -> Result<Self>;

Source line: 139.

agent::OpenAgent::document

The agent's signed OAS Identity Document.

pub fn document(&self) -> &OasDocument;

Source line: 187.

agent::OpenAgent::keypair

The agent's keypair (for advanced workflows — most users should not touch this).

pub fn keypair(&self) -> &OasKeyPair;

Source line: 193.

agent::OpenAgent::did

The agent's did:oas string.

pub fn did(&self) -> &str;

Source line: 198.

agent::OpenAgent::default_scopes

The default scopes the agent was created with.

pub fn default_scopes(&self) -> &[String];

Source line: 203.

agent::OpenAgent::config

The SDK config snapshot in effect for this agent.

pub fn config(&self) -> &OpenAgentConfig;

Source line: 208.

agent::OpenAgent::skills_policy

Skill policy handle for this agent.

Returns a clone, so callers can move it into other layers without borrow-checking pain.

pub fn skills_policy(&self) -> SkillsPolicyHandle;

Source line: 216.

agent::OpenAgent::with_skills_policy

Set (or replace) the skill policy on this agent.

This rebuilds the inner Arc so the change is local to the returned clone — callers should reassign the returned value.

pub fn with_skills_policy<P: SkillsPolicy + 'static>(self, policy: P) -> Self;

Source line: 224.

agent::OpenAgent::check_skill

Quick check whether the named skill may be invoked by this agent.

Errors

Returns [OpenAgentError::SkillDenied] if the skill is not allowed.

pub fn check_skill(&self, skill: &str) -> Result<()>;

Source line: 250.

agent::OpenAgent::credentials_for

Get a credentials handle scoped to a specific provider.

provider is a logical name (e.g., "openai", "github") used by the SDK only for diagnostic logs — the actual scopes routed to the broker come from the agent's [Self::default_scopes].

Errors

Returns [OpenAgentError::Config] if no credential client is wired in.

#[cfg(feature = "arsenal")]
pub async fn credentials_for(&self, provider: &str) -> Result<CredentialClient>;

Source line: 264.

agent::OpenAgent::verifier

Reference to the AEGIS verifier (if configured).

#[cfg(feature = "aegis")]
pub fn verifier(&self) -> Option<&Verifier>;

Source line: 278.

agent::authenticate_with_verifier

One-shot authentication helper at the crate level.

OpenAgent::authenticate is the canonical entry point referenced in the README pitch. We expose it as an inherent method on the [OpenAgent] type itself by re-exporting from [crate::lib].

Verifies the supplied DID through an injected [Verifier]. The DID is opaque — typically it comes from an Authorization: Bearer header or an X-Openagent-DID header on an inbound HTTP request.

Errors

Returns [OpenAgentError::Verification] on pipeline failure or [OpenAgentError::Config] if no verifier was supplied.

#[cfg(feature = "aegis")]
pub async fn authenticate_with_verifier(
    verifier: &Verifier,
    did: &str,
) -> Result<crate::verification::VerifiedContext>;

Source line: 311.

On this page