@vextlabs/stoa-guard
v0.1.0
Published
Wire ANY AI into STOA in one line. Wrap a tool/function so it is gated (prove-or-permit before it runs), permit-carrying, and receipted automatically — against the open STOA API, verifiable by anyone. From Vext Labs.
Maintainers
Readme
@vextlabs/stoa-guard
Wire any AI into STOA in one line. Wrap a tool or function and it becomes:
- gated — STOA proves-or-permits the action before it runs (deterministic checks: financial bounds, unscoped-SQL refusal, sandboxed code, delete safety),
- permit-carrying — you get a short-lived signed permit the executor/vendor can verify,
- receipted — every action leaves a tamper-proof record anyone can verify
offline with
@vextlabs/stoa-verifier, trusting no one.
It wraps your execution, so it works with OpenAI, Anthropic, LangChain, CrewAI, or your own code. Apache-2.0, zero dependencies.
npm install @vextlabs/stoa-guardGet a token at https://tryvext.com/api-keys (scope: cap_call).
One line
import { createStoaGuard } from '@vextlabs/stoa-guard';
const stoa = createStoaGuard({ token: process.env.STOA_TOKEN! });
// Wrap any tool — same signature, now gated + permitted + receipted:
const safeCharge = stoa.guard(
'urn:stoa:cap:stripe.charges.create',
(input) => stripe.charges.create(input),
);
await safeCharge({ amount_cents: 4000, currency: 'usd' });
// Gates first. Throws StoaBlockedError if the gate refuses (e.g. a $9M charge,
// a DELETE without a WHERE). Runs your function only if the action is allowed.More control
// Inspect the verdict + permit without running anything:
const { verdict, permit } = await stoa.check({ cap, input });
// Gate + run, and get everything back:
const { result, verdict, permit, receipt_id } = await stoa.run({ cap, input }, () => myTool(input));
// Prove what an action WOULD do, before it commits (executes nothing):
const { predicted_effect } = await stoa.simulate({ cap, input });Modes
enforce(default) — a blocked action throwsStoaBlockedError; an abstained one throwsStoaHeldErrorunless you passconfirmed: trueor anonAbstainhandler that returnstrue.observe— never throws on the verdict; runs the action and attaches the verdict. Dark-launch with zero behavior change, then flip toenforce.
const stoa = createStoaGuard({ token, mode: 'observe' });Verify, trusting no one
Every permit and receipt is an ES256 JWS over a canonical payload, verifiable
offline against the public key at /.well-known/stoa/jwks.json:
import { verifyPermit } from '@vextlabs/stoa-verifier';
const ok = await verifyPermit({ permit, cap, input, nowSeconds: Math.floor(Date.now() / 1000), publicJwk });Learn more: https://stoa.tryvext.com · spec + capabilities at /.well-known/stoa/capabilities.json.
