Hooks
React hooks of the SDK - the Command Center and its registration hooks, the task inbox, real-time task events, deadline monitoring, the run console and notification preferences.
The hooks connect your components to the Command Center and to the person’s work. Most of them need the signed-in
user from Veripass’s AuthProvider; the Command Center hooks also need CommandCenterProvider.
Command Center
| Hook | What it does |
|---|---|
useCommandCenter() | Returns the Command Center: registerCommands, getContext, registry, executeIntent, allCommands, providers, isThinking, error… Returns null when no provider is mounted, so shared components can fall back to an empty object. |
useSommaticContextSource(source, deps) | Publishes a snapshot the model can read: { id, description, getData, ttl_ms? }. The snapshot is cached 30 seconds by default. |
useSommaticSurface(surface, deps) | Publishes a surface with its handlers and targets: { id, type, label, description?, targets?, handlers? }. |
useSommaticSelection(selection, deps) | Publishes the current selection: { type, content, surface_id }. |
useSommaticFocus(focus, deps) | Publishes the entity in focus: { entity_type, entity_id, label, metadata }. |
useCommandCenterAgent(options) | The inference loop on its own: classifyIntent turns a request into a plan and executePlan runs it. The panel already uses it; reach for it only to build your own interface. |
All registration hooks unregister on unmount and register again when deps change. How to use them in a page is in
Integration.
Tasks
useTaskInbox(options)
The signed-in person’s inbox, sorted by urgency and refreshed on a timer and whenever a task event arrives.
import { useTaskInbox } from '@sommatic/react-sdk';
function InboxBadge() {
const { counts, badgeSeverity, groups, isLoading, refresh } = useTaskInbox({ pollIntervalMs: 60000, pageSize: 10 });
return <span data-severity={badgeSeverity}>{counts.total}</span>;
}| Option | Default | |
|---|---|---|
enabled | true | Turns the hook off. |
pollIntervalMs | 60000 | How often it reloads. |
dueSoonThresholdMs | 1800000 | How close a deadline must be to count as “due soon” (30 minutes). |
pageSize | 10 | How many tasks it loads. |
It returns tasks, groups (overdue, dueSoon, critical, normal), counts, badgeSeverity, isLoading and
refresh.
useEventStream({ userIdentity, enabled, baseUrl })
Opens the task stream for one person and turns each task-assigned event into a sommatic::task-notification DOM
event, which TaskNotificationToast shows and useTaskInbox uses to refresh. Mount it once in your layout:
const { user } = useAuth();
useEventStream({ userIdentity: user?.identity, enabled: Boolean(user?.identity) });useTaskSLAMonitor(fetchActiveTasks, options)
Checks the person’s active tasks on a timer and emits sommatic::task-notification for tasks whose deadline is close
or has passed. fetchActiveTasks is an async function you provide that returns the tasks. Options: enabled,
onLoad (check on mount, default true), repeat (default true), intervalMs (default 15 minutes) and
dueSoonThresholdMs (default 30 minutes).
Notification preferences
useNotificationPreferences() reads the person’s preferences (pause, quiet hours, minimum priority, muted types and
per-app switches) from the browser’s local storage and keeps them in sync across tabs. readNotificationPreferences,
writeNotificationPreferences, isQuietNow and shouldNotify work with the same data outside React. The storage key
is NOTIFICATION_PREFS_KEY, and NOTIFICATION_PREFS_EVENT is the event fired when they change.
Workflows and apps
| Hook | What it does |
|---|---|
useSseConsole() | The controller of FlowsSseConsole: collects run events with stable ids and evaluates JavaScript against them, with $('evt-3'), $events and $last. Returns items, events, commandHistory, push, clear, reset and evaluate. |
useAppStateSync(sdk, state, deps, options) | For App Engine apps: saves the app’s view state through the runtime sdk (debounced, 5 seconds by default) and restores it when the app reopens, with options.onRestore. |
useLocalStorage(key, defaultValue) | A value kept in local storage. |