Skip to main content

Crate oino_extension

Crate oino_extension 

Source
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:

ModuleWITUse
sessionsessionentries, append_entry, send_message, sessions index
controlcontrolmodel, thinking, tools, commands, compaction, command-context ops
modelsmodelscompletions, streaming, summaries, credentials
uiui, registrydialogs, slots (panels, widgets, status, turn footers), settings namespaces, editor, OS integration; node trees from ui::widgets
agentsagentsnested agent sessions (subagents)
processprocessexec, spawn with streaming stdio, signals, process trees
taskstaskshost background tasks
httphttpfetch (streaming), loopback listener
fsfs + WASInamed preopens, atomic writes, locks, watchers
timerstimersoino_timer events, sleep, wall clock
kvkvscoped key-value state
settingsregistryextension settings reads and writes
secrets, bus, servicessamesecrets, pub/sub, inter-extension calls
host_servicehost-serviceembedding-host services ("browser", "cron", …)
hosthost-info, logplatform, workspace, env, logging
[provider] (feature provider)provider, provider-hostprovider 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_bus events.
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 type field).
fs
Files: named preopens (/ext-global, /ext-workspace/<wsid>, /ext-session/<sid>, /tmp, /cache, /logs, /project, /agent/<sub>), atomic writes, locks and watchers. Plain std::fs works 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 to EventKind::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 Extension type 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.