Skip to main content
Verified against published aomi-sdk 5.1.1 at commit 2ef3e04 on 2026-09-22.
The aomi-sdk crate is the public Rust API for implementing an Aomi plugin. It defines typed tools, call context, secrets, async results, registration, host namespaces, and test helpers. This is an API-focused reference. To choose a project layout, write a preamble, and package the plugin as an App, start with Aomi App.
Build only against the public aomi-sdk crate. Your plugin exchanges JSON values with the host and does not link to private runtime crates.

SDK surface

The crate re-exports compatible schemars and serde_json modules. Using aomi_sdk::schemars and aomi_sdk::serde_json avoids dependency-version drift in schema and JSON types. The public crate and its authoring examples live in the aomi-sdk repository. The hosted backend consumes the crate and loads its ABI; private backend crates are not part of the plugin API.

The DynAomiTool trait

Implement one DynAomiTool per operation exposed to the model.
Argument types derive Deserialize and JsonSchema. Field doc comments become parameter descriptions in the generated schema.
Return concise error strings that tell the model whether it should correct an argument, ask the user, or stop.

Tool-call context

Every tool receives a DynToolCallCtx containing its call identity and the host data exposed to the plugin.
Read nested attributes with typed helpers:
Treat state attributes as input for the current call. Do not assume an attribute exists unless the host capability that supplies it is active.

Async tools

Set IS_ASYNC = true and implement run_async for long-running work. Use the DynAsyncSink to send progress and one terminal result.
  • emit sends a non-terminal update.
  • complete sends the terminal result.
  • fail reports a terminal error.
  • is_canceled lets expensive work stop after host cancellation.
Pass bare JSON values to emit. Only the terminal complete result may use a routed return envelope.

Routed and multistep tools

A tool can suggest a follow-up host action by returning a routed ToolReturn. Use this when one result naturally supplies the arguments for the next step, such as a quote followed by a signature request. Override run_with_routes, then attach an on_return step:
The route is a continuation hint, not permission to execute. Aomi presents the step to the model and still applies the App policy, guards, and signing policy before the next tool runs. Use bind_as on a producer and after(...).awaits for a callback-driven continuation. The host injects the bound callback artifact into the awaiting arguments; do not rebuild or manually copy wallet payloads, transaction hashes, signatures, quote IDs, or route IDs.

The dyn_aomi_app! macro

Call dyn_aomi_app! once in src/lib.rs. It registers the plugin manifest and dispatches tool calls to their typed implementations.
The macro is the only registration entry point you need. Do not implement the low-level plugin boundary by hand.

Secrets

Declare each external credential as a Secret slot. The name is canonical, the description appears in configuration surfaces, and required determines whether the App can load without a value. A declaration is operator-owned by default.
Register the slot with secrets = [API_KEY]. At call time, read it with resolve_secret_value:
The helper resolves, in order:
  1. an explicit argument;
  2. the credential injected into ctx.secrets; and
  3. an environment variable used by local CLI and tests.
Do not log, persist, or include the resolved value in tool output.

User-owned credentials

Call .user_owned() when every authenticated user must supply a separate credential:
Read a user-owned value only from the injected call context:
resolve_user_secret_value intentionally has no tool-argument or process environment fallback. This prevents a missing user credential from silently using a builder or backend operator key. The host redacts common result and error paths, but plugin code is trusted native code: never log, persist, or return a credential.

Host namespaces

namespaces requests host capability sets that accompany your plugin tools. Declare only capabilities the App uses. If the App stages transactions, describe the expected stage, simulate, and commit sequence in its preamble so the model invokes the host tools in the correct order.

Testing tools

Use aomi_sdk::testing to test typed tools without loading the compiled plugin.
Seed the same inputs a host call would provide:
For an async tool, run_async_tool returns (updates, terminal): the emitted values in order and the terminal payload.

Next steps

Aomi App

Structure the crate, write its preamble, and configure its package.

End-to-end testing

Test realistic App conversations with a canonical test.json journey.

CLI toolchain

Compile, run, deploy, and activate the plugin.
Last modified on August 12, 2026