Verified against published
aomi-sdk 5.1.1 at commit 2ef3e04 on 2026-09-22.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.
Tool-call context
Every tool receives aDynToolCallCtx containing its call identity and the
host data exposed to the plugin.
Async tools
SetIS_ASYNC = true and implement run_async for long-running work. Use the
DynAsyncSink to send progress and one terminal result.
emitsends a non-terminal update.completesends the terminal result.failreports a terminal error.is_canceledlets expensive work stop after host cancellation.
Routed and multistep tools
A tool can suggest a follow-up host action by returning a routedToolReturn.
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:
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 aSecret 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.
secrets = [API_KEY]. At call time, read it with
resolve_secret_value:
- an explicit argument;
- the credential injected into
ctx.secrets; and - an environment variable used by local CLI and tests.
User-owned credentials
Call.user_owned() when every authenticated user must supply a separate
credential:
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
Useaomi_sdk::testing to test typed tools without loading the compiled plugin.
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.