@ormai/tools
v0.1.1
Published
Generic database tools for OrmAI — query, get, aggregate, create, update, delete
Downloads
20
Maintainers
Readme
@ormai/tools
Generic database tools (query, get, aggregate, create, update, delete, bulk update, describe schema) for AI agents.
@ormai/tools provides eight generic database tools that implement the BaseTool interface from @ormai/core. Each tool is policy-aware and uses an OrmAdapter for query execution.
| Tool | Description |
|------|-------------|
| db.describe_schema | List available models, fields, and relations |
| db.query | Query records with filters, ordering, pagination |
| db.get | Get a single record by primary key |
| db.aggregate | Perform aggregations (count, sum, avg, min, max) |
| db.create | Create a new record |
| db.update | Update a record by primary key |
| db.delete | Delete (soft or hard) a record |
| db.bulk_update | Update multiple records by IDs |
Installation
npm install @ormai/core @ormai/tools
# Plus an adapter, e.g.:
npm install @ormai/prisma @prisma/clientQuick Start
import { PrismaClient } from '@prisma/client';
import { PrismaAdapter } from '@ormai/prisma';
import { createToolset, createContext } from '@ormai/core';
import { createGenericTools } from '@ormai/tools';
const prisma = new PrismaClient();
const adapter = new PrismaAdapter({ prisma });
const schema = await adapter.introspect();
const policy = createPolicyBuilder('dev').build();
const tools = createGenericTools({ adapter, policy, schema });
const ctx = createContext({ tenantId: 't1', userId: 'u1', db: prisma });
const result = await tools.get('db.query').execute({
model: 'Order',
where: [{ field: 'status', op: 'eq', value: 'pending' }],
take: 10,
}, ctx);API Reference
DescribeSchemaTool-- Schema introspection toolQueryTool-- Filtered, paginated query toolGetTool-- Single record fetch by PKAggregateTool-- Aggregation tool (count, sum, avg, min, max)CreateTool-- Record creation toolUpdateTool-- Record update toolDeleteTool-- Record deletion tool (soft or hard)BulkUpdateTool-- Bulk update by IDscreateGenericTools(options)-- Create and register all 8 toolsGenericToolsOptions-- Configuration type
Related Packages
- @ormai/core -- Core types, policy engine, tool registry
- @ormai/prisma -- Prisma adapter
- @ormai/drizzle -- Drizzle adapter
- @ormai/typeorm -- TypeORM adapter
- @ormai/store -- Audit logging stores
- @ormai/integrations -- Agent framework integrations
License
MIT
