Venolio

Add-ons: host API reference

For developers

An add-on reaches the outside world only through the host functions of the venolio import module. The venolio-addon SDK wraps them. This page lists the SDK functions, then the raw interface for authors who use another language.

The SDK

[dependencies]
venolio-addon = "0.1"            # or { path = "<sdk folder>/venolio-addon" }
serde = { version = "1", features = ["derive"] }

Everything returns venolio_addon::Result<T>, whose error is venolio_addon::Error:

Variant Meaning
Error::Denied(message) The grants do not allow it (see Permissions). error.is_denied() tells you.
Error::Host(message) The host refused or failed: invalid arguments, a storage limit, an outside service error.
Error::Input(message) The run’s input is not what the entry point expects.
Error::Other(message) Your own errors (Error::msg("…")) and JSON encoding errors.

Entry points

use venolio_addon::{entry_point, Result};

fn digest(input: DigestInput) -> Result<DigestOutput> { … }
entry_point!(digest);                       // exported as "digest"
entry_point!(ping, |(): ()| Ok("pong"));    // exported as "ping"
  • The input type is anything serde::Deserialize. A run without input (null) decodes as null when the type accepts it ((), Option<T>, Value) and otherwise as {}, so a struct whose fields all have defaults works without input.
  • The output type is anything serde::Serialize; it becomes the run’s output (at most 256 KiB).
  • An Err, invalid input or a panic ends the run as failed. The SDK writes the reason as the last log line (error: … or panic at …) before stopping, because the sandbox’s own message for a trap only says wasm unreachable instruction executed.

Lower level: venolio_addon::input::<T>(), input_bytes() and output(&value).

Logs

venolio_addon::log!("sent {} pages", n);
venolio_addon::log_line("plain text");

At most 50 lines of 1000 characters per run; control characters other than tab are removed. Logs are kept with the run and shown to administrators, so never log secrets or page contents you would not show them.

Pages (pages:read)

Function Returns
pages::get(page_id) Page { id, parent_id, title, icon, text, truncated, updated_at }. text is plain text, at most 65,536 characters.
pages::list(limit) PageList { items: Vec<PageSummary>, has_more }: pages (not database records), most recently updated first. limit 1–50, default 20.

IDs are UUID strings; times are RFC 3339 strings.

Records (records:read, records:write)

Function Returns
records::list(database_id, limit) RecordList { database: { id, title, properties: [{ id, name, kind }] }, items: [{ id, page_id, title, properties, updated_at }], has_more } in board order. limit 1–100, default 50. properties is a JSON object keyed by property ID.
records::create(database_id, title, properties) Created { id, page_id }. properties is a JSON object keyed by property ID (or Value::Null). Relation and file properties cannot be set. Needs records:write and a database the granting administrator can edit.

Storage (storage)

Function Returns
storage::get::<T>(key) Option<T>
storage::set(key, &value) (); the value must not be null
storage::delete(key) bool: whether the key existed
storage::list(prefix, limit) KeyList { keys, has_more } in key order; limit 1–100, default 100

Keys are 1–200 characters without control characters; values are JSON of at most 64 KiB; an add-on stores at most 1000 keys and 1 MiB in total. Storage belongs to the installation: uninstalling deletes it, and no add-on can read another’s.

HTTP (network)

use venolio_addon::http::Request;

let response = Request::post("https://hooks.example.com/digest")
    .header("authorization", &format!("Bearer {token}"))
    .json(&payload)?          // sets content-type: application/json
    .send()?;
if !response.is_success() { … }
let data: MyType = response.json()?;

Request::{get, post, put, patch, delete, head, new}, .header(), .body(), .json(), .send(). Response { status, headers, body, truncated } with is_success(), json() and error_for_status(). Bodies are text; binary answers are decoded lossily. The response headers passed on are content-type, content-length, retry-after, etag, last-modified, location and date (the server’s clock, for runs that have no time of their own). The network rules apply.

Signatures (no scope needed)

let signature = venolio_addon::crypto::sign_rs256(&key_pem, &format!("{header}.{claims}"))?;
let jwt = format!("{header}.{claims}.{signature}");

crypto::sign_rs256(key_pem, data) signs data (text up to 64 KiB) with RS256 and an RSA private key of 2048–4096 bits in PEM (up to 4 KiB), and returns the signature in URL-safe base64 without padding, ready to end a JWT, for example a Google service account’s sign-in. Venolio computes it: the same signature inside the sandbox would cost more than a run’s whole processor budget. The key is the add-on’s own, from its input or storage; signing reaches no Venolio data and no network. A key that is not an RSA key in PEM is an Error::Host.

Where do tokens come from? There is no secret store for add-ons yet: pass a token in the run’s input or keep it in storage. A common pattern is a setup entry point, run by an administrator, that stores it.

Raw requests

venolio_addon::call(&json!({"op": "…", …})) sends any host request and returns its result. Use it for operations the SDK does not wrap yet.

The raw interface

For authors who do not use the SDK (any language that compiles to WebAssembly). The module must export its memory as memory, export each entry point as a function () -> (), have no start function, and import nothing but these functions from the module venolio:

Function Signature Purpose
input_len () -> i32 Length of the run’s JSON input.
input_read (ptr: i32) Copies the input to memory at ptr.
output_write (ptr: i32, len: i32) Sets the run’s output: JSON, at most 256 KiB.
call (ptr: i32, len: i32) -> i32 Sends a JSON host request; returns the length of the response envelope.
response_read (ptr: i32) Copies the last response envelope to memory at ptr.
log (ptr: i32, len: i32) Adds a UTF-8 log line.

A response envelope is {"ok": true, "result": …} or {"ok": false, "error": "…", "denied": true|false}. To fail a run, trap (for example with unreachable) after logging why.

op Scope Request Result
pages.get pages:read page_id id, parent_id, title, icon, text, truncated, updated_at
pages.list pages:read limit? 1–50 (20) items [{id, parent_id, title, icon, updated_at}], has_more
records.list records:read database_id, limit? 1–100 (50) database {id, title, properties [{id, name, type}]}, items [{id, page_id, title, properties, updated_at}], has_more
records.create records:write database_id, title, properties? id, page_id
storage.get storage key key, value (null when unset)
storage.set storage key, value key, stored
storage.delete storage key key, deleted
storage.list storage prefix?, limit? 1–100 (100) keys, has_more
http.fetch network url, method? (GET, POST, PUT, PATCH, DELETE, HEAD), headers? (object of strings), body? (string) status, headers, body, truncated
triggers.fire automations:trigger trigger (a declared ID), payload? (up to 16 KiB) trigger, queued. At most 4 per run; refused in runs started by automations. SDK: venolio_addon::triggers::fire(trigger, &payload).
crypto.sign_rs256 none key (RSA PEM, up to 4 KiB), data (string, up to 64 KiB) signature

An unknown op returns Unknown operation "…"; a request that is not JSON returns The request is not valid JSON.

About this part of Venolio: Let Claude, ChatGPT and Codex work in your workspace

Checked against the app on . The same help is built into the Venolio apps and works offline. Something wrong or missing? Tell us.