@ai-operations/ops-storage
v0.1.0
Published
SQLite persistence layer for AI Operations OS — tasks, workflows, receipts, SPARK learning data (WAL mode)
Maintainers
Readme
@ai-operations/ops-storage
SQLite persistence layer for tasks, workflows, approvals, and users in AI Operations OS.
Part of AI Operations OS — autonomous business workflow orchestration with safety enforcement.
Install
npm install @ai-operations/ops-storageRequires better-sqlite3 as a peer dependency.
Quick Start
import { createStores } from '@ai-operations/ops-storage';
import { createTask } from '@ai-operations/shared-types';
const { tasks, workflows, approvals, users, db } = createStores();
const task = createTask({ source: 'email', title: 'Reply to John' });
tasks.save(task);
const found = tasks.get(task.id);
const pending = tasks.list({ status: 'pending', limit: 20 });API
createStores(dbPath?): Stores
Convenience factory that creates a Database and all stores in one call. Defaults to ~/.ai-ops/data.db.
interface Stores {
tasks: TaskStore;
workflows: WorkflowStore;
approvals: ApprovalStore;
users: UserStore;
db: Database;
}Database
Opens/creates a SQLite database, creates all required tables on first run, and uses WAL mode for concurrency.
constructor(dbPath?: string) // defaults to ~/.ai-ops/data.db
close(): voidTaskStore
CRUD operations for Task records with filtering and pagination.
save(task: Task): void
get(id: string): Task | undefined
list(filter?: TaskFilter): Task[]
update(id: string, updates: Partial<Task>): Task | undefined
count(filter?: TaskFilter): number
delete(id: string): booleanTaskFilter—{ status?, source?, intent?, priority?, limit?, offset? }
WorkflowStore
Persistence for WorkflowRun and WorkflowStep records.
WorkflowRunFilter—{ taskId?, state?, limit?, offset? }
ApprovalStore
Persistence for Approval records with filtering by risk level and decision.
ApprovalFilter— Filter by decision status, risk level, task ID.
UserStore
User account management with typed input/output.
User/CreateUserInput— User record types for the users table.
Related Packages
@ai-operations/shared-types— Task, WorkflowRun, Approval types stored here@ai-operations/ops-core— Workflow engine that drives stored workflow runs@ai-operations/cord-adapter— ForensicEngine reads from these stores
License
MIT
