Expand description
Guest SDK for Oino WASM component extensions (oino:extension@2.0.0).
An extension is a type implementing Extension; export_extension! turns it into a
component. init registers events, tools, commands, shortcuts, flags, services, settings,
renderers and arbiter roles through Init; handlers are plain async closures or methods
receiving &'static Self. Host capabilities are thin typed wrappers over the WIT imports:
| Module | WIT | Use |
|---|---|---|
session | session | entries, append_entry, send_message, sessions index |
control | control | model, thinking, tools, commands, compaction, command-context ops |
models | models | completions, streaming, summaries, credentials |
ui | ui, registry | dialogs, slots (panels, widgets, status, turn footers), settings namespaces, editor, OS integration; node trees from ui::widgets |
agents | agents | nested agent sessions (subagents) |
process | process | exec, spawn with streaming stdio, signals, process trees |
tasks | tasks | host background tasks |
http | http | fetch (streaming), loopback listener |
fs | fs + WASI | named preopens, atomic writes, locks, watchers |
timers | timers | oino_timer events, sleep, wall clock |
kv | kv | scoped key-value state |
settings | registry | extension settings reads and writes |
secrets, bus, services | same | secrets, pub/sub, inter-extension calls |
host_service | host-service | embedding-host services ("browser", "cron", …) |
host | host-info, log | platform, workspace, env, logging |
[provider] (feature provider) | provider, provider-host | provider components |
ⓘ
use oino_extension::prelude::*;
#[derive(Default)]
struct Hello;
#[derive(Deserialize, JsonSchema)]
struct Args { name: String }
impl Extension for Hello {
async fn init(&'static self, cx: &mut Init<Self>) -> Result<()> {
cx.tool(Tool::new("hello").description("Greets").args::<Args>()
.run(|_ext, args: Args, _cx| async move { Ok(ToolResult::text(format!("Hello {}", args.name))) }));
cx.on(EventKind::AgentEnd, |_ext, _ev, cx| async move {
session::append_entry("hello.seen", Some(&json!({"session": cx.session_id()})))?;
Ok(())
});
Ok(())
}
}
oino_extension::export_extension!(Hello);§Errors
Every wrapper returning Result fails only with the host-error of its WIT import
(permission denied, stale context, invalid argument, …) or a JSON decoding error, surfaced
as Error. Individual functions therefore do not repeat an # Errors section.
Re-exports§
pub use futures;pub use oino_ai;pub use schemars;pub use serde;pub use serde_json;pub use wit_bindgen;
Modules§
- agents
- Nested agent sessions (subagents, btw, sidekick; runtime §12). Permission
agents.spawn. - bus
- Event bus: deliveries arrive as
oino_busevents. - command
- Command, shortcut and flag builders (
registerCommand,registerShortcut,registerFlag). - context
- Call contexts handed to handlers.
- control
- Session control (
ctx.*,setModel, tools, commands, command-context operations). - events
- Event payloads. Payloads are wire-shaped JSON (they carry the
typefield). - fs
- Files: named preopens (
/ext-global,/ext-workspace/<wsid>,/ext-session/<sid>,/tmp,/cache,/logs,/project,/agent/<sub>), atomic writes, locks and watchers. Plainstd::fsworks on preopen paths. - host
- Host information and logging.
- host_
service - Host-provided services (WIT
host-service, v2 ext-abi §3): one thin wrapper over [wit::host_service]. - http
- Outbound HTTP through the host (permission
network.hosts) and a loopback listener. - kv
- Scoped key-value state (
global,workspace,session). - models
- Model calls outside the session loop (permission
models.complete,credentials). - prelude
- Everything an extension usually needs.
- process
- Processes (permission
process.spawn+process.allow). - secrets
- Secrets in the extension’s own namespace (permission
secrets). - services
- Inter-extension service calls (permission
services.call). - session
- Session reads and writes (
sessionManager,appendEntry,sendMessage). - settings
- Extension settings (runtime §10.3): read the namespaces this extension registered (or any namespace, without secrets it is not allowed to see) and write its own keys.
- sync
- Single-threaded synchronisation for state shared across concurrent guest calls.
- tasks
- Host background tasks (C12; permission
process.spawn). - timers
- Timers:
oino_timer {timerId}events (subscribe toEventKind::OinoTimer), sleep, clock. - tool
- Tool builder and results.
- ui
- Frontend-agnostic UI (ui-protocol v2): dialogs, slots (panels, widgets, status segments, turn footers), settings namespaces, editor, device integration.
- wit
- Raw generated WIT types (escape hatch).
Macros§
- export_
extension - Exports an
Extensiontype as the component’s guest implementation.
Structs§
- Init
- Registration collector passed to
Extension::init.
Enums§
- Error
- SDK error.
Traits§
- Extension
- An Oino extension. One value per component instance (created with
Default, then leaked so handlers receive&'static Self).
Type Aliases§
- Result
- SDK result.
Attribute Macros§
- tool
- Generates
fn <name>_tool() -> ::oino_extension::tool::Tool<Self>for a tool method.