Skip to content

Scene

The Scene class represents an individual narrative unit. Each beat in a plot generates one scene. Scenes are typically created by the engine, not manually.

Import

typescript
import { Scene } from '@spectator-ai/core'
import type { SceneInput, SceneData, CharacterStateData } from '@spectator-ai/core'

Constructor

typescript
new Scene(input: SceneInput)

Validates input against SceneSchema and freezes the data.

Throws: ValidationError if input is invalid.

Properties

All properties are readonly getters.

PropertyTypeDescription
idstringUnique scene identifier
textstringNarrative text content
beatBeatData | undefinedThe plot beat that generated this scene
locationstring | undefinedWhere the scene takes place
participantsstring[]Character names in this scene (defaults to [])
summarystring | undefinedAuto-generated scene summary
characterStatesCharacterStateData[] | undefinedCharacter states after this scene

CharacterStateData

typescript
interface CharacterStateData {
  characterName: string
  emotionalState: string
  currentGoals: string[]
  relationships?: DynamicRelationshipData[]
  internalConflict?: string
  notes?: string
}

Methods

toJSON()

typescript
scene.toJSON(): SceneData

Returns a plain serializable object.

toMarkdown()

typescript
scene.toMarkdown(): string

Returns formatted markdown. Includes location and participants as a header if present, followed by the scene text.

Types

SceneInput

typescript
interface SceneInput {
  id: string
  beat?: BeatInput
  location?: string
  participants?: string[]
  text: string
  summary?: string
  characterStates?: CharacterStateInput[]
  metadata?: Record<string, unknown>
}

Released under the MIT License.