Validates LLM-generated invention JSON: checks inputs exist in
ItemRegistry, rejects name collisions (case-insensitive), validates
categories, and generates snake_case itemIds from names.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Events recorded with tick: 0 now get a meaningful tick value from the
service's internal counter, ensuring selectForPrompt recency scoring
works correctly. Also fixed preferTypes to accept readonly arrays.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When narrating social interactions, the LLM now receives up to 3 shared
history events between the two NPCs, enabling more contextual narrations
that reference past encounters.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the simple last-2-narration-events approach with smart selection
of up to 5 memory events, preferring types relevant to the thought trigger
(social events for post-interaction, need events for need-critical).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- determineTrigger now detects post_interaction (recent social outcome),
need_critical, idle (wandering), and periodic triggers
- Track active emoji per NPC, destroy previous before showing new one
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements LLM-powered narration for NPC social interactions:
- Rate limits updated to 20 RPM / 1000 per day (OpenRouter free tier)
- NarrationEvent type with template fallback text generator
- NarrationService with rolling event buffer and LLM priority queuing
- Narration emitter wired between social and relationship systems
- Socket.io events for real-time narration delivery
- Tabbed left panel (Stats + Events) replacing old Superlatives panel
- Recent events section in NPC info panel
- Follow tracking via socket for LLM narration priority
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Restore subscribeSuperlatives/unsubscribeSuperlatives/onSuperlativesUpdate
on SocketClient (lost during Task 5 refactor)
- Fix EventsFeed.updateEvent to rebuild entire element when LLM narration
arrives (names may be in different positions)
- Remove dead setFollowedEntity method from GameLoop (replaced by
SocketServer.rebuildFollowedEntityIds)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds follow-npc client event so the server knows which NPCs are being
watched, enabling priority LLM narration for followed entity interactions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire narration events through the socket layer so clients receive
real-time narration updates. Server emits narration-event on creation,
narration-update when LLM text arrives, and narration-history on connect.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removes duplicated local version that had different format.
Also brings backstoryGenerator.ts into the worktree from main.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add narrationEmitter system that reads completed interactions from
socialState.lastOutcome and feeds them to the NarrationService. It runs
between socialSystem and relationshipSystem to capture outcomes before
they are cleared. Includes pair deduplication, proposal detection,
priority marking for followed NPCs and high-value relationships, and
personality formatting for LLM prompts.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements NarrationService that manages a rolling buffer of 50 narration events,
generates immediate template fallback text, and queues LLM generation for priority
interactions and proposals (respecting daily limits).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Define NarrationEvent and NarrationOutcome types in shared package for
social interaction narration. Add generateFallbackNarration() with
randomized templates for each outcome type (positive, negative,
proposal_accepted, proposal_rejected) to provide immediate text when
LLM narration is unavailable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>