@veritera.ai/eydii-mastra
v0.1.2
Published
EYDII Verify middleware and tools for Mastra — verify every agent action before execution
Maintainers
Readme
@veritera.ai/eydii-mastra
EYDII Verify middleware and tools for Mastra -- verify every agent action before execution.
Install
npm install @veritera.ai/eydii-mastra @veritera.ai/eydii-verify@mastra/core is a peer dependency and must be installed in your project.
Quick Start
EydiiIntegration
Shared verification client for use across agents, tools, and middleware.
import { EydiiIntegration } from "@veritera.ai/eydii-mastra";
const eydii = new EydiiIntegration({
apiKey: "vt_live_...",
policy: "production-safety",
});
const result = await eydii.verify("payment.create", { amount: 500 });
if (!result.verified) {
console.log("Blocked:", result.reason);
}eydiiVerifyTool
A Mastra Tool that agents can call to explicitly verify an action.
import { Agent } from "@mastra/core";
import { eydiiVerifyTool } from "@veritera.ai/eydii-mastra";
const agent = new Agent({
tools: {
eydii_verify: eydiiVerifyTool({
apiKey: "vt_live_...",
policy: "finance-controls",
}),
},
});eydiiMiddleware
Middleware that verifies every tool call before execution. If verification fails, the tool is never called.
import { Agent } from "@mastra/core";
import { eydiiMiddleware } from "@veritera.ai/eydii-mastra";
const middleware = eydiiMiddleware({
apiKey: "vt_live_...",
policy: "production-safety",
failClosed: true,
});
const agent = new Agent({
middleware: [middleware],
});eydiiWrapTool
Wraps any individual Mastra tool with EYDII verification.
import { eydiiWrapTool } from "@veritera.ai/eydii-mastra";
const protectedTool = eydiiWrapTool(myPaymentTool, {
apiKey: "vt_live_...",
policy: "finance-controls",
});
const agent = new Agent({
tools: { payment: protectedTool },
});Configuration
All exports accept the same EydiiConfig options:
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| apiKey | string | VERITERA_API_KEY env | EYDII API key (vt_live_... or vt_test_...) |
| baseUrl | string | https://id.veritera.ai | EYDII API base URL |
| agentId | string | "mastra-agent" | Agent identifier for audit trail |
| policy | string | -- | Policy name to evaluate against |
| failClosed | boolean | true | Block actions when verification service errors |
| timeout | number | 10000 | Request timeout in milliseconds |
| skipActions | string[] | [] | Actions that bypass verification |
| onVerified | function | -- | Callback when an action is verified |
| onBlocked | function | -- | Callback when an action is blocked |
Error Handling
When an action is blocked, a EydiiBlockedError is thrown:
import { EydiiBlockedError } from "@veritera.ai/eydii-mastra";
try {
await agent.execute(task);
} catch (err) {
if (err instanceof EydiiBlockedError) {
console.log("Action:", err.action);
console.log("Reason:", err.reason);
console.log("Verification ID:", err.verificationId);
}
}Environment Variable
Set VERITERA_API_KEY to avoid passing apiKey in every config:
export VERITERA_API_KEY=vt_live_...License
MIT
