Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

WIT Interface

The WIT (WebAssembly Interface Type) definition is the canonical contract between the WASM sandbox and the Akshi host runtime. It uses the Component Model specification.

Status: Component Model execution is in-progress. The runtime currently uses a preview adapter. The WIT contract is stable and defines the target interface.

Package

package akshi:runtime@0.1.0;

Interface: host

interface host {
    // Database
    db-query: func(sql: string) -> result<string, string>;
    db-execute: func(sql: string) -> result<u64, string>;

    // Journal
    journal-append: func(payload: string) -> result<_, string>;
    journal-read: func(since: u64) -> result<string, string>;

    // MCP
    mcp-call-tool: func(server: string, tool: string, args: string) -> result<string, string>;
    mcp-list-tools: func(server: string) -> result<string, string>;

    // HTTP
    http-request: func(method: string, url: string, headers: string, body: string) -> result<string, string>;

    // Inference
    inference-prompt: func(prompt: string) -> result<string, string>;
    inference-prompt-with-model: func(model: string, prompt: string) -> result<string, string>;

    // Config
    config-get: func(key: string) -> result<string, string>;
    config-set: func(key: string, value: string) -> result<_, string>;

    // A2A
    a2a-send: func(target: string, payload: string) -> result<string, string>;
    a2a-receive: func() -> result<string, string>;

    // WebSocket
    ws-send: func(channel: string, message: string) -> result<_, string>;
    ws-receive: func(channel: string) -> result<string, string>;

    // Utility
    log: func(level: string, message: string) -> result<_, string>;
    sleep-ms: func(millis: u64) -> result<_, string>;
    random-bytes: func(len: u32) -> result<list<u8>, string>;
}

World

world agent {
    import host;
    export run: func() -> result<_, string>;
}

The run export is the agent entry point. The runtime calls it once per tick (or once at startup in single-shot mode). All host imports are available for the agent to call during execution.