Skip to content

MEL Domain Basics ​

A MEL domain names your state, derived values, and allowed actions.

MEL is the authoring format for Manifesto domains. It compiles to data the runtime can run the same way each time.

A Small Domain ​

mel
domain Counter {
  type Label = {
    text: string
  }

  state {
    count: number = 0
    label: Label = { text: "Counter" }
  }

  computed doubled = count * 2

  action increment() {
    onceIntent {
      patch count = count + 1
    }
  }
}

What Each Part Means ​

PartPurpose
domain CounterNames the domain model
type LabelDefines a reusable MEL type
stateDeclares source-of-truth data and defaults
computedDeclares values derived from current state
actionDeclares a typed transition that callers can request
onceIntentMakes the action body run once for one submitted action
patchWrites the next state through the runtime

In Your App ​

typescript
import { createManifesto } from "@manifesto-ai/sdk";
import CounterMel from "./counter.mel";

const app = createManifesto(CounterMel, {}).activate();

await app.action.increment.submit();

const snapshot = app.snapshot();
console.log(snapshot.state.count);      // 1
console.log(snapshot.computed.doubled); // 2

Common Mistake ​

MEL is not executed like JavaScript. It defines the domain model. TypeScript code activates that model, submits actions, and reads Snapshots.

Next ​

Read MEL For App Developers for the small syntax set you need before wiring UI, routes, or agents. Then create the runtime in Creating an App and read it in Reading Snapshots. After that, learn what belongs in State and Computed Values. For full syntax, use the MEL Reference.