elizalang
Declare what an Eliza plugin is (its objects, the links between them, and the actions an agent may take on them) once. The compiler turns each declaration into typed VibeLang and refuses the ontology mistakes before your plugin compiles.
00 Why
Every Eliza plugin action today is a hand-built Action literal. Each one restates the same shape by hand: two descriptions, tags, the contexts and a contextGate over the same list, a roleGate, a parameter array, untyped parameter readers, and receipts that spell the resource kind as a string. Nothing checks that those agree with each other.
export const ptySessionAction: Action = {
name: "PTY_SESSION",
contexts: ["code", "terminal"],
contextGate: { anyOf: ["code", "terminal"] },
roleGate: { minRole: "OWNER" },
parameters: [
{ name: "sessionId", description: "Target PTY session identifier.", descriptionCompressed: "Session ID.",
required: false, schema: { type: "string" } },
…
],
handler: async (runtime, _message, _state, options) => {
const params = readParams(options)
const sessionId = readStr(params, "sessionId")
…
effectReceipts: [terminalReceipt("pty.stop", sessionId, "durable")]
},
}
The same action in elizalang states each fact once. The rest of this page builds it up, one form at a time.
01 A file is VibeLang plus three forms
A .eliza file is a .vibe file. Imports, functions and everything else pass through untouched. Three declaration forms are added: object, link and action. Each one is lowered onto the line it starts on, so an error from the VibeLang compiler on line 40 of the output is line 40 of your source.
import type { ActionResult } from "@elizaos/core"
object PtySession "pty.session" {
sessionId: string
cols: number
rows: number
}
action PTY_SESSION on PtySession {
…
}
export const ptySessionAction = PTY_SESSION.action({ … })
02 Objects: the things a plugin keeps
An object names a kind of thing with an identity. The quoted kind, namespace.kind, is what a receipt will name as its resource, so it is written once, here.
object Note "notes.note" {
noteId: string
pinned: boolean
}
const Note: OntologyObject<"notes.note"> = {
name: "Note",
kind: "notes.note",
properties: { noteId: "string",
pinned: "boolean" } }
Properties are string, number or boolean. Two objects of the same kind are refused: a receipt could not say which one it changed.
03 Links: how objects relate
A link names a relationship between two declared objects. -> is one target, ->> is many.
object Folder "notes.folder" {
folderId: string
}
link filedIn: Note -> Folder
link holds: Folder ->> Note
it becomes
const filedIn: OntologyLink = { name: "filedIn", from: Note, to: Folder, many: false }
const holds: OntologyLink = { name: "holds", from: Folder, to: Note, many: true }
Both ends must be objects declared in the same file. A typo is a compile error that lists what is declared.
04 Actions: what the agent may do, who may ask, and where
An action is always on an object. Its body is one statement per line. Three statements are required, because an action without them cannot be offered safely: what it does, the least role that may run it, and the contexts it appears in.
action PTY_SESSION on PtySession {
describe "Control interactive PTY sessions: list, read incremental bounded output, send input and wait in one call, resize, or stop."
brief "Control PTY sessions: list, read(cursor), send_wait(input), resize, stop."
tags resource:terminal capability:execute capability:delete
contexts code terminal
role OWNER
service PTY_SERVICE
model TEXT_SMALL
cache stable agent
strict
}
| Statement | Becomes on the registered Action |
|---|---|
describe "…" (required) | description, what the model reads to choose it |
role OWNER (required) | roleGate: { minRole: "OWNER" } |
contexts code terminal (required) | contexts and contextGate: { anyOf } over the same list |
brief "…" | descriptionCompressed |
tags facet:value … | tags |
service PTY_SERVICE | validate: offered only while that service is registered |
model TEXT_SMALL | modelClass |
cache stable agent | cacheStable: true, cacheScope: "agent" |
strict | toolSchemaStrict: true |
contexts and again as contextGate, and nothing stopped the two lists from drifting apart.05 Parameters: typed for the handler, described for the model
Each param gives a type and two strings: the description the model reads, then a brief one. ? marks it optional.
param op: "list" | "read" | "resize" | "send_wait" | "stop" "PTY operation to run." "Operation."
param sessionId?: string "Target PTY session identifier." "Session ID."
param input?: text "Keystrokes or command text to write for send_wait." "Input text."
param cols?: number "Terminal columns for resize (1-500)." "Cols."
| Type | The handler receives | Tool schema |
|---|---|---|
string | the string if it has a non-blank character, else undefined | string |
text | any string, the empty one too | string |
number | a finite number | number |
boolean | a boolean | boolean |
"a" | "b" | one of the literals | string with enum |
The handler gets them decoded and typed, so the hand-written readParams, readStr and readNum helpers go away. Every parameter arrives as its type or undefined, required ones too, because a model may omit or mistype anything.
export const ptySessionAction = PTY_SESSION.action({
handler: async (runtime, { op, sessionId, cursor, input = "" }, raw) => {
// op: "list" | "read" | "resize" | "send_wait" | "stop" | undefined
// raw: what the model actually sent, for an error message that quotes it
…
},
})
06 Effects and receipts: filed against the right object
An effect names a change the action can make, the operation a receipt records, and how it commits.
effect input "pty.input" provider_accepted
effect resize "pty.resize" provider_accepted
effect stop "pty.stop" durable
The handler files a receipt by effect name. The resource kind comes from the object the action is on, so it can't be misspelled:
PTY_SESSION.receipt("stop", sessionId, { receiptId, observedAt })
// → { operation: "pty.stop", resource: { kind: "pty.session", id: sessionId },
// outcome: "applied", commit: { kind: "durable", … }, … }
PTY_SESSION.receipt("stopp", sessionId, stamp)
// ✗ type error: "stopp" is not "input" | "resize" | "stop"
An effect's operation must sit in its object's namespace: "files.share" on a pty.session is refused at compile time.
07 What the compiler refuses
Here is a source with a mistake on almost every line:
object Note "notes.note" {
noteId: string
size: bigint
}
object Copy "notes.note" {
}
link filedIn: Note -> Folder
action NOTE_DELETE on Memo {
describe "Delete a note."
role SUPERUSER
colour red
param noteId: uuid "The note." "Note."
}
action NOTE_SHARE on Note {
contexts notes
cache stable forever
effect share "files.share" durable
effect publish "notes.publish" eventually
}
elizalang src: nothing is written for this file
bad.eliza:3 Write an object property as `name: type`, where type is string, number, boolean.
bad.eliza:6 Copy and Note are both kind `notes.note`: a receipt could not say which it changed.
bad.eliza:9 link filedIn names `Folder`, which is not an object declared in this file. Declared: Note, Copy.
bad.eliza:11 action NOTE_DELETE is on `Memo`, which is not an object declared in this file. Declared: Note, Copy.
bad.eliza:11 action NOTE_DELETE needs `role <minimum role>`: who may run it.
bad.eliza:11 action NOTE_DELETE needs `contexts <context>...`: where it is offered.
bad.eliza:13 `SUPERUSER` is not a role. Use NONE, GUEST, USER, MEMBER, ADMIN, OWNER.
bad.eliza:14 An action has no `colour`. Use describe, brief, tags, contexts, role, service, model, cache, strict, param, effect.
bad.eliza:15 `uuid` is not a parameter type. Use string, text, number, boolean, or a union of string literals such as "read" | "stop".
bad.eliza:18 action NOTE_SHARE needs `describe "..."`: what the model reads to choose it.
bad.eliza:18 action NOTE_SHARE needs `role <minimum role>`: who may run it.
bad.eliza:20 Write `cache stable <scope>`, where scope is global, agent, conversation, room, entity, turn, none.
bad.eliza:21 effect share files `files.share` against Note, whose kind is `notes.note`: the operation must start with `notes.`.
bad.eliza:22 Write `effect name "namespace.operation" commit`, where commit is durable, provider_accepted.
Every message names the line and says how to fix it. What the three forms can't see, the VibeLang type checker does, on the source's own line numbers: a handler that reads an undeclared parameter, or files an effect the action doesn't name.
08 How it fits Eliza
- Specs stay the source of truth. The compiler's own rules live in
spec/elizalang/index.mdas Quint, and the compiler calls the guards generated from it. A plugin's verified guards, such asvalidTerminalGeometry, stay in its spec and are called from the handler, never restated as an action statement. - One
genstep. A package adds"gen": "node --import vibelang/register ../elizalang/src/bin.vibe src". Turborepo runs it before build, typecheck and test, andsrc/**/*.eliza.vibeis generated and ignored by Git. - Agents learn it from a skill.
.agents/skills/elizalang/SKILL.mdlists every form and statement and what the compiler refuses, andAGENTS.mdpoints to it.
Action literals in Eliza today that could move over09 The whole example
import type { ActionResult } from "@elizaos/core"
object PtySession "pty.session" {
sessionId: string
cols: number
rows: number
}
action PTY_SESSION on PtySession {
describe "Control interactive PTY sessions: list, read incremental bounded output, send input and wait in one call, resize, or stop."
brief "Control PTY sessions: list, read(cursor), send_wait(input), resize, stop."
tags resource:terminal capability:execute capability:delete
contexts code terminal
role OWNER
service PTY_SERVICE
model TEXT_SMALL
cache stable agent
strict
param op: "list" | "read" | "resize" | "send_wait" | "stop" "PTY operation to run." "Operation."
param sessionId?: string "Target PTY session identifier." "Session ID."
param input?: text "Keystrokes or command text to write for send_wait." "Input text."
param cursor?: number "Character offset from previous read for incremental output." "Output cursor."
param cols?: number "Terminal columns for resize (1-500)." "Cols."
param rows?: number "Terminal rows for resize (1-500)." "Rows."
effect input "pty.input" provider_accepted
effect resize "pty.resize" provider_accepted
effect stop "pty.stop" durable
}
export const ptySessionAction = PTY_SESSION.action({
handler: async (runtime, { op, sessionId }, raw): Promise<ActionResult> => {
…
return { success: true, text: `Stopped PTY session ${sessionId}.`,
effectReceipts: [PTY_SESSION.receipt("stop", sessionId, stamp())] }
},
})