Skip to content

Store API Reference

FlowDrop uses Svelte 5 rune-based stores for state management. All stores are module-level singletons — import and call getter functions directly.

The primary store for workflow state, dirty tracking, and node/edge mutations.

import {
getWorkflowStore,
getIsDirty,
getWorkflowId,
getWorkflowName,
getWorkflowNodes,
getWorkflowEdges,
getWorkflowMetadata,
getWorkflowFormat,
getWorkflowChanged,
getWorkflowValidation,
getConnectedHandles
} from '@flowdrop/flowdrop/editor';
FunctionReturnsDescription
getWorkflowStore()Workflow | nullCurrent workflow object
getIsDirty()booleanWhether workflow has unsaved changes
getWorkflowId()string | nullCurrent workflow ID
getWorkflowName()stringWorkflow display name
getWorkflowNodes()WorkflowNode[]All nodes
getWorkflowEdges()WorkflowEdge[]All edges
getWorkflowMetadata()WorkflowMetadataMetadata (created, updated, version)
getWorkflowFormat()stringWorkflow format identifier
getWorkflowChanged(){nodes, edges, name}Reactive change tracker
getWorkflowValidation(){hasNodes, hasEdges, nodeCount, edgeCount, isValid}Validation summary
getConnectedHandles()Set<string>Set of connected port handle IDs
import { getWorkflow, isDirty, markAsSaved } from '@flowdrop/flowdrop/editor';
const workflow = getWorkflow(); // Snapshot, not reactive
const dirty = isDirty(); // Snapshot
markAsSaved(); // Clears dirty flag
import { workflowActions } from '@flowdrop/flowdrop/editor';
MethodParametersDescription
initialize(workflow)WorkflowLoad a workflow into the store
updateWorkflow(workflow)WorkflowReplace the entire workflow
addNode(node)WorkflowNodeAdd a node
removeNode(nodeId)stringRemove a node by ID
updateNode(nodeId, updates)string, Partial<WorkflowNode>Update node properties
addEdge(edge)WorkflowEdgeAdd an edge
removeEdge(edgeId)stringRemove an edge by ID
updateNodes(nodes)WorkflowNode[]Replace all nodes
updateEdges(edges)WorkflowEdge[]Replace all edges
updateName(name)stringChange workflow name
updateMetadata(metadata)Partial<Workflow['metadata']>Update metadata fields
batchUpdate(updates){nodes?, edges?, name?, description?, metadata?}Apply multiple changes atomically
clear()Reset the store
pushHistory(description?)string?Manually push a history snapshot
import { setOnDirtyStateChange, setOnWorkflowChange } from '@flowdrop/flowdrop/editor';
setOnDirtyStateChange((isDirty) => {
console.log('Dirty state:', isDirty);
});
setOnWorkflowChange((workflow, changeType) => {
console.log('Changed:', changeType);
});

Manages undo/redo with snapshot-based history.

import { getCanUndo, getCanRedo, getHistoryState } from '@flowdrop/flowdrop/editor';
FunctionReturnsDescription
getCanUndo()booleanWhether undo is available
getCanRedo()booleanWhether redo is available
getHistoryState()HistoryStateFull history state (entries, current index)
import { historyActions } from '@flowdrop/flowdrop/editor';
MethodReturnsDescription
undo()booleanUndo last change
redo()booleanRedo last undone change
clear(currentWorkflow?)voidClear all history
startTransaction(workflow, description?)voidBegin grouping changes
commitTransaction()voidCommit grouped changes as one step
cancelTransaction()voidRevert grouped changes
pushState(workflow, options?)voidManually push a snapshot
initialize(workflow)voidInitialize with a starting state
interface HistoryState {
entries: HistoryEntry[];
currentIndex: number;
maxEntries: number;
}
interface HistoryEntry {
workflow: Workflow;
timestamp: number;
description?: string;
}
interface PushOptions {
description?: string;
force?: boolean;
}

Manages editor settings with localStorage persistence and optional API sync.

import {
getSettings,
getThemeSettings,
getEditorSettings,
getUiSettings,
getBehaviorSettings,
getApiSettings,
getTheme,
getResolvedTheme,
getSyncStatus
} from '@flowdrop/flowdrop/settings';
FunctionReturnsDescription
getSettings()FlowDropSettingsAll settings
getThemeSettings()ThemeSettingsTheme preferences
getEditorSettings()EditorSettingsEditor behavior settings
getUiSettings()UISettingsUI preferences
getBehaviorSettings()BehaviorSettingsBehavior flags
getApiSettings()ApiSettingsAPI configuration
getTheme()ThemePreference'light' | 'dark' | 'auto'
getResolvedTheme()ResolvedTheme'light' | 'dark' (after resolving auto)
getSyncStatus(){status, lastSyncedAt, error}API sync state
import { updateSettings, resetSettings } from '@flowdrop/flowdrop/settings';
updateSettings({ theme: { preference: 'dark' } });
resetSettings(['theme', 'editor']); // Reset specific categories
import { setTheme, toggleTheme, cycleTheme } from '@flowdrop/flowdrop/settings';
setTheme('dark'); // Set explicit theme
toggleTheme(); // Toggle light/dark
cycleTheme(); // Cycle light → dark → auto
import { onSettingsChange } from '@flowdrop/flowdrop/settings';
const unsubscribe = onSettingsChange((newSettings, changedKeys) => {
console.log('Settings changed:', changedKeys);
});
// Later: unsubscribe();

Manages playground sessions, messages, and execution state.

import {
getCurrentSession,
getSessions,
getMessages,
getIsExecuting,
getIsLoading,
getError,
getMessageCount,
getChatMessages,
getLogMessages,
getInputFields,
getSessionCount,
getCurrentSessionId
} from '@flowdrop/flowdrop/playground';
FunctionReturnsDescription
getCurrentSession()PlaygroundSession | nullActive session
getSessions()PlaygroundSession[]All sessions
getMessages()PlaygroundMessage[]All messages in current session
getIsExecuting()booleanWhether a workflow is running
getIsLoading()booleanWhether data is loading
getError()string | nullCurrent error message
getMessageCount()numberTotal message count
getChatMessages()PlaygroundMessage[]Chat-type messages only
getLogMessages()PlaygroundMessage[]Log-type messages only
getInputFields()PlaygroundInputField[]Available input fields
getSessionCount()numberTotal session count
getCurrentSessionId()string | nullActive session ID
import { playgroundActions } from '@flowdrop/flowdrop/playground';
MethodDescription
setCurrentSession(session)Set the active session
addSession(session)Add a new session
removeSession(sessionId)Remove a session
switchSession(sessionId)Switch to a different session
addMessage(message)Add a message
addMessages(messages)Add multiple messages
clearMessages()Clear all messages
setExecuting(executing)Set execution state
setLoading(loading)Set loading state
setError(error)Set error message
reset()Reset all playground state

Manages human-in-the-loop interrupts with a state machine for each interrupt’s lifecycle.

import {
getPendingInterrupts,
getPendingInterruptCount,
getResolvedInterrupts,
getIsAnySubmitting,
getInterrupt,
isInterruptPending,
isInterruptSubmitting
} from '@flowdrop/flowdrop/playground';
FunctionReturnsDescription
getPendingInterrupts()InterruptWithState[]Interrupts awaiting action
getPendingInterruptCount()numberCount of pending interrupts
getResolvedInterrupts()InterruptWithState[]Completed interrupts
getIsAnySubmitting()booleanWhether any interrupt is being submitted
getInterrupt(id)InterruptWithState | undefinedGet interrupt by ID
isInterruptPending(id)booleanCheck if specific interrupt is pending
isInterruptSubmitting(id)booleanCheck if specific interrupt is submitting
import { interruptActions } from '@flowdrop/flowdrop/playground';
MethodDescription
addInterrupt(interrupt)Add an interrupt
addInterrupts(interrupts)Add multiple interrupts
startSubmit(id, value)Begin submitting a response
submitSuccess(id)Mark submission as successful
submitFailure(id, error)Mark submission as failed
startCancel(id)Begin cancelling an interrupt
retry(id)Retry a failed submission
resolveInterrupt(id, value)Resolve an interrupt
cancelInterrupt(id)Cancel an interrupt
clearInterrupts()Clear all interrupts
reset()Reset the store

Each interrupt transitions through these states:

pending → submitting → resolved
→ error → submitting (retry)
pending → cancelling → cancelled

Manages node category definitions.

import {
getCategories,
getCategoryLabel,
getCategoryIcon,
getCategoryColor,
getCategoryDefinition,
initializeCategories
} from '@flowdrop/flowdrop/editor';
FunctionReturnsDescription
getCategories()CategoryDefinition[]All categories sorted by weight
getCategoryLabel(category)stringDisplay label for a category
getCategoryIcon(category)stringIconify icon ID for a category
getCategoryColor(category)stringCSS color for a category
getCategoryDefinition(category)CategoryDefinition | undefinedFull definition
initializeCategories(categories)voidLoad categories from API