The data model for apps and agents
A typed object graph on the device. Plugins code against it, agents keep their memory in it and read its schema, and data from other systems meets in it. Writes land before the call returns, and peers merge when they connect.
class Task extends Type.makeObject<Task>(DXN.make('com.example.type.task', '0.1.0'))( Schema.Struct({ title: Schema.String, done: Schema.Boolean }),) {}
const open = db.query(Query.select(Filter.type(Task, { done: false })));open.subscribe(() => console.log(open.results.length));
// The subscriber has already run when `add` returns.const task = db.add(Obj.make(Task, { title: 'Ship the docs', done: false }));
// A CRDT change: it merges with any peer's edit to this task.Obj.update(task, (task) => { task.done = true;});One graph for apps, agents and external data
An agent saves what it learned as ordinary objects, linked to the work they describe and found again with the same query an application uses.
Every type reports its name and version and converts to JSON Schema, so an agent can see what a space holds, and add a type, while it runs.
Records synced from other systems become objects with foreign keys. A Ref can link a GitHub issue to a Linear task or a note.
A plugin declares its types and reads and writes objects. Its UI, its operations and its agents all share them.
Behavior you can rely on
A query over your local objects reflects db.add and Obj.update, and has told its subscribers, by the time the call returns.
org.dxos.echo.query#F-2The index and EDGE can lag this tab. ECHO checks each remote entry against local state and drops what local state contradicts.
org.dxos.echo.query#F-5A class built with Type.makeObject is both the runtime schema and the TypeScript instance type. There is no second definition to keep in sync.
org.dxos.echo#F-2A Ref field stores a DXN and loads its target lazily. A missing target is a typed error you can catch by tag.
org.dxos.echo#F-4