Implementation:AIScientists Dev WorldSeed stream format
| Knowledge Sources | |
|---|---|
| Domains | Frontend, Formatting |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
Concrete stream record formatting module defining hidden kind sets, display group mappings, free-text extraction, effect formatting, and CSS class assignment, provided by the WorldSeed frontend.
Description
The stream-format module is the single source of truth for stream record presentation. `HIDDEN_KINDS`/`DIGEST_HIDDEN_KINDS`/`STORY_HIDDEN_KINDS` define which record kinds are filtered per view mode. `KIND_DISPLAY` maps raw kinds to display groups for filter chips (e.g. `dm_call`→`dm`, `whisper`→`user`). `hasFreeText`/`extractFreeText` check and extract `free_text` params from action definitions, driving dialogue vs compact rendering. `formatParams` formats action params compactly, skipping free_text. `formatEffect` renders effect operators as human-readable strings. `recClass` assigns CSS classes per record kind for stream panel styling.
Usage
Import this module from StreamPanel, the stream store, and subtitle-classifier to format records, filter by view mode, and determine rendering style.
Code Reference
Source Location
- Repository: WorldSeed
- File: frontend/src/lib/stream-format.ts
Signature
export const HIDDEN_KINDS: Set<string>;
export const DIGEST_HIDDEN_KINDS: Set<string>;
export const STORY_HIDDEN_KINDS: Set<string>;
export const KIND_DISPLAY: Record<string, string>;
export function hasFreeText(actionDefs: Record<string, any>, actionType: string): boolean;
export function extractFreeText(actionDefs: Record<string, any>, actionType: string, params: Record<string, unknown>): string | null;
export function formatParams(params: any, actionDefs?: Record<string, any>, actionType?: string): string;
export function formatEffect(eff: any): string;
export function recClass(rec: any): string;
Import
import { HIDDEN_KINDS, KIND_DISPLAY, hasFreeText, formatParams, formatEffect, recClass } from '@/lib/stream-format';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| actionDefs | Record<string, any> | Yes │ Action definitions from world store | |
| actionType | string | Yes │ Action type to look up | |
| params | Record | Yes (formatParams) │ Action parameters | |
| rec | any | Yes (recClass) │ Stream record |
Outputs
| Name | Type | Description |
|---|---|---|
| hasFreeText returns | boolean │ Whether action has a free_text param | |
| recClass returns | string │ CSS class string for the record | |
| formatEffect returns | string │ Human-readable effect summary |
Usage Examples
import { recClass, hasFreeText, formatParams } from '@/lib/stream-format';
// Get CSS class for a stream record
const cls = recClass({ kind: 'action', agent_id: 'old_chen' });
// 'stream-record stream-action'
// Check if an action has free text (dialogue vs compact)
const isDialogue = hasFreeText(actionDefs, 'say');
// Format action params compactly
const params = formatParams({ to: 'hallway', message: 'hello' }, actionDefs, 'say');
// 'to: hallway' (message skipped as free_text)