deriveActivity (activityState.ts)

diorama-builder · realtime

Activity State System — derives visual activity from gateway events. Maps event type + room preset → agent activity for 3D visualization. Pure functions, no React/Three.js dependencies. /

/**
 * Activity State System — derives visual activity from gateway events.
 *
 * Maps event type + room preset → agent activity for 3D visualization.
 * Pure functions, no React/Three.js dependencies.
 */

export type AgentActivity =
  | "idle"
  | "talking"
  | "working"
  | "testing"
  | "presenting"
  | "listening"
  | "sending"
  | "reviewing";

export interface ActivityRecord {
  activity: AgentActivity;
  startedAt: number;
  eventType: string;
  eventLabel: string;
  roomPreset: string;
}

/** How long an agent stays in an activity before returning to idle (ms). */
export const ACTIVITY_TIMEOUT_MS = 8000;

/**
 * Event type patterns → activity. Checked in order, first match wins.
 * Each entry: [substring to match in eventType, resulting activity].
 */
const EVENT_PATTERNS: Array<[

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key