Mixer
Parse and Deploy SODEA Network Scripts
Explore MixerIntroduction
Mixer is a lightweight interpreter for .mix scripts — declarative SODEA scripts that define semantic object networks and their relationships. It parses the script, instantiates the defined objects, and uploads them to your Morpheus backend.
Ideal for setting up project spaces, use cases, and learning environments, Mixer simplifies network creation and object orchestration through code.
Current Capabilities
- .mix File Parsing: Interpret .mix scripts that define semantic objects and their connections.
- SODEA Object Creation: Generate and upload sobjects to Morpheus.
- Linking: Automatically resolve and create object relationships defined in the script.
- Execution Options: Choose between actual upload (`run`), local dry-run (`simulate`), or hook testing (`test`).
Example .mix Script
Below is a complete, working .mix script that demonstrates SODEA object creation, hooks, event emission, and subscriptions.
// Define IDs
define statusId = "urn:statusindicator:100"
define alarmId = "urn:alarmclock:100"
// Create the status indicator
create statusId {
"@context": "https://sodea.org/test#",
"@type": "StatusIndicator",
"status": "--"
}
// Create the alarm clock
create alarmId {
"@context": "https://sodea.org/alarm#",
"@type": "AlarmClock",
"time": "07:00"
}
// ── StatusIndicator Hooks ────────────────────────────────────────────────────
hook statusId.checkObject: javascript (obj, params, context) => {
obj.testedAt = new Date().toISOString();
obj.lastStatus = obj.status || "unknown";
return { updatedObject: obj };
}
hook statusId.onEvent: javascript (obj, params, context) => {
const log = (l,d) => console.log(l, JSON.stringify(d));
log('📩 Received event:', params);
if (params.eventType === 'AlarmTriggered') {
obj.status = 'ALARM!';
log('✅ STATUS set to ALARM!', obj.status);
} else if (params.eventType === 'AlarmReset') {
obj.status = 'off';
log('🔁 STATUS reset to off.', obj.status);
} else {
log('ℹ️ Unknown eventType:', params.eventType);
}
return { updatedObject: obj };
}
// Subscriptions
subscribe statusId.onEvent = AlarmTriggered where { "target": statusId }
subscribe statusId.onEvent = AlarmReset where { "target": statusId }
// ── AlarmClock Hooks ────────────────────────────────────────────────────────
hook alarmId.triggerAlarm: javascript (obj, params) => {
const event = {
eventType: 'AlarmTriggered',
payload: { target: 'urn:statusindicator:100' }
};
console.log('⏰ Triggering alarm event:', JSON.stringify(event));
return { trigger_event: event };
}
hook alarmId.resetAlarm: javascript (obj, params) => {
const event = {
eventType: 'AlarmReset',
payload: { target: 'urn:statusindicator:100' }
};
console.log('🔁 Triggering alarm reset event:', JSON.stringify(event));
return { trigger_event: event };
}
// ── Test Sequence ───────────────────────────────────────────────────────────
emit alarmId.event = triggerAlarm with { "target": alarmId }
emit alarmId.event = resetAlarm with { "target": alarmId }
Documentation & Resources (to be added)
Learn how to write .mix scripts and use Mixer to create semantic networks.