@aroha-sdk/run
v1.6.0
Published
Aroha /v1/run server and client  the fastest path to a Hub-registered agent
Downloads
132
Readme
@aroha-sdk/run
Lightweight HTTP runtime for Aroha agents — the server layer that mandate-carrying requests travel over.
Install
npm install @aroha-sdk/runQuick example
import { serve } from "@aroha-sdk/run";
import { verifyMandate } from "@aroha-sdk/credentials";
serve({
name: "flight-agent",
did: process.env.AROHA_AGENT_DID!,
privateKey: process.env.AROHA_PRIVATE_KEY!,
async onRequest(req) {
// Verify the incoming mandate before doing any work
const { valid, mandate, reason } = await verifyMandate(
req.mandateToken,
req.issuerPublicKey,
);
if (!valid) return { error: reason, status: 403 };
// mandate.constraints.spendLimitUsd is enforced — act within scope
const result = await bookFlight(req.message, mandate.constraints);
return { message: result };
},
});
// → [flight-agent] did:aroha:flight-agent http://localhost:3001/aroha/v1 ReadyWhy this exists in the mandate chain
The HTTP layer is where mandate-carrying requests arrive and where enforcement happens. @aroha-sdk/run provides the serve() primitive that wires up the /v1/run endpoint and makes it straightforward to call verifyMandate before any agent logic executes.
API
serve(config)— start an Aroha-compliant HTTP server. Acceptsname,did,privateKey,onRequest,port, andauthoptions.createHandler(config)— create a Next.js / Cloudflare Workers compatible request handler without starting a standalone server.
License
MIT
