@happyvertical/smrt-core
The object model, persistence layer, AI operations, manifests, and generated interfaces at the center of every smrt app.
What it gives you
The object model, persistence layer, AI operations, manifests, and generated interfaces at the center of every smrt app.
- 01Typed, column-backed list projections without object hydration
- 02Context memory and semantic search for durable learned patterns
- 03Change feeds, conditional reads, sync apply, REST, MCP, WebMCP, and CLI generation
- 04Recipes: declared user-facing units collected into the manifest, plus a cookbook document and engine
- 05A one-call smrt() Vite preset over the packages declared in smrt.config.ts
Recipes and cookbooks
A SmrtRecipe is a named, user-facing unit smaller than a package, such as Sales or Customers. Its static id, label, models, nav, requires, and options are read structurally by the scanner into the manifest and knowledge recipes. The /cookbook entry validates and migrates a cookbook v1 document; /cookbook/engine runs typed cookbook commands with idempotent retries, atomic batches, and receipts.
One Vite plugin call for a SvelteKit app
smrt() from @happyvertical/smrt-core/vite applies the decorator config and composes smrtConsumer and smrtPlugin with the SvelteKit conventions. The consumed packages are the declared list under consumer.packages in smrt.config.ts; a missing or malformed list fails the build. smrtPlugin and smrtConsumer remain public for custom setups. Generated routes resolve collections through the runtime exported from $lib/server/smrt; a hand-written getCollection export is deprecated.
Data shape rules
smrt requires a field only when its own code would be wrong or unsafe without it, and each such field states why. The app decides every other part of a table. An app hardens a smrt class with a subclass that overrides fields. A subclass with the same name replaces the class everywhere in the app. Migrate changes the database to match the code when that loses no data. It stops when it would lose or invent data, such as a field declared required while existing rows are empty.
Migrate is all or nothing
Migrate works out every change first. If any change stops, it applies none and reports what stopped and what it held back. Migrate also stops when a package it saw last time is missing. smrt does not start new code against a database that was not migrated for that build.
Models from data
runtimeModelEntry turns a definition into a manifest entry, and registerRuntimeModel registers it. The model then has storage, REST, MCP, and method surfaces without a class or a rebuild. planRuntimeModelDDL returns additive statements only. The host runs them in its own transaction, because smrt does not create the tables.
App models and cookbook tools
createAppModelEditor from the /app-models entry adds fields and lists to a cookbook with versioned, tracked edits. createCookbookToolService from /cookbook/tools supplies recipe tools, and an app customization set when given modelEditorFor. Removing a field or list, and undo, always need durable owner approval. Removing a list keeps its table and data.
Move a model or close its surface without a subclass
A class that moves between packages declares its old qualified names in previousQualifiedNames, and lookups by the old name keep resolving. smrt db:migrate-qualified-names rewrites stored names on request. ObjectRegistry.registerOverride closes the generated API, MCP, or CLI surface of a package model, or makes its tenancy required, at startup. Only complete closures are supported; reopening throws. The browser entry builds and evaluates without Node-only modules.
Package UI
No UI layer to carry
This package stays focused on models, runtime behavior, or tooling. Build its interface with smrt-ui, or use a related domain package that exposes a /svelte entry point.
Intentionally headless
Package previews
No playground module yet
This package does not currently export a ./playground module. Its component names and import path remain available in the Components tab.
Intentionally not registered
Generated interface
REST
The exact route set comes from each model's @smrt({ api }) policy
and the application manifest—not from a second controller definition.
GET /api/products
GET /api/products/:id
POST /api/products
PATCH /api/products/:idWhat stays consistent
- Tenant scope and operation permissions run before model access.
- OpenAPI and generated clients use the same manifest fields.
- Packages can expose read-only or custom action sets.
Generated interface
MCP
AI tools are generated from the methods you explicitly include. Their inputs are validated against the same model metadata used by REST and CLI.
products_list({ where, limit, orderBy })
products_get({ id })
products_create({ data })
products_update({ id, data })Agent-safe by construction
- Tool availability can be narrower than the HTTP API.
- Principal execution intersects RBAC, agent ceilings, and persona tools.
- Descriptions and schemas are emitted from source metadata.
Browser-native agent interface
WebMCP
The generated web definitions carry the same tool names, descriptions, and JSON Schema
inputs as MCP. smrt-web registers them with document.modelContext.
import { webMcpToolDefinitions } from '@happyvertical/smrt-virt-web';
import { registerWebMcpTools } from '@happyvertical/smrt-web';
// Omitting an exposure policy registers read-only tools only.
const dispose = registerWebMcpTools(webMcpToolDefinitions);The page keeps its security boundary
- Tools execute through generated REST fetchers as the signed-in page user.
- Authentication, tenant gates, permissions, and field policy stay server-side.
- Feature detection makes registration a safe no-op outside supported browsers.
Generated interface
CLI
The app CLI turns manifest resources into predictable operator commands while keeping package-specific actions close to their models.
smrt products list --limit 25 --order-by created_at:desc
smrt products get <id>
smrt products create --from-file ./record.jsonMade for automation
- Machine-readable output and file-based input.
- The same include/exclude policy as other surfaces.
- Migration, introspection, dispatch, and knowledge commands stay in smrt-cli.