Integrations
Custom agents
A framework-independent trusted tool executor for agents you build yourself.
If you run the model loop yourself, centralize execution in one executor that every tool call passes through.
executor.ts
import { Reqlo, ReqloDeniedError, type AuthorizeRequest } from "@reqlo/sdk";
const reqlo = new Reqlo({ apiKey: process.env.REQLO_API_KEY! });
type ToolDef<A> = {
action: string;
parse: (raw: unknown) => A; // validate model output
authorize: (args: A, ctx: Ctx) => Promise<AuthorizeRequest>; // authoritative facts
run: (args: A, ctx: Ctx) => Promise<unknown>;
};
const registry = new Map<string, ToolDef<any>>();
export async function execute(name: string, rawArgs: unknown, ctx: Ctx) {
const def = registry.get(name);
if (!def) return { error: "Unknown tool." }; // never execute unknown tools
const args = def.parse(rawArgs);
try {
await reqlo.enforce(await def.authorize(args, ctx));
} catch (e) {
if (e instanceof ReqloDeniedError) return { error: "This action isn't allowed." };
throw e;
}
return def.run(args, ctx);
}Why one executor
- New tools can't skip authorization: registration requires an
authorizefunction. - Parallel tool calls each go through the same path.
- Tests can target one function: "denied action does not run" for every registered tool.
Test
TypeScript
test("denied action does not run", async () => {
const run = vi.fn();
mockReqlo.denyNext();
await execute("send_email", { to: "x@example.com" }, ctx);
expect(run).not.toHaveBeenCalled();
});Something wrong or unclear? Report an issue with this page.