The Runtime

The Runtime is the authoritative entry point for all application functionality in a Foresight Development Kit client.

Responsibilities

  1. Global Entry Point: Handles all high-level commands, such as opening projects or connecting to the cloud.
  2. State Management: Owns the versioned state storage and provides the only path to access or mutate it.
  3. Async Coordination: Manages the execution of asynchronous work, including Tools and Scripts.
  4. Undo/Redo: Orchestrates the undo and redo stack, ensuring consistency even during active async operations.
  5. Tool Lifecycle: Manages the starting and stopping of tools, ensuring only one tool is active at a time to prevent state conflicts.

Exclusive Execution

To ensure robustness and prevent race conditions, all calls into the runtime, whether they are API commands or Statements, are executed exclusively. Only one asynchronous command can be running at a given time.

UI and Extensions Integration

The Runtime’s statement-based architecture enables several key features:

  • Action Search: Since every action the user can perform through the UI is a callable Statement, features like search-based action menus can be built easily.
  • Runtime Extensions: Runtime Extensions are built directly on top of the Runtime, allowing third-party WASM scripts to execute Statements and interact with the project state in a sandboxed environment.
  • Macros and Scripting: Because the Runtime coordinates serializable Statements, user actions can be recorded into macros or manually scripted for automation.