Skip to main content

Documentation Index

Fetch the complete documentation index at: https://iii.dev/docs/llms.txt

Use this file to discover all available pages before exploring further.

Invoking functions

A function runs when a trigger fires. The same function can be invoked from many trigger types at once (direct CLI calls, an HTTP route, and a cron schedule, for example) without changing the handler.
Some trigger types are: iii trigger, worker.trigger, iii-http, iii-cron, iii-queue, iii-state, iii-stream.

Register a function

Inside a worker, worker.registerFunction(id, handler) makes a function callable from anywhere in the iii system. The id follows the service::name form; the handler receives the call’s payload and returns the result.
import { registerWorker } from "iii-sdk";

const worker = registerWorker(process.env.III_URL);

worker.registerFunction("math::add", async (payload: { a: number; b: number }) => {
  return { c: payload.a + payload.b };
});

Define request and response formats

Functions can carry JSON Schemas for their request payload and response shape. The schemas are stored with the function and feed the iii console and the agent-readable skills.
Runtime validation is not yet supported. Attached schemas are metadata only; the engine does not reject payloads or responses that don’t match. Treat the schemas as contract documentation for callers, agents, and the console until validation lands.
For how to attach schemas when registering a function, see Creating Workers / Functions.

Invoke a function

For how to call a registered function from worker code or the terminal (with optional delivery actions like fire-and-forget or queue-routed), see Triggers / Call a function directly.