Skip to main content

EvalContext

The context object passed to eval, enrichment, action, filter, and condition functions.
interface EvalContext {
  entries: Record<string, unknown>[];  // Combined session + subagent JSONL entries, each tagged with _source
  stats: EvalLogStats;                 // Computed stats across all entries
  projectName: string;                 // Encoded project folder name
  sessionId: string;                   // Session UUID
  source: string;                      // "session" or "agent-{id}"
  subagentType?: string;               // e.g. 'Explore', 'Bash' (subagent scope only)
  subagentDescription?: string;        // Short description (subagent scope only)
  parentSessionId?: string;            // Parent session ID (subagent scope only)
  evalResults?: Record<string, {       // Cached eval results (cachedOnly views only)
    pass: boolean;
    score: number;
    error?: string;
    message?: string;
  }>;
}
entries contains raw JSONL data. Every line is parsed as JSON. Each entry has a _source field: "session" for main session entries, "agent-{id}" for subagent entries.

EvalLogStats

Computed stats across all entries (session + subagents combined).
interface EvalLogStats {
  turnCount: number;      // Number of conversation turns
  userCount: number;      // Number of user messages
  assistantCount: number; // Number of assistant responses
  toolCallCount: number;  // Total tool invocations
  subagentCount: number;  // Number of subagent spawns
  duration: string;       // Formatted duration (e.g. "2m 15s")
  models: string[];       // Distinct model IDs used
}

EvalResult

Returned by eval functions.
interface EvalResult {
  pass: boolean;                       // Did the eval pass?
  score?: number;                      // 0-1, clamped automatically (default: 1.0)
  message?: string;                    // Shown in the UI
  metadata?: Record<string, unknown>;  // Arbitrary data
}

EnrichmentResult

Returned by enrichment functions.
type EnrichmentResult = Record<string, string | number | boolean>;

ActionResult

Returned by action functions.
interface ActionResult {
  output?: string;                   // Free-form text (rendered in a monospace block with copy button)
  status: 'success' | 'error';      // Determines the icon in the results panel
  message?: string;                  // Short summary shown in the UI
}

ActionContext

Passed to action functions. Extends EvalContext with cached results.
interface ActionContext extends EvalContext {
  evalResults: Record<string, EvalRunResult>;
  enrichmentResults: Record<string, EnrichRunResult>;
}

AlertContext

Passed to alert callbacks.
interface AlertContext {
  projectName: string;
  sessionId: string;
  evalSummary?: EvalRunSummary;
  enrichSummary?: EnrichRunSummary;
}

EvalRunSummary

interface EvalRunSummary {
  results: EvalRunResult[];
  totalDurationMs: number;
  passCount: number;
  failCount: number;
  errorCount: number;
  skippedCount: number;
}

EnrichRunSummary

interface EnrichRunSummary {
  results: EnrichRunResult[];
  totalDurationMs: number;
  errorCount: number;
  skippedCount: number;
}

ConditionFunction

type ConditionFunction = (context: EvalContext) => boolean | Promise<boolean>;

FilterValue

type FilterValue = boolean | number | string;

FilterFunction

type FilterFunction = (context: EvalContext) => FilterValue | Promise<FilterValue>;

FilterOptions

interface FilterOptions {
  label?: string;                // Human-readable tile label (defaults to name)
  condition?: ConditionFunction; // Per-filter gate
}

FilterMeta

Metadata auto-derived from computed filter values. Discriminated union by type:
type FilterMeta =
  | { type: 'boolean'; name: string; label: string }
  | { type: 'number';  name: string; label: string; min: number; max: number }
  | { type: 'string';  name: string; label: string; values: string[] }
  | { type: 'date';    name: string; label: string; min: string; max: string };

EvalScope

type EvalScope = 'session' | 'subagent' | 'both';

AggregateContext

Passed to aggregate collect functions.
interface AggregateContext {
  entries: Record<string, unknown>[];
  stats: EvalLogStats;
  projectName: string;
  sessionId: string;
  source: string;
  evalResults: Record<string, { pass: boolean; score: number; error?: string; message?: string }>;
  enrichResults: Record<string, Record<string, string | number | boolean>>;
  filterValues: Record<string, FilterValue>;
}

CollectedSession

The input to aggregate reduce functions.
interface CollectedSession {
  projectName: string;
  sessionId: string;
  values: Record<string, boolean | number | string>;
}

DashboardPayload

interface DashboardPayload {
  sessions: DashboardSessionRow[];  // One page of matching sessions
  filterMeta: FilterMeta[];         // One per registered filter
  totalDurationMs: number;          // Server-side computation time
  totalCount: number;               // Total sessions before filtering
  matchingCount: number;            // Total sessions after filtering
  page: number;                     // Current page (1-based)
  pageSize: number;                 // Items per page
}

interface DashboardSessionRow {
  projectName: string;
  sessionId: string;
  lastModified: string;             // ISO 8601
  lastModifiedFormatted: string;    // Human-readable
  filterValues: Record<string, FilterValue>;
}

EvalLogEntry (display helper)

A convenience type for display-oriented parsed entries. Not the type of EvalContext.entries - those are raw Record<string, unknown>[].
interface EvalLogEntry {
  type: string;
  _source?: string;
  uuid: string;
  parentUuid: string | null;
  timestamp: string;
  timestampMs: number;
  timestampFormatted: string;
  message?: {
    role: string;
    content: string | EvalContentBlock[];
    model?: string;
  };
  raw?: Record<string, unknown>;
  label?: string;
}