@x12i/xentra-approvals
v0.2.0
Published
Approval policies and requests for Xentra
Readme
@x12i/xentra-approvals
Human-in-the-loop approval policies and requests for sensitive agent or user actions.
Install
npm install @x12i/xentra-approvalsRequires @x12i/xentra-store.
Usage
import { createMemoryStore } from "@x12i/xentra-store";
import { createApprovalsService } from "@x12i/xentra-approvals";
const store = createMemoryStore();
const approvals = createApprovalsService(store);
const policy = await approvals.createPolicy({
accountId: "acc_1",
name: "High-risk tool use",
actorTypes: ["agent"],
actions: ["tools.invoke"],
resourceTypes: ["tool"],
requiredApproverRoleIds: ["role_acc_1_security-admin"],
});
const request = await approvals.createRequest({
accountId: "acc_1",
actor: { type: "agent", id: "agent_1" },
action: "tools.invoke",
resource: { resourceType: "tool", resourceId: "tool_1" },
requestedByActor: { type: "agent", id: "agent_1" },
reason: "Sending customer email",
});
await approvals.approve("acc_1", request.id, "user_approver");
// or approvals.reject("acc_1", request.id, "user_approver", "Not justified");Policy matching
matchesPolicy(request, policies) returns whether any active policy applies to a proposed action (by actor type, action, and resource type).
Related packages
@x12i/xentra-permissions— can returnrequires_human_approvalwhen wired@x12i/xentra-audit— approval events are written through the store@x12i/xentra-react—ApprovalInboxcomponent scaffold
Development
npm run build -w @x12i/xentra-approvals
npm test -w @x12i/xentra-approvalsLicense
MIT
