API Reference
Quick reference for SMRT framework APIs. See documentation for detailed usage.
Core Classes
SmrtObject Base class for persistent entities with AI methods (is, do)SmrtCollection Collection manager for querying, CRUD, and batch operationsObjectRegistry Runtime registry for class/field metadata (globalThis singleton)DispatchBus Inter-agent asynchronous messaging with persistent subscriptionsGlobalInterceptors Plugin system for beforeList/Get/Save/Delete hooksSchemaComparer Compares current vs. desired database schemaManifestManager Reads, writes, and generates build-time manifestsDecorators
@smrt() Register a class with the framework for code generation@field() Configure field constraints (required, unique, nullable, transient)@meta() Mark field for STI meta storage in _meta_data JSONB@foreignKey() Many-to-one relationship (same-package only)@oneToMany() One-to-many relationship (transient, no DB column)@manyToMany() Many-to-many via junction table (transient, no DB column)AI Methods (SmrtObject)
is(criteria) Evaluate criteria against object, returns booleando(instructions) Perform action based on instructions, returns stringObject Methods (SmrtObject)
save() Upsert with STI validation, interceptors, auto-embeddingsdelete() Delete object from databaseinitialize() Load field initializers, apply options, load from DBloadRelated(field) Lazy-load a foreignKey relationship (cached)loadRelatedMany(field) Lazy-load a oneToMany relationshipgetSlug() Auto-generate slug from name/title/label/idtransformJSON(data) Override point for custom JSON serializationCollection Methods (SmrtCollection)
create(options) Static factory to create collection instanceget(id|slug|filter) Retrieve single object by ID, slug, or filterlist(options) Query with where, orderBy, limit, offset, includecount(options) Count objects matching criterialistByIds(ids) Batch fetch multiple objects in a single queryquery(sql, params) Execute raw SQL querygetOrUpsert(match, defaults) Get existing or create new objectWHERE Operators
String operators in the field key. Arrays auto-detect as IN.
= (default) { status: 'active' }>, <, >=, <= { 'price >': 100 }!= { 'status !=': 'archived' }in { 'category in': ['A', 'B'] } or auto-detected from arraysnot in { 'status not in': ['archived', 'deleted'] }like { 'name like': '%widget%' }contains { 'tags contains': 'featured' } (JSON)DispatchBus Methods
emit(type, payload, meta) Emit an event to the dispatch queuesubscribe(options) Create persistent subscription (survives restarts)on(pattern, handler) In-memory handler (immediate, fire-and-forget)process(subscriber, handler) Process pending dispatches for subscriberretry(options) Reset failed dispatches for retrycleanup(options) Delete old completed/failed dispatcheslist(filters) Query dispatches with status/source/type filtersAgent Exports
Agent Base agent class with lifecycle, dispatch, interestsAgentConfig DB-persisted agent configuration modelAgentSchedule Cron-based schedule model (_smrt_agent_schedules)TenantAgent Agent-to-tenant junction with hierarchy resolutionAgentUIRegistry Singleton registry for agent admin panels (from /ui)CLI Commands
smrt introspect Discover SMRT objects in projectsmrt db:status Show pending schema changessmrt db:migrate Apply migrationssmrt db:diff --generate Generate migration from changessmrt db:rollback Rollback migrationssmrt docs:claude Generate .claude/smrt-framework.mdsmrt generate:mcp Generate MCP serversmrt config:export Export agent config for SSGsmrt dispatch:* Dispatch management (list/process/retry/cleanup)Internal Tables
_smrt_migrations Framework schema version tracking_smrt_schema_migrations User schema migration tracking_smrt_registry Object metadata persistence_smrt_contexts Remembered context and learned patterns_smrt_embeddings Vector embeddings for semantic search_smrt_dispatch Inter-agent dispatch queue_smrt_dispatch_subscriptions Persistent dispatch subscriptions_smrt_signals Signal history audit log_smrt_agent_schedules Cron-based agent schedule definitionsTypeDoc Reference
Full API documentation is generated from source with TypeDoc.