qwed-open-responses
v0.2.2
Published
Verification guards for AI agent outputs - Works with OpenAI, LangChain, Express.js
Maintainers
Readme
QWED Open Responses (Node.js)
Verification guards for AI agent outputs in Node.js/Express applications.
Installation
npm install qwed-open-responsesQuick Start
import express from 'express';
import { createQWEDMiddleware, ToolGuard, SafetyGuard } from 'qwed-open-responses';
const app = express();
app.use(express.json());
// Add verification middleware
app.use(createQWEDMiddleware({
guards: [new ToolGuard(), new SafetyGuard()],
blockOnFailure: true,
}));
app.post('/api/agent', (req, res) => {
// Response will be verified before sending
res.json({
tool_calls: [
{ name: 'search', arguments: { query: 'weather' } }
]
});
});Guards
ToolGuard
Blocks dangerous tool calls.
const guard = new ToolGuard({
blockedTools: ['execute_shell', 'delete_file'],
allowedTools: ['search', 'calculator'], // Whitelist mode
});SafetyGuard
Detects PII and prompt injection.
const guard = new SafetyGuard({
checkPii: true,
checkInjection: true,
});SchemaGuard
Validates JSON structure.
const guard = new SchemaGuard({
type: 'object',
required: ['name', 'age'],
});MathGuard
Verifies calculations.
const guard = new MathGuard({ tolerance: 0.01 });Middleware Options
createQWEDMiddleware({
guards: [], // Guards to apply
blockOnFailure: true, // Block failed responses
verbose: false, // Log verification results
skipPaths: ['/health'], // Paths to skip
onError: (result, req, res) => {
// Custom error handler
},
});Verify Request Bodies
import { verifyRequestBody, ToolGuard } from 'qwed-open-responses';
app.post('/api/execute',
verifyRequestBody({ guards: [new ToolGuard()] }),
(req, res) => {
// Request body is verified
}
);Direct Verification
import { ResponseVerifier, ToolGuard } from 'qwed-open-responses';
const verifier = new ResponseVerifier([new ToolGuard()]);
const result = verifier.verify({
tool_calls: [{ name: 'search', arguments: {} }]
});
if (result.verified) {
console.log('✅ Safe to execute');
} else {
console.log('❌ Blocked:', result.blockReason);
}Links
- GitHub: QWED-AI/qwed-open-responses
- PyPI (Python): qwed-open-responses
- Docs: docs.qwedai.com
License
Apache 2.0
