Platform Constraints
mimOE is designed for device-first execution with specific technical constraints. Understanding these limitations is essential for building robust mims and AI agents that work reliably across platforms.
JavaScript Constraints
Not a Node.js Runtime
The mimOE JavaScript runtime is NOT Node.js. It is a custom ES5-based runtime. Node.js built-in modules are not available.
The most common mistake developers make is trying to import Node.js modules:
// ❌ Node.js modules are NOT available
const fs = require('fs'); // Not available
const path = require('path'); // Not available
const http = require('http'); // Not available
const net = require('net'); // Not available
const crypto = require('crypto'); // Not available
const child_process = require('child_process'); // Not available
Instead, use the mimOE runtime APIs provided via the context object:
// ✅ Use mimOE runtime APIs
app.get('/data', (request, response) => {
// HTTP requests via context.http (with callbacks)
context.http.request({
url: 'https://api.example.com/data',
success: (result) => {
// Storage via context.storage (synchronous)
context.storage.setItem('key', result.data);
response.end(result.data);
},
error: (err) => {
response.statusCode = 500;
response.end(err.message);
}
});
});
For the complete list of available APIs, see the JavaScript mim Runtime API.
ES5 Runtime with Transpilation
The mimOE JavaScript runtime is ES5-compatible. However, this is easily handled by using Webpack with Babel to transpile modern JavaScript:
// You can write modern JavaScript
const add = (a, b) => a + b;
const message = `Hello ${name}`;
async function fetchData() { ... }
// Webpack + Babel transpiles to ES5 for deployment
See Toolchain Setup for configuration details.
What's Available vs. What's Not
| Available | Not Available |
|---|---|
context.http | fetch, XMLHttpRequest |
context.storage | fs, localStorage |
context.edge | net, dgram |
JSON, Math, Date, RegExp | setTimeout, setInterval |
Array methods (map, filter, etc.) | Buffer (Node.js) |
console.log (debugging) | process, __dirname |
Stateless Execution Constraint
This is the most fundamental constraint of mimOE's serverless architecture.
No State Persists Between Requests
// ❌ WRONG - State is lost after each request
var requestCount = 0;
app.get('/count', (request, response) => {
requestCount++; // Always 1!
response.end(JSON.stringify({ count: requestCount }));
});
// ✅ CORRECT - Use context.storage
app.get('/count', (request, response) => {
var count = parseInt(context.storage.getItem('requestCount') || '0');
var newCount = count + 1;
context.storage.setItem('requestCount', String(newCount));
response.end(JSON.stringify({ count: newCount }));
});
No Background Tasks
There are no timers, intervals, or background processes:
// ❌ Not available
setTimeout(function() {
// Never runs
}, 1000);
setInterval(function() {
// Never runs
}, 5000);
Alternative: Use external schedulers (cron jobs, cloud functions) to trigger mims via HTTP.
WASM Constraints
No WASI Support
mimOE's WebAssembly runtime does not support WASI (WebAssembly System Interface).
// ❌ WASI functions not available
use std::fs::File; // Won't work
use std::env; // Won't work
Alternative: Use mimOE's custom imported functions:
// ✅ Use mimOE imports
extern "C" {
fn storage_get(key_ptr: *const u8, key_len: usize) -> i32;
fn http_get(url_ptr: *const u8, url_len: usize) -> i32;
}
See WASM mims for more information (detailed API reference coming soon).
Networking Constraints
No Direct Socket Access
mims cannot create raw sockets or listen on ports:
// ❌ Not available
const net = require('net');
const server = net.createServer();
Alternative: Use context.http for outbound HTTP requests. Inbound requests are handled by the runtime.
HTTP/HTTPS for External Requests
Outbound requests support both HTTP and HTTPS:
context.http.request({
url: 'https://api.example.com/data',
success: (result) => {
response.end(result.data);
},
error: (err) => {
response.statusCode = 500;
response.end(err.message);
}
});
No Streaming (Current Limitation)
WebSockets, Server-Sent Events (SSE), and chunked transfer encoding are not currently supported:
// ❌ Not supported
const ws = new WebSocket('ws://example.com');
// ❌ Not supported
response.setHeader('Transfer-Encoding', 'chunked');
Streaming support (WebSockets, SSE) is planned for future releases.
Storage Constraints
Key-Value Store Only
context.storage is a key-value store with tag support, not a relational database:
// ✅ Simple key-value operations (synchronous)
context.storage.setItem('user:123', JSON.stringify({ name: 'Alice' }));
var user = JSON.parse(context.storage.getItem('user:123'));
// ✅ Tagged storage for collections
context.storage.setItemWithTag('user:123', JSON.stringify(user), 'users');
// ✅ Paginated queries with filters
context.storage.getJsonItemsPaginated(0, 10, callback, {
tag: 'users',
filters: [{ jsonPath: '$.age', comparisonOperator: '>', value: '18' }]
});
// ❌ SQL queries not available
context.storage.query('SELECT * FROM users WHERE age > 18'); // Not available
Alternative: For complex relational queries, use an external database via context.http.
Cross-Platform Considerations
Platform-Specific Paths
File paths and conventions differ across platforms:
// ❌ Hardcoded paths won't work cross-platform
var configPath = '/Users/alice/config.json'; // macOS only
// ✅ Use context.storage for portable persistence
context.storage.setItem('config', JSON.stringify(configData));
Mobile Platform Differences
On iOS and Android, mimOE runs embedded within an application:
- Integrated within your app (not standalone)
- Background execution follows OS guidelines
- App sandbox restrictions apply
Workarounds and Best Practices
Use Polyfills
For missing features, use polyfills via Webpack:
// webpack.config.js
module.exports = {
resolve: {
fallback: {
"promise": require.resolve("promise-polyfill"),
"buffer": require.resolve("buffer/")
}
}
};
Optimize for Stateless
Design mims for stateless execution:
- Use
context.storagefor any data that must persist - Keep request handlers pure functions when possible
- Cache expensive computations in storage
- Validate all inputs (don't assume previous state)
Use Transactions for Consistency
Use lockExecute for atomic operations:
// ❌ Not atomic - could be inconsistent if interrupted
context.storage.setItem('balance:alice', String(aliceBalance - amount));
context.storage.setItem('balance:bob', String(bobBalance + amount));
// ✅ Atomic - all operations execute together
context.storage.lockExecute(function() {
context.storage.setItem('balance:alice', String(aliceBalance - amount));
context.storage.setItem('balance:bob', String(bobBalance + amount));
});
Constraint Summary Table
| Constraint | Impact | Workaround |
|---|---|---|
| Not Node.js | No fs, net, path, etc. | Use context.* APIs |
| ES5 runtime | No modern JS natively | Use Webpack + Babel |
| Stateless | No persistent variables | context.storage |
| No WASI | Limited WASM stdlib | Custom imports |
| No WebSockets | No real-time push | Polling or external service |
| KV storage only | No complex queries | External database via HTTP |
Next Steps
Now that you understand the constraints:
- JavaScript Development: Build with JavaScript (ES5)
- ES5 Patterns Guide: ES5 patterns and techniques
- WASM Development: Build with WebAssembly
- Getting Started: Set up your environment
These constraints enable mimOE's portability, security, and efficiency. Design with them in mind rather than fighting against them.