All docs
Docs · Stacks
Nano-ops
Run operations at the edge
Small, pure logic via JavaScript that runs sandboxed on the chassis — no service to deploy.
txco op init OPS/support/0100_TRIAGE/classify # scaffold classify.js next to its rule
txco op run OPS/support/0100_TRIAGE/classify.js --input '{"amount": 1200}'
txco op test OPS/support/0100_TRIAGE/classify.js # mock-request.json in, diff vs mock-response.json
txco apply # build + upload happen automatically The handler is a function of the event:
import { op } from "@txco/op"; // helper library imports txco functions
export default op(async ({ input, env, secrets, log }) => {
return { tier: input.amount > 1000 ? "vip" : "standard" };
}); and the rule references it by name — EXEC "op://classify" resolves
to the colocated classify.js at apply time.
What the tooling handles for you:
- Building.
apply(andtxco devon save) bundles, compiles to wasm via the pinnedjavy(auto-fetched and checksum-verified on first use), and uploads the content-addressed module. - Running locally.
txco op runexecutes on the same engine production uses — what passes locally is what ships. - Testing.
txco op testuses the scope’s mock fixtures:mock-request.jsonas input, diff againstmock-response.json(exit 1 on mismatch), withmock-env.json/mock-secrets.jsonstanding in forctx.envandctx.secrets. - Sandboxing. No filesystem, network, or ambient environment; memory and wall-clock capped per call (runtime reference).
Important restrictions when choosing nano-ops
Nano-ops are not meant for running large operations requiring IO, but instead as a way to have a richer language
available for processing and manipulating operation state in the lowest runtime latency possible. This means
that you won’t compile a node app with a full node_modules included. It also means that many functions that node
includes, like fetch won’t be available to the nano-op.
See also
Full txco handler API: (ctx fields, helper subpaths @txco/op/{envelope,schema,crypto,codec}): the sdk/op README.