Skip to content

Services - storage, server, model runtime

Flow stores data in SQLite at ~/.flow-studio/db/flow.sqlite. The Store type wraps that database.

pub struct Store { /* open(path), shared by all hosts */ }
// Runs and steps
pub fn list_runs(&self, limit: usize) -> Result<Vec<RunSummary>, StoreError>;
pub fn get_execution(&self, id: &str)
-> Result<Option<(ExecutionRecord, Vec<ExecutionStepRecord>, Vec<InterceptionRecord>)>, StoreError>;
pub fn upsert_step(&self, rec: &ExecutionStepRecord) -> Result<(), StoreError>;
// AI decision audit trail
pub struct AiAuditRecord { pub execution_id: String, pub node_id: String,
pub at: DateTime<Utc>, pub kind: String, pub payload: serde_json::Value }
pub fn record_ai_audit(&self, rec: &AiAuditRecord) -> Result<(), StoreError>;
pub fn list_ai_audit(&self, execution_id: &str) -> Result<Vec<AiAuditRecord>, StoreError>;

Audit kinds include ai_invocation, ai_routing_decision, ai_review_required / ai_review_resolved, ai_tool_call (coding-agent turns), and agent_edit_applied / agent_edit_rejected. Writes happen as part of the execution cycle via StorageSink, not after it.

Schedules (flow_schedules), template membership, and interception records live in the same database.

This is the host for the browser edition. It is an axum HTTP server that exposes FlowApp using the same command names the desktop uses. As a result, the React app runs unchanged against either transport.

  • POST /api/invoke - the command bridge ({ cmd, args }), kept in lockstep with the Tauri command set.
  • POST /api/run - execute a graph with the event stream over SSE.
  • GET /health - liveness.

To add a host-visible command, you implement it in both the Tauri commands and flow-server/src/invoke.rs. Cross-host parity is a release gate.

This is the lifecycle manager for the local inference engine. It is re-exported as flow_application::llm_server.

pub struct LlmServerHandle;
pub struct LlmServerStatus { pub running: bool, pub endpoint: Option<String>,
pub model_path: Option<String>, pub pid: Option<u32> }
pub struct LlamaParams { /* context, gpu layers, threads, flash-attn,
kv-cache type, enable_thinking, ... */ }

It resolves the engine binary from the managed ~/.flow-studio/engines/ dir, a saved setting, or $PATH. On first use, it fetches the binary for the current OS and arch. It then starts llama-server with a chosen .gguf, discovers the OpenAI-compatible endpoint, and reports status. FlowApp::start_local_llm and stop_local_llm wrap it and keep local_ai_base_url in sync, so the local AI provider and the DSL generator always point at the managed server.