Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
docs: spec P2.5 Aesthetic Taste Prompting for Digital Twin (brain idea 608dc733)
Adam Eivy48a2a878ad0d
diff --git a/.changelog/v0.13.x.md b/.changelog/v0.13.x.mdindex c6a6e02512..90475a5d97 100644--- a/.changelog/v0.13.x.md+++ b/.changelog/v0.13.x.md@@ -40,6 +40,73 @@ This release expands the genome dashboard with comprehensive cancer predispositi- **Platform-aware UI**: Quick actions switch between Moltbook (Engage, Check Posts) and Moltworld (Explore, Build) based on selected account; schedule action dropdown filters by platform- **Connection testing**: Profile + balance check for Moltworld accounts in the Test Connection flow+### Moltworld "World" Tab+- **Dedicated World tab** on agent detail page — visible only for agents with Moltworld accounts, hidden for Moltbook-only agents+- **World Status card** showing online/offline state, position, SIM balance, earning rate, total earned, and online time with refresh button+- **Nearby Agents panel** populated from join/explore responses with agent names, positions, and distances+- **Recent Messages panel** showing messages and thoughts from nearby agents (expire after 5 min per API)+- **Move/Explore actions** with X/Y coordinate inputs and optional thinking text, plus "Random Explore" for random movement+- **Think action** for sending visible thoughts to nearby agents+- **Build action** with X/Y/Z inputs, block type selection (wood/stone/dirt/grass/leaves), and place/remove toggle+- **Say action** for broadcasting messages or sending DMs to specific agent IDs+- **Rate limit badges** with animated cooldown timers matching ToolsTab pattern+- **Deep-linkable** at `/agents/:id/world`+- New server endpoints: `POST /think` (direct thought API) and `POST /say` (message via join)++### Moltworld Explorer Script+- **Standalone exploration script** (`server/scripts/moltworld-explore.mjs`) — wanders the world, thinks AI-generated thoughts, greets nearby agents, and earns SIM tokens+- **LM Studio integration** — generates contextual thoughts using local `gpt-oss-20b` model (configurable via `LMSTUDIO_MODEL`), with automatic fallback to curated thoughts when unavailable+- **Configurable intervals** — join frequency (default 3-9 min random), model, LM Studio URL, and duration all configurable via env vars+- **COS autonomous job** (`job-moltworld-exploration`) — daily scheduled job to run the explorer script+- **Efficient heartbeat** — joins every 3-9 minutes (within 10-minute expiry window) instead of every 8 seconds, reducing API calls while staying online++### Moltworld Sky Maze Builder+- **Procedural maze builder** (`server/scripts/moltworld-maze.mjs`) — generates and builds a stone maze floating in the sky using recursive backtracking DFS+- **Configurable** — maze size (3-12 cells), position, height (Z), wall height, block type, optional seed for reproducible mazes+- **Rate-limit compliant** — 1.1s between builds, auto-heartbeat every 50 blocks, handles 429 responses with retry+- **Resumable** — progress saved to `data/moltworld-maze-progress.json` after every block; interrupted builds resume from where they left off+- **Progress thoughts** — agent thinks out loud while building ("Placing block 150/449... the maze takes shape")++### Platform Tab Improvements+- **Renamed "Tools" tab to "Moltbook"** (📚 icon) for clarity — tab only visible for agents with Moltbook accounts+- **Conditional platform tabs** — Moltbook and World tabs auto-hide when agent lacks the corresponding platform account++### Moltworld Real-time WebSocket Integration+- **Server-side WebSocket relay** (`server/services/moltworldWs.js`) — connects to `wss://moltworld.io/ws` and streams real-time events (agent movements, thoughts, messages, interactions, presence snapshots) through the existing Socket.IO infrastructure+- **Connection control routes** at `/api/agents/tools/moltworld/ws/` — connect, disconnect, status, plus WebSocket-based move, think, nearby, and interact endpoints for lower-latency actions+- **Live Feed panel** in World tab — scrollable real-time event stream with per-event icons, agent names, event type badges, timestamps, and "(live)" indicator when connected+- **Connection banner** with status dot (green=connected, yellow=connecting, gray=disconnected) and Connect/Disconnect button+- **WebSocket-based actions** — when WS is connected, Move and Think actions route through WebSocket for lower latency; Say DMs use the interact endpoint+- **Real-time Nearby Agents** — presence data from WebSocket automatically merges with REST-fetched nearby agents, with "(live)" indicator+- **Explorer script WS mode** — `MOLTWORLD_USE_WS=true` env var routes movements through the PortOS WS relay when available, with automatic REST fallback+- **Automatic reconnection** with exponential backoff (2s to 60s cap); no auto-connect on server restart (requires explicit Connect click)+- **Activity logging** — interaction events from WebSocket are logged to the agent activity service for the Activity tab++### Moltworld Activity History+- **Persistent activity log** in the World tab — all Moltworld actions (explore, think, say, build, heartbeat) are now logged to the agent activity service and displayed in a scrollable "Activity History" card+- **Filterable by action type** — dropdown to filter by Explore, Think, Say, Build, Heartbeat, or show All+- **Paginated** with "Load More" button for browsing older activity+- **Auto-refresh** after each manual action so new entries appear immediately+- **Consistent `mw_` prefix** for all Moltworld action types (`mw_explore`, `mw_build`, `mw_think`, `mw_say`, `mw_heartbeat`, `mw_interact`) — distinguishes them from Moltbook actions in the global activity view+- Activity logging added to think, say, and join routes (previously only explore and build were logged); WebSocket-initiated actions (move, think, interact) also log activity++### Moltworld Action Queue+- **In-memory action queue** per agent — schedule future actions (explore, think, build, say) from the UI that the explore script picks up and executes+- **Action Queue card** at top of the right column in World tab with real-time status updates via Socket.IO+- **Add Action form** — inline toggleable form with action type dropdown and dynamic parameter fields (coordinates, thought text, message, block type, etc.)+- **Cancel pending items** — click X on any pending queue item to remove it+- **Queue status badges** — pending (gray), executing (blue pulse), completed (green), failed (red)+- **Explore script integration** — before each auto-generated action, the script checks the queue for manually-scheduled items and executes them first, respecting rate limits+- **Queue API endpoints**: `GET /queue/:agentId`, `POST /queue`, `DELETE /queue/:id`, `POST /queue/:id/complete`, `POST /queue/:id/fail`++### Digital Twin — Aesthetic Taste Prompting Spec (brain idea 608dc733)+- **Promoted brain idea 608dc733** ("Prompting Aesthetic Taste Docs via Digital Twin") from dormant idea to concrete P2.5 spec in PLAN.md under M42: Unified Digital Twin Identity System+- **Defined 7 aesthetic domains** for taste capture: movies, music, visual art, architecture, food, plus 2 new domains (fashion/texture and digital/interface aesthetics)+- **Designed conversational prompting flow** — twin reads existing identity documents (BOOKS.md, AUDIO.md, CREATIVE.md, PREFERENCES.md) and enrichment answers to generate personalized follow-up questions that reference things it already knows about the user+- **Specified data model** — taste-profile.json v2.0.0 schema (extended with source tracking, generated question storage, identity context provenance) and aesthetics.json as the canonical synthesized profile+- **Relaxed P1 prerequisite** — P2.5 can read identity documents directly without the Identity orchestrator, unblocking implementation+- **9-step implementation plan** covering new sections, context aggregation, LLM-powered question generation, API routes, UI updates, and data migration+## Improvements### CoS — Consolidated Duplicate Repo Maintenance Jobsdiff --git a/PLAN.md b/PLAN.mdindex 7e160b9928..9553429771 100644--- a/PLAN.md+++ b/PLAN.md@@ -369,12 +369,214 @@ The existing Digital Twin page at `/digital-twin/:tab` gets a new **Identity** t- Wire sub-routes for deep dives#### P2.5: Digital Twin Aesthetic Taste Prompting (brain idea 608dc733)-The existing Taste tab uses static questions. This phase enhances it by having the digital twin generate personalized follow-up questions based on existing identity documents and enrichment answers. The twin reads BOOKS.md, AUDIO.md, and enrichment responses to craft targeted queries like "You listed Blade Runner as a favorite — what specific visual elements resonated?" instead of generic "Name a movie you like."-- Add `generatePersonalizedTasteQuestion(section, existingResponses, identityContext)` to `taste-questionnaire.js`-- Identity context includes: enrichment answers, document excerpts (BOOKS.md, AUDIO.md, CREATIVE.md), traits (aesthetic markers from Big Five Openness dimension)-- LLM generates contextual follow-ups that probe deeper into already-expressed preferences-- Responses feed back into `taste-profile.json` and `aesthetics.json` (once P1 Identity orchestrator exists)-- Prerequisite: P1 (identity orchestrator provides the context aggregation)++##### Problem++P2's Taste questionnaire uses static questions and keyword-triggered follow-ups. The questions are good but generic — they don't reference anything the twin already knows about the user. Brain idea 608dc733 proposes using the digital twin's existing knowledge (books, music, movie lists, enrichment answers, personality traits) to generate personalized, conversational prompts that feel like talking to someone who already knows you rather than filling out a survey.++##### What Data to Capture++The aesthetic taste system captures preferences across **7 domains**, extending P2's 5 sections with 2 new ones (fashion/texture and digital/interface):++| Domain | Data Captured | Sources That Seed It |+|--------|--------------|---------------------|+| **Movies & Film** | Visual style preferences, narrative structure, mood/atmosphere, genre affinities, anti-preferences, formative films | BOOKS.md (narrative taste), enrichment:favorite_movies, existing P2 responses |+| **Music & Sound** | Functional use (focus/energy/decompress), genre affinities, production preferences, anti-sounds, formative artists | AUDIO.md, enrichment:music_taste, existing P2 responses |+| **Visual Art & Design** | Minimalism vs maximalism spectrum, color palette preferences, design movements, typography, layout sensibility | CREATIVE.md, enrichment:aesthetics, existing P2 responses |+| **Architecture & Spaces** | Material preferences, light quality, scale/intimacy, indoor-outdoor relationship, sacred vs functional | enrichment:aesthetics, existing P2 responses |+| **Food & Culinary** | Flavor profiles, cuisine affinities, cooking philosophy, dining experience priorities, sensory texture preferences | enrichment:daily_routines (meal patterns), existing P2 responses |+| **Fashion & Texture** *(new)* | Material/fabric preferences, silhouette comfort, color wardrobe, formality spectrum, tactile sensitivity | genome:sensory markers (if available), enrichment:aesthetics |+| **Digital & Interface** *(new)* | Dark vs light mode, information density, animation tolerance, typography preferences, notification style, tool aesthetics | PREFERENCES.md, existing PortOS theme choices (port-bg, port-card etc.) |++Each domain captures:+- **Positive affinities** — what they're drawn to and why+- **Anti-preferences** — what they actively avoid (often more revealing than likes)+- **Functional context** — how the preference serves them (focus, comfort, identity, social)+- **Formative influences** — early experiences that shaped the preference+- **Evolution** — how the preference has changed over time++##### Conversational Prompting Flow++The key design principle: **conversation, not survey**. The twin generates questions that reference things it already knows, creating a dialogue that feels like it's building on shared context.++**Flow architecture:**++```+┌─────────────────────────────────────────────────┐+│ 1. Context Aggregation │+│ Read: BOOKS.md, AUDIO.md, CREATIVE.md, │+│ PREFERENCES.md, enrichment answers, │+│ existing taste-profile.json responses, │+│ personality traits (Big Five Openness) │+├─────────────────────────────────────────────────┤+│ 2. Static Core Question (from P2) │+│ Serve the existing static question first │+│ to establish baseline in that domain │+├─────────────────────────────────────────────────┤+│ 3. Personalized Follow-Up Generation │+│ LLM generates 1 contextual follow-up using │+│ identity context + previous answer │+│ e.g., "You listed Blade Runner — what about │+│ its visual language specifically grabbed you?" │+├─────────────────────────────────────────────────┤+│ 4. Depth Probing (optional, user-initiated) │+│ "Want to go deeper?" button generates │+│ another personalized question that connects │+│ across domains (e.g., music taste ↔ visual) │+├─────────────────────────────────────────────────┤+│ 5. Summary & Synthesis │+│ After core + follow-ups complete, LLM │+│ generates section summary + cross-domain │+│ pattern detection │+└─────────────────────────────────────────────────┘+```++**Prompt template for personalized question generation:**++```+You are a thoughtful interviewer building an aesthetic taste profile.+You already know the following about this person:++## Identity Context+{identityContext — excerpts from BOOKS.md, AUDIO.md, enrichment answers, traits}++## Previous Responses in This Section+{existingResponses — Q&A pairs from taste-profile.json for this section}++## Section: {sectionLabel}++Generate ONE follow-up question that:+1. References something specific from their identity context or previous answers+2. Probes WHY they prefer what they do, not just WHAT+3. Feels conversational — like a friend who knows them asking a natural question+4. Explores an angle their previous answers haven't covered yet+5. Is concise (1-2 sentences max)++Do NOT:+- Ask generic questions that ignore the context+- Repeat topics already covered in previous responses+- Use survey language ("On a scale of 1-10...")+- Ask multiple questions at once+```++**Example personalized exchanges:**++> **Static (P2):** "Name 3-5 films you consider near-perfect."+> **User:** "Blade Runner, Stalker, Lost in Translation, Drive, Arrival"+>+> **Personalized (P2.5):** "Your BOOKS.md lists several sci-fi titles with themes of isolation and altered perception. Four of your five film picks share that same atmosphere. Is solitude a feature of stories you're drawn to, or is it more about the specific visual treatment of lonely spaces?"++> **Static (P2):** "What artists or albums have had a lasting impact?"+> **User:** "Radiohead, Boards of Canada, Massive Attack"+>+> **Personalized (P2.5):** "All three of those artists layer heavy texture over minimalist structures. Your CREATIVE.md mentions an appreciation for 'controlled complexity.' Does this principle — density within restraint — apply to how you think about visual design too?"++##### Data Model — Where Taste Lives++Taste data lives in **two files** with distinct roles:++**1. Raw questionnaire responses: `data/digital-twin/taste-profile.json`** (existing, extended)++```json+{+ "version": "2.0.0",+ "createdAt": "...",+ "updatedAt": "...",+ "sections": {+ "movies": {+ "status": "completed",+ "responses": [+ {+ "questionId": "movies-core-1",+ "answer": "Blade Runner, Stalker, Lost in Translation...",+ "answeredAt": "...",+ "source": "static"+ },+ {+ "questionId": "movies-p25-1",+ "answer": "It's not solitude per se, it's the visual...",+ "answeredAt": "...",+ "source": "personalized",+ "generatedQuestion": "Your BOOKS.md lists several sci-fi titles...",+ "identityContextUsed": ["BOOKS.md:sci-fi-themes", "taste:movies-core-1"]+ }+ ],+ "summary": "..."+ },+ "fashion": { "status": "pending", "responses": [], "summary": null },+ "digital": { "status": "pending", "responses": [], "summary": null }+ },+ "profileSummary": null,+ "lastSessionAt": null+}+```++Changes from v1:+- `source` field distinguishes static vs personalized questions+- `generatedQuestion` stores the LLM-generated question text (since personalized questions aren't in the static definition)+- `identityContextUsed` tracks which identity sources informed the question (for provenance)+- Two new sections: `fashion`, `digital`+- Version bumped to 2.0.0++**2. Synthesized aesthetic profile: `data/digital-twin/aesthetics.json`** (planned in P1, populated by P2.5)++```json+{+ "version": "1.0.0",+ "updatedAt": "...",+ "profile": {+ "visualStyle": ["brutalist minimalism", "high-contrast neon", "controlled complexity"],+ "narrativePreferences": ["isolation themes", "slow burn", "ambiguity over resolution"],+ "musicProfile": ["textural electronica", "atmospheric layering", "functional listening"],+ "spatialPreferences": ["raw materials", "dramatic light", "intimacy over grandeur"],+ "culinaryIdentity": ["umami-driven", "improvisational cooking", "experience over formality"],+ "fashionSensibility": ["monochrome", "natural fibers", "minimal branding"],+ "digitalAesthetic": ["dark mode", "high information density", "subtle animation"],+ "antiPatterns": ["visual clutter", "forced symmetry", "saccharine sentimentality"],+ "corePrinciples": ["density within restraint", "function informing form", "earned complexity"]+ },+ "sources": {+ "tasteQuestionnaire": {+ "sectionsCompleted": 7,+ "totalResponses": 28,+ "lastUpdated": "..."+ },+ "enrichment": {+ "aesthetics": { "questionsAnswered": 5 },+ "favoriteBooks": { "analyzed": true, "themes": ["existential sci-fi", "systems thinking"] },+ "favoriteMovies": { "analyzed": true, "themes": ["atmospheric isolation", "neon noir"] },+ "musicTaste": { "analyzed": true, "themes": ["textural electronica", "ambient"] }+ },+ "documents": ["BOOKS.md", "AUDIO.md", "CREATIVE.md", "PREFERENCES.md"]+ },+ "crossDomainPatterns": [+ "Preference for 'controlled complexity' appears across music (layered textures), visual art (minimalist structure with dense detail), architecture (raw materials with precise placement), and food (complex umami built from simple ingredients)",+ "Anti-preference for overt sentimentality spans film (avoids melodrama), music (dislikes saccharine pop), and design (rejects decorative ornamentation)"+ ],+ "genomicCorrelations": {+ "tasteReceptorGenes": "TAS2R38 status may correlate with bitter-food tolerance preferences",+ "sensoryProcessing": "Olfactory receptor variants may explain heightened texture sensitivity"+ }+}+```++This file is the **canonical aesthetic profile** referenced by the Identity orchestrator (`identity.json`). It is regenerated whenever taste-profile.json accumulates significant new responses.++##### Implementation Steps++1. **Add 2 new sections** to `TASTE_SECTIONS` in `taste-questionnaire.js`: `fashion` and `digital`, each with 3 core questions and keyword-triggered follow-ups+2. **Add `aggregateIdentityContext(sectionId)`** to `taste-questionnaire.js` — reads BOOKS.md, AUDIO.md, CREATIVE.md, PREFERENCES.md, enrichment answers, and existing taste responses to build a context string for the LLM+3. **Add `generatePersonalizedTasteQuestion(sectionId, existingResponses, identityContext)`** — calls the active AI provider with the prompt template above, returns a single personalized follow-up question+4. **Add `POST /api/digital-twin/taste/:section/personalized-question`** route that returns a generated question+5. **Extend `submitAnswer()`** to accept `source: 'personalized'` and store `generatedQuestion` + `identityContextUsed` metadata+6. **Add "Go deeper" button** to TasteTab.jsx after each static follow-up cycle completes — clicking it calls the personalized question endpoint+7. **Add `generateAestheticsProfile()`** to `taste-questionnaire.js` — synthesizes all taste-profile.json responses + enrichment data into `aesthetics.json`+8. **Bump taste-profile.json version** to 2.0.0, migrate existing responses to include `source: 'static'`+9. **Update TasteTab.jsx** to render personalized questions differently (subtle indicator showing the twin referenced specific context)++##### Prerequisite Relaxation++The original spec listed P1 (Identity orchestrator) as a hard prerequisite. This is relaxed: P2.5 can read identity documents directly from the filesystem (`BOOKS.md`, `AUDIO.md`, etc.) and enrichment data from `meta.json` without needing the orchestrator layer. The orchestrator becomes useful for caching and cross-section queries but is not strictly required for context aggregation.#### P5: Cross-Insights Engine- Add `generateCrossInsights(identity)` in identity service