Midio docs
  • Getting Started
    • Welcome
    • Quick Start Guide
  • Your First Midio App
  • Guides
    • HTTP
      • Making HTTP Requests
      • Responding to HTTP Requests
      • How to reach your own endpoints
      • CORS
      • Server-Sent Events (SSE)
    • Branching
    • Loops
    • Map, filter, reduce
    • Working with Data
    • Expressions
    • Building Agents
      • Streaming Agent API (experimental)
    • Debugging
    • Secrets and Environment variables
    • Convert JSON to data nodes
    • Writing tests
    • Cleaning up your flows
  • Package Manager
  • Integrating with third party services
  • Troubleshooting
  • Tutorials
    • Connecting LLMs to MCP-servers using the MCP-client package
    • Making Your Own MCP Server in Midio
    • A Fast Path to Functional RAG Agents
    • How to build a streaming agent using Server-Sent Events (SSE)
  • Reference
    • The Midio Editor
      • The Node Editor
      • User Traces
      • Traces (execution)
      • Processes
      • Log
      • Services
      • Problems
      • Function Signature
      • Data
      • Settings
    • The Midio Language
      • Nodes and execution
      • Functions and Events
        • Anonymous functions
      • Modules
      • Contexts
      • Data type
      • Local variables
      • Portals
      • Waypoint node
      • Partial function application
  • The Midio Engine
  • Built in Nodes
    • Core (std)
    • HTTP
    • LLM
Powered by GitBook
On this page
  • Overview
  • Processes
  • Services
  • The Midio textual representation
  • Midio Language Syntax

Was this helpful?

Edit on GitHub

The Midio Engine

PreviousPartial function applicationNextBuilt in Nodes

Last updated 2 months ago

Was this helpful?

Overview

Midio compiled to bytecode, meaning that before the node graph is executed, it is compiled to a list of instructions, which is then executed by the [Midio VM](#The Midio VM). This makes the code run a lot faster than it would if we had to interpret the node graph during execution.

The Midio engine is a virtual machine that executes the bytecode produced by the compiler. It is responsible for hooking up all the native functionality that the code depends on, like all external functions, and services.

The bytecode is executed in Midio processes, of which several can run concurrently, executing different flows.

Processes

A process represents an isolated environment for bytecode to be executed in. It contains its own call stack, and its own memory heap, and is not able to affect other processes directly.

Processes are created by supplying it a module to run. It can then be handed to the scheduler, which will eventually schedule it for execution.

A process can be in one of the following states:

  • Runnable - The process is ready to be scheduled by the scheduler

  • DoneAndWaitingForCleanup - The process is done executing, and is waiting for the engine to clean up its resources, like heap and stack.

  • Error - The process has experienced an error, and is waiting for cleanup.

  • Paused - The process is paused for debugging purposes

  • Stepping - The process is in debugger state, and the middle of performing a single. The difference from being Runnable is that the process will enter the Paused state as soon as it hits an instruction corresponding to a node, like a CallFunction instruction.

Services

Services are not something the user directly interfaces with, but are accessed through various functions in the .

Services are components that provide various capabilities to your programs, such as offering an HTTP server, scheduling flows at specific intervals, and more. These services are shared between processes and are instantiated automatically when a node that requires the service is used. This process is entirely transparent to the user, and the way you interact with services is through funtions whose implementation happen to use them.

Currently, you cannot create your own service, but this will eventually be possible.

Some existing services include:

  • HttpServer: Enables the creation of HTTP APIs. Some functions that use this service include HttpEndpoint and HttpResponse.

  • Scheduler: Allows scheduling of flows to run at specific intervals. The Timer event uses this sevices.

  • Testing: Offers a way for tests to report their results. Some nodes using this service includes the Test event and the various assertion functions, like: AssertEqual, AssertTrue and AssertFalse.

  • Ephemeral Store: Provides an in-memory key-value store (non-persistent) for storing data between various flow executions. This service is accessed through the functions in the EphemeralStore module.

The Midio textual representation

Midio programs are stored using a textual representation, which maps almost one to one with the visual representation.

Midio Language Syntax

Midio is a declarative programming language with a textual representation, designed for node-based programming. Its primary features include the ability to define modules, functions, events, and properties, as well as supporting native implementation through external functions. This section provides an overview of the syntax used in Midio.

!!! note The midio textual representation is not designed to be written by hand, but is means to at least be understandable by a human. The syntax is easy enough to understand, but it is hard to get a sense of what a program is doing by only looking at the textual representation.

Modules

Modules in Midio are containers for functions and other elements. The hidden attribute determines whether the module should be visible in the editor or not.

module(hidden: true) ModuleName {
    // Module content (functions, events, types, nodes and arrows)
}

Functions

Functions in Midio can be either user-defined or external (native) functions.

User-defined functions:

func FunctionName {
	// input and output and parameter declarations
	in trigger execute
	out trigger continue
	in property input1
	out property output1

	// function body (node instances and arrows)
}

External functions:

extern func FunctionName {
	// only input and output and parameter declarations
}

External functions have a native implementation in Rust and cannot have a body.

Inputs, and Outputs

Inputs, and outputs are defined within functions using the in, out, and event keywords:

in(name: "inputName") property(Type) inputVariableName
out(name: "outputName") property(Type) outputVariableName

Parameters and Attributes

Parameters provide compile-time information to nodes, while attributes are optional values that can be used to configure modules, functions, events, inputs, or outputs:

parameter attributeName

Attributes are enclosed in parentheses, following the element they belong to:

module(attributeName: attributeValue) ModuleName
func(attributeName: attributeValue) FunctionName
event(attributeName: attributeValue) EventName
in(attributeName: attributeValue) property(Type) inputVariableName
out(attributeName: attributeValue) property(Type) outputVariableName

Properties and Types

Properties in Midio are used to store values and are declared with a type:

property(Type) propertyName

Identifiers

Identifiers in Midio follow conventional rules from languages like JavaScript, C, or Rust, which include:

  • Starting with a letter, underscore

  • Continuing with any combination of letters, digits, underscores, or dollar signs

Instances and Arrows

In the body of user-defined functions, instances of other functions and arrows are used to connect them:

instance(x: xPosition, y: yPosition, name: "InstanceName") instanceVariableName FunctionType {

}
inputPropertyName -> instanceVariableName.propertyName
instanceVariableName.propertyName -> outputPropertyName

This is a general overview of the syntax used in Midio. The language is designed to support a node-based programming paradigm, allowing for a flexible and visual approach to developing software.

standard library