Skip to content

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

feat(digital-twin): add social accounts management for digital twin

Adam Eivya81ae11fdfc4
diff --git a/.changelog/v0.10.x.md b/.changelog/v0.10.x.md
index 53949d0574..454a917129 100644
--- a/.changelog/v0.10.x.md
+++ b/.changelog/v0.10.x.md
@@ -26,6 +26,10 @@ This release introduces a structured changelog documentation system for creating
- **Progress Bar Enhancement**: Improved progress bar with clearer "X% complete" and prominent ETA display
- **Visual Polish**: Slightly thicker progress bars and better typography for the countdown display
+### Chief of Staff - Arcane Sigil (3D) Avatar
+- **New Avatar Style**: Added an additional Three.js avatar option, "Arcane Sigil (3D)", alongside the existing Cyberpunk 3D style
+- **State-Reactive Animation**: Sigil intensity, rune ring motion, and scan effects respond to agent state (sleeping/thinking/coding/investigating) and speaking activity
+
### Dashboard - Activity Streak
- **Current Streak Display**: Shows consecutive days of activity with dynamic emoji (fire for 7+ days, lightning for 3+, sparkles for less)
- **Longest Streak Tracking**: Displays your personal best streak alongside current streak
@@ -226,6 +230,14 @@ This release introduces a structured changelog documentation system for creating
- **API Endpoints**: New `/api/brain/links` CRUD endpoints plus `/api/brain/links/:id/clone` and `/api/brain/links/:id/pull` for repo management
- **GitHub URL Parsing**: Supports HTTPS and SSH GitHub URL formats
+### Digital Twin - Social Accounts
+- **Social Account Management**: New "Accounts" tab in the Digital Twin page for managing your online presence - social media profiles, blogs, and developer accounts
+- **Platform Support**: 14 pre-configured platforms (GitHub, Instagram, Facebook, LinkedIn, X/Twitter, Substack, Medium, YouTube, TikTok, Reddit, Bluesky, Mastodon, Threads) plus custom "Other" option
+- **Content Ingestion Prep**: Each account tracks content types and has an ingestion toggle for future content downloading and style learning
+- **Categorized Display**: Accounts grouped by category (developer, social, professional, writing, video, community) with color-coded platform icons
+- **Bulk Import API**: `POST /api/digital-twin/social-accounts/bulk` endpoint for programmatic bulk account creation
+- **Pre-Seeded Accounts**: User's GitHub (atomantic), Instagram (atomantic), Facebook (atomantic), LinkedIn (antic), X (antic), Substack (antic), and Medium (atomantic) accounts pre-configured
+
### AI Provider Model Updates
- **Claude Opus 4.6**: Added `claude-opus-4-6` model to Claude Code CLI provider as the new default and heavy tier model
- **GPT-5.2**: Codex CLI provider uses `gpt-5.2` as default and heavy tier model (5.3 was not yet available)
diff --git a/client/src/components/digital-twin/constants.js b/client/src/components/digital-twin/constants.js
index ca05fae132..9d5a2885f7 100644
--- a/client/src/components/digital-twin/constants.js
+++ b/client/src/components/digital-twin/constants.js
@@ -22,7 +22,8 @@ import {
Shield,
GitBranch,
AlertOctagon,
- Fingerprint
+ Fingerprint,
+ Globe
} from 'lucide-react';
// Main navigation tabs
@@ -31,6 +32,7 @@ export const TABS = [
{ id: 'documents', label: 'Documents', icon: FileText },
{ id: 'test', label: 'Test', icon: CheckCircle },
{ id: 'enrich', label: 'Enrich', icon: Sparkles },
+ { id: 'accounts', label: 'Accounts', icon: Globe },
{ id: 'import', label: 'Import', icon: Upload },
{ id: 'export', label: 'Export', icon: Download }
];
diff --git a/client/src/components/digital-twin/tabs/AccountsTab.jsx b/client/src/components/digital-twin/tabs/AccountsTab.jsx
new file mode 100644
index 0000000000..42aa1dd985
--- /dev/null
+++ b/client/src/components/digital-twin/tabs/AccountsTab.jsx
@@ -0,0 +1,507 @@
+import { useState, useEffect } from 'react';
+import {
+ Github,
+ Instagram,
+ Facebook,
+ Linkedin,
+ Twitter,
+ Youtube,
+ Music,
+ MessageCircle,
+ Cloud,
+ Globe,
+ AtSign,
+ Link,
+ Newspaper,
+ PenTool,
+ Plus,
+ Trash2,
+ ExternalLink,
+ RefreshCw,
+ Edit3,
+ Check,
+ X,
+ BarChart3
+} from 'lucide-react';
+import * as api from '../../../services/api';
+import toast from 'react-hot-toast';
+
+// Platform icon mapping
+const PLATFORM_ICONS = {
+ github: Github,
+ instagram: Instagram,
+ facebook: Facebook,
+ linkedin: Linkedin,
+ x: Twitter,
+ youtube: Youtube,
+ tiktok: Music,
+ reddit: MessageCircle,
+ bluesky: Cloud,
+ mastodon: Globe,
+ threads: AtSign,
+ substack: Newspaper,
+ medium: PenTool,
+ other: Link
+};
+
+// Platform color mapping
+const PLATFORM_COLORS = {
+ github: 'text-gray-300 bg-gray-500/20 border-gray-500/30',
+ instagram: 'text-pink-400 bg-pink-500/20 border-pink-500/30',
+ facebook: 'text-blue-400 bg-blue-500/20 border-blue-500/30',
+ linkedin: 'text-sky-400 bg-sky-500/20 border-sky-500/30',
+ x: 'text-gray-300 bg-gray-500/20 border-gray-500/30',
+ youtube: 'text-red-400 bg-red-500/20 border-red-500/30',
+ tiktok: 'text-cyan-400 bg-cyan-500/20 border-cyan-500/30',
+ reddit: 'text-orange-400 bg-orange-500/20 border-orange-500/30',
+ bluesky: 'text-blue-300 bg-blue-400/20 border-blue-400/30',
+ mastodon: 'text-purple-400 bg-purple-500/20 border-purple-500/30',
+ threads: 'text-gray-300 bg-gray-500/20 border-gray-500/30',
+ substack: 'text-orange-300 bg-orange-400/20 border-orange-400/30',
+ medium: 'text-green-400 bg-green-500/20 border-green-500/30',
+ other: 'text-gray-400 bg-gray-500/20 border-gray-500/30'
+};
+
+// Category labels
+const CATEGORY_LABELS = {
+ developer: 'Developer',
+ social: 'Social',
+ professional: 'Professional',
+ writing: 'Writing',
+ video: 'Video',
+ community: 'Community',
+ other: 'Other'
+};
+
+const CATEGORY_COLORS = {
+ developer: 'text-green-400',
+ social: 'text-pink-400',
+ professional: 'text-sky-400',
+ writing: 'text-orange-400',
+ video: 'text-red-400',
+ community: 'text-purple-400',
+ other: 'text-gray-400'
+};
+
+// Empty form template
+const EMPTY_FORM = {
+ platform: '',
+ username: '',
+ displayName: '',
+ url: '',
+ bio: '',
+ notes: '',
+ ingestionEnabled: false
+};
+
+export default function AccountsTab() {
+ const [accounts, setAccounts] = useState([]);
+ const [platforms, setPlatforms] = useState([]);
+ const [stats, setStats] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [showForm, setShowForm] = useState(false);
+ const [editingId, setEditingId] = useState(null);
+ const [form, setForm] = useState(EMPTY_FORM);
+ const [saving, setSaving] = useState(false);
+ const [deleting, setDeleting] = useState(null);
+
+ useEffect(() => {
+ loadData();
+ }, []);
+
+ const loadData = async () => {
+ const [accountsData, platformsData, statsData] = await Promise.all([
+ api.getSocialAccounts().catch(() => ({ accounts: [] })),
+ api.getSocialAccountPlatforms().catch(() => ({ platforms: [] })),
+ api.getSocialAccountStats().catch(() => null)
+ ]);
+ setAccounts(accountsData.accounts || []);
+ setPlatforms(platformsData.platforms || []);
+ setStats(statsData);
+ setLoading(false);
+ };
+
+ const handleSubmit = async () => {
+ if (!form.platform || !form.username) {
+ toast.error('Platform and username are required');
+ return;
+ }
+
+ setSaving(true);
+
+ if (editingId) {
+ const updated = await api.updateSocialAccount(editingId, form).catch(() => null);
+ if (updated) {
+ toast.success(`Updated ${form.platform} account`);
+ setEditingId(null);
+ }
+ } else {
+ const created = await api.createSocialAccount(form).catch(() => null);
+ if (created) {
+ toast.success(`Added ${form.platform} account`);
+ }
+ }
+
+ setSaving(false);
+ setShowForm(false);
+ setForm(EMPTY_FORM);
+ loadData();
+ };
+
+ const handleEdit = (account) => {
+ setForm({
+ platform: account.platform,
+ username: account.username,
+ displayName: account.displayName || '',
+ url: account.url || '',
+ bio: account.bio || '',
+ notes: account.notes || '',
+ ingestionEnabled: account.ingestionEnabled || false
+ });
+ setEditingId(account.id);
+ setShowForm(true);
+ };
+
+ const handleDelete = async (id) => {
+ setDeleting(id);
+ const success = await api.deleteSocialAccount(id).catch(() => false);
+ if (success !== false) {
+ toast.success('Account removed');
+ loadData();
+ }
+ setDeleting(null);
+ };
+
+ const handleCancel = () => {
+ setShowForm(false);
+ setEditingId(null);
+ setForm(EMPTY_FORM);
+ };
+
+ const selectedPlatformDef = platforms.find(p => p.id === form.platform);
+
+ // Group accounts by category
+ const groupedAccounts = {};
+ for (const account of accounts) {
+ const platformDef = platforms.find(p => p.id === account.platform);
+ const category = platformDef?.category || 'other';
+ if (!groupedAccounts[category]) groupedAccounts[category] = [];
+ groupedAccounts[category].push(account);
+ }
+
+ if (loading) {
+ return (
+ <div className="flex items-center justify-center py-12">
+ <RefreshCw className="w-6 h-6 text-port-accent animate-spin" />
+ </div>
+ );
+ }
+
+ return (
+ <div className="space-y-6 p-4">
+ {/* Header */}
+ <div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
+ <div>
+ <h2 className="text-lg font-semibold text-white">Social Accounts</h2>
+ <p className="text-sm text-gray-500">
+ Your online presence for content learning and style reference
+ </p>
+ </div>
+ <div className="flex items-center gap-2">
+ <button
+ onClick={loadData}
+ className="p-2 text-gray-400 hover:text-white border border-port-border rounded-lg hover:bg-port-card transition-colors min-h-[40px] min-w-[40px] flex items-center justify-center"
+ title="Refresh"
+ >
+ <RefreshCw className="w-4 h-4" />
+ </button>
+ <button
+ onClick={() => { setShowForm(true); setEditingId(null); setForm(EMPTY_FORM); }}
+ className="flex items-center gap-2 px-3 py-2 bg-port-accent text-white rounded-lg hover:bg-port-accent/80 transition-colors min-h-[40px]"
+ >
+ <Plus className="w-4 h-4" />
+ <span className="text-sm">Add Account</span>
+ </button>
+ </div>
+ </div>
+
+ {/* Stats Summary */}
+ {stats && stats.total > 0 && (
+ <div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
+ <div className="bg-port-card border border-port-border rounded-lg p-3">
+ <div className="text-2xl font-bold text-white">{stats.total}</div>
+ <div className="text-xs text-gray-500">Total Accounts</div>
+ </div>
+ <div className="bg-port-card border border-port-border rounded-lg p-3">
+ <div className="text-2xl font-bold text-port-accent">{stats.ingestionEnabled}</div>
+ <div className="text-xs text-gray-500">Ingestion Enabled</div>
+ </div>
+ <div className="bg-port-card border border-port-border rounded-lg p-3">
+ <div className="text-2xl font-bold text-purple-400">{Object.keys(stats.byCategory || {}).length}</div>
+ <div className="text-xs text-gray-500">Categories</div>
+ </div>
+ <div className="bg-port-card border border-port-border rounded-lg p-3">
+ <div className="text-2xl font-bold text-green-400">{Object.keys(stats.byPlatform || {}).length}</div>
+ <div className="text-xs text-gray-500">Platforms</div>
+ </div>
+ </div>
+ )}
+
+ {/* Add/Edit Form */}
+ {showForm && (
+ <div className="bg-port-card border border-port-border rounded-lg p-4 space-y-4">
+ <div className="flex items-center justify-between">
+ <h3 className="text-sm font-medium text-white">
+ {editingId ? 'Edit Account' : 'Add Social Account'}
+ </h3>
+ <button
+ onClick={handleCancel}
+ className="p-1 text-gray-400 hover:text-white transition-colors"
+ >
+ <X className="w-4 h-4" />
+ </button>
+ </div>
+
+ {/* Platform selector */}
+ <div>
+ <label className="block text-xs text-gray-500 mb-1">Platform</label>
+ <div className="grid grid-cols-4 sm:grid-cols-7 gap-2">
+ {platforms.filter(p => p.id !== 'other').map(platform => {
+ const Icon = PLATFORM_ICONS[platform.id] || Link;
+ const isSelected = form.platform === platform.id;
+ return (
+ <button
+ key={platform.id}
+ onClick={() => setForm(prev => ({ ...prev, platform: platform.id }))}
+ className={`flex flex-col items-center gap-1 p-2 rounded-lg border transition-colors min-h-[40px] ${
+ isSelected
+ ? `${PLATFORM_COLORS[platform.id]} border-current`
+ : 'border-port-border text-gray-500 hover:text-gray-300 hover:border-gray-600'
+ }`}
+ title={platform.label}
+ >
+ <Icon className="w-4 h-4" />
+ <span className="text-[10px] leading-tight">{platform.label}</span>
+ </button>
+ );
+ })}
+ {/* Other option */}
+ <button
+ onClick={() => setForm(prev => ({ ...prev, platform: 'other' }))}
+ className={`flex flex-col items-center gap-1 p-2 rounded-lg border transition-colors min-h-[40px] ${
+ form.platform === 'other'
+ ? 'border-gray-400 text-gray-300 bg-gray-500/20'
+ : 'border-port-border text-gray-500 hover:text-gray-300 hover:border-gray-600'
+ }`}
+ title="Other"
+ >
+ <Link className="w-4 h-4" />
+ <span className="text-[10px] leading-tight">Other</span>
+ </button>
+ </div>
+ </div>
+
+ {/* Username and Display Name */}
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
+ <div>
+ <label className="block text-xs text-gray-500 mb-1">
+ Username / Handle *
+ </label>
+ <input
+ type="text"
+ value={form.username}
+ onChange={e => setForm(prev => ({ ...prev, username: e.target.value }))}
+ placeholder={selectedPlatformDef ? `Your ${selectedPlatformDef.label} username` : 'username'}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:outline-none focus:border-port-accent min-h-[40px]"
+ />
+ </div>
+ <div>
+ <label className="block text-xs text-gray-500 mb-1">Display Name</label>
+ <input
+ type="text"
+ value={form.displayName}
+ onChange={e => setForm(prev => ({ ...prev, displayName: e.target.value }))}
+ placeholder="Optional display name"
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:outline-none focus:border-port-accent min-h-[40px]"
+ />
+ </div>
+ </div>
+
+ {/* URL */}
+ <div>
+ <label className="block text-xs text-gray-500 mb-1">Profile URL</label>
+ <input
+ type="url"
+ value={form.url}
+ onChange={e => setForm(prev => ({ ...prev, url: e.target.value }))}
+ placeholder={selectedPlatformDef?.urlTemplate?.replace('{username}', form.username || 'username') || 'https://...'}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:outline-none focus:border-port-accent min-h-[40px]"
+ />
+ </div>
+
+ {/* Bio */}
+ <div>
+ <label className="block text-xs text-gray-500 mb-1">Bio / Description</label>
+ <textarea
+ value={form.bio}
+ onChange={e => setForm(prev => ({ ...prev, bio: e.target.value }))}
+ placeholder="What you use this account for, your profile bio, etc."
+ rows={2}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:outline-none focus:border-port-accent resize-y"
+ />
+ </div>
+
+ {/* Notes */}
+ <div>
+ <label className="block text-xs text-gray-500 mb-1">Notes</label>
+ <textarea
+ value={form.notes}
+ onChange={e => setForm(prev => ({ ...prev, notes: e.target.value }))}
+ placeholder="Private notes about this account"
+ rows={2}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:outline-none focus:border-port-accent resize-y"
+ />
+ </div>
+
+ {/* Ingestion toggle */}
+ <div className="flex items-center gap-3">
+ <button
+ onClick={() => setForm(prev => ({ ...prev, ingestionEnabled: !prev.ingestionEnabled }))}
+ className={`relative w-10 h-5 rounded-full transition-colors ${
+ form.ingestionEnabled ? 'bg-port-accent' : 'bg-gray-600'
+ }`}
+ >
+ <span className={`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${
+ form.ingestionEnabled ? 'left-5' : 'left-0.5'
+ }`} />
+ </button>
+ <span className="text-sm text-gray-400">
+ Enable content ingestion (future: download and learn from content)
+ </span>
+ </div>
+
+ {/* Actions */}
+ <div className="flex items-center gap-2 pt-2 border-t border-port-border">
+ <button
+ onClick={handleSubmit}
+ disabled={saving || !form.platform || !form.username}
+ className="flex items-center gap-2 px-4 py-2 bg-port-accent text-white rounded-lg hover:bg-port-accent/80 transition-colors disabled:opacity-50 disabled:cursor-not-allowed min-h-[40px]"
+ >
+ {saving ? (
+ <RefreshCw className="w-4 h-4 animate-spin" />
+ ) : (
+ <Check className="w-4 h-4" />
+ )}
+ <span className="text-sm">{editingId ? 'Update' : 'Add Account'}</span>
+ </button>
+ <button
+ onClick={handleCancel}
+ className="px-4 py-2 text-gray-400 hover:text-white border border-port-border rounded-lg hover:bg-port-card transition-colors text-sm min-h-[40px]"
+ >
+ Cancel
+ </button>
+ </div>
+ </div>
+ )}
+
+ {/* Empty state */}
+ {accounts.length === 0 && !showForm && (
+ <div className="bg-port-card border border-port-border rounded-lg p-8 text-center">
+ <Globe className="w-12 h-12 text-gray-600 mx-auto mb-3" />
+ <h3 className="text-white font-medium mb-1">No social accounts yet</h3>
+ <p className="text-sm text-gray-500 mb-4">
+ Add your social media accounts to build your digital identity profile.
+ These will be used for content learning and style reference.
+ </p>
+ <button
+ onClick={() => setShowForm(true)}
+ className="inline-flex items-center gap-2 px-4 py-2 bg-port-accent text-white rounded-lg hover:bg-port-accent/80 transition-colors min-h-[40px]"
+ >
+ <Plus className="w-4 h-4" />
+ Add Your First Account
+ </button>
+ </div>
+ )}
+
+ {/* Accounts grouped by category */}
+ {Object.entries(groupedAccounts).sort(([a], [b]) => a.localeCompare(b)).map(([category, categoryAccounts]) => (
+ <div key={category}>
+ <h3 className={`text-sm font-medium mb-2 ${CATEGORY_COLORS[category] || 'text-gray-400'}`}>
+ {CATEGORY_LABELS[category] || category}
+ </h3>
+ <div className="space-y-2">
+ {categoryAccounts.map(account => {
+ const Icon = PLATFORM_ICONS[account.platform] || Link;
+ const colorClass = PLATFORM_COLORS[account.platform] || PLATFORM_COLORS.other;
+ return (
+ <div
+ key={account.id}
+ className="bg-port-card border border-port-border rounded-lg p-3 flex items-start gap-3 group hover:border-gray-600 transition-colors"
+ >
+ {/* Platform icon */}
+ <div className={`flex-shrink-0 w-10 h-10 rounded-lg border flex items-center justify-center ${colorClass}`}>
+ <Icon className="w-5 h-5" />
+ </div>
+
+ {/* Account info */}
+ <div className="flex-1 min-w-0">
+ <div className="flex items-center gap-2">
+ <span className="text-white font-medium text-sm truncate">
+ {account.displayName || account.username}
+ </span>
+ <span className="text-xs text-gray-500">
+ @{account.username}
+ </span>
+ {account.ingestionEnabled && (
+ <span className="text-[10px] px-1.5 py-0.5 bg-port-accent/20 text-port-accent rounded">
+ ingestion
+ </span>
+ )}
+ </div>
+ {account.bio && (
+ <p className="text-xs text-gray-500 mt-0.5 line-clamp-1">{account.bio}</p>
+ )}
+ {account.url && (
+ <a
+ href={account.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-xs text-port-accent hover:underline mt-0.5 inline-flex items-center gap-1"
+ >
+ {account.url.replace(/^https?:\/\//, '')}
+ <ExternalLink className="w-3 h-3" />
+ </a>
+ )}
+ </div>
+
+ {/* Actions */}
+ <div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
+ <button
+ onClick={() => handleEdit(account)}
+ className="p-1.5 text-gray-400 hover:text-white rounded transition-colors min-h-[40px] min-w-[40px] flex items-center justify-center"
+ title="Edit"
+ >
+ <Edit3 className="w-4 h-4" />
+ </button>
+ <button
+ onClick={() => handleDelete(account.id)}
+ disabled={deleting === account.id}
+ className="p-1.5 text-gray-400 hover:text-red-400 rounded transition-colors min-h-[40px] min-w-[40px] flex items-center justify-center"
+ title="Remove"
+ >
+ {deleting === account.id ? (
+ <RefreshCw className="w-4 h-4 animate-spin" />
+ ) : (
+ <Trash2 className="w-4 h-4" />
+ )}
+ </button>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ ))}
+ </div>
+ );
+}
diff --git a/client/src/pages/DigitalTwin.jsx b/client/src/pages/DigitalTwin.jsx
index 5796dd88d7..b125880b9b 100644
--- a/client/src/pages/DigitalTwin.jsx
+++ b/client/src/pages/DigitalTwin.jsx
@@ -9,6 +9,7 @@ import OverviewTab from '../components/digital-twin/tabs/OverviewTab';
import DocumentsTab from '../components/digital-twin/tabs/DocumentsTab';
import TestTab from '../components/digital-twin/tabs/TestTab';
import EnrichTab from '../components/digital-twin/tabs/EnrichTab';
+import AccountsTab from '../components/digital-twin/tabs/AccountsTab';
import ImportTab from '../components/digital-twin/tabs/ImportTab';
import ExportTab from '../components/digital-twin/tabs/ExportTab';
@@ -51,6 +52,8 @@ export default function DigitalTwin() {
return <TestTab onRefresh={fetchData} />;
case 'enrich':
return <EnrichTab onRefresh={fetchData} />;
+ case 'accounts':
+ return <AccountsTab />;
case 'import':
return <ImportTab onRefresh={fetchData} />;
case 'export':
diff --git a/client/src/services/api.js b/client/src/services/api.js
index 2ace771f6a..361840f44d 100644
--- a/client/src/services/api.js
+++ b/client/src/services/api.js
@@ -825,6 +825,46 @@ export const saveDigitalTwinImport = (source, suggestedDoc) => request('/digital
body: JSON.stringify({ source, suggestedDoc })
});
+// Digital Twin - Social Accounts
+export const getSocialAccounts = (params = {}) => {
+ const qs = new URLSearchParams(params).toString();
+ return request(`/digital-twin/social-accounts${qs ? `?${qs}` : ''}`);
+};
+export const getSocialAccountPlatforms = () => request('/digital-twin/social-accounts/platforms');
+export const getSocialAccountStats = () => request('/digital-twin/social-accounts/stats');
+export const getSocialAccount = (id) => request(`/digital-twin/social-accounts/${id}`);
+export const createSocialAccount = (data) => request('/digital-twin/social-accounts', {
+ method: 'POST',
+ body: JSON.stringify(data)
+});
+export const createSocialAccountsBulk = (accounts) => request('/digital-twin/social-accounts/bulk', {
+ method: 'POST',
+ body: JSON.stringify({ accounts })
+});
+export const updateSocialAccount = (id, data) => request(`/digital-twin/social-accounts/${id}`, {
+ method: 'PUT',
+ body: JSON.stringify(data)
+});
+export const deleteSocialAccount = (id) => request(`/digital-twin/social-accounts/${id}`, {
+ method: 'DELETE'
+});
+
+// Browser - CDP browser management
+export const getBrowserStatus = () => request('/browser');
+export const getBrowserConfig = () => request('/browser/config');
+export const updateBrowserConfig = (config) => request('/browser/config', {
+ method: 'PUT',
+ body: JSON.stringify(config)
+});
+export const launchBrowser = () => request('/browser/launch', { method: 'POST' });
+export const stopBrowser = () => request('/browser/stop', { method: 'POST' });
+export const restartBrowser = () => request('/browser/restart', { method: 'POST' });
+export const getBrowserHealth = () => request('/browser/health');
+export const getBrowserProcess = () => request('/browser/process');
+export const getBrowserPages = () => request('/browser/pages');
+export const getBrowserVersion = () => request('/browser/version');
+export const getBrowserLogs = (lines = 50) => request(`/browser/logs?lines=${lines}`);
+
// Default export for simplified imports
export default {
get: (endpoint, options) => request(endpoint, { method: 'GET', ...options }),
diff --git a/server/index.js b/server/index.js
index 24c0b430b3..cd118f4f3b 100644
--- a/server/index.js
+++ b/server/index.js
@@ -31,7 +31,9 @@ import standardizeRoutes from './routes/standardize.js';
import brainRoutes from './routes/brain.js';
import mediaRoutes from './routes/media.js';
import digitalTwinRoutes from './routes/digital-twin.js';
+import socialAccountsRoutes from './routes/socialAccounts.js';
import lmstudioRoutes from './routes/lmstudio.js';
+import browserRoutes from './routes/browser.js';
import { initSocket } from './services/socket.js';
import { initScriptRunner } from './services/scriptRunner.js';
import { errorMiddleware, setupProcessErrorHandlers, asyncHandler } from './lib/errorHandler.js';
@@ -180,8 +182,10 @@ app.use('/api/notifications', notificationsRoutes);
app.use('/api/standardize', standardizeRoutes);
app.use('/api/brain', brainRoutes);
app.use('/api/media', mediaRoutes);
+app.use('/api/digital-twin/social-accounts', socialAccountsRoutes);
app.use('/api/digital-twin', digitalTwinRoutes);
app.use('/api/lmstudio', lmstudioRoutes);
+app.use('/api/browser', browserRoutes);
// Initialize script runner
initScriptRunner().catch(err => console.error(`❌ Script runner init failed: ${err.message}`));
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 8f2fcece6d..9b5b9fec42 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -177,6 +177,29 @@ export const runSchema = z.object({
timeout: z.number().int().min(1000).max(600000).optional()
});
+// =============================================================================
+// SOCIAL ACCOUNT SCHEMAS (Digital Twin)
+// =============================================================================
+
+export const socialPlatformSchema = z.enum([
+ 'github', 'instagram', 'facebook', 'linkedin', 'x',
+ 'substack', 'medium', 'youtube', 'tiktok', 'reddit',
+ 'bluesky', 'mastodon', 'threads', 'other'
+]);
+
+export const socialAccountSchema = z.object({
+ platform: socialPlatformSchema,
+ username: z.string().min(1).max(200),
+ displayName: z.string().max(200).optional(),
+ url: z.string().url().optional(),
+ bio: z.string().max(2000).optional().default(''),
+ contentTypes: z.array(z.string().max(50)).optional().default([]),
+ ingestionEnabled: z.boolean().optional().default(false),
+ notes: z.string().max(2000).optional().default('')
+});
+
+export const socialAccountUpdateSchema = socialAccountSchema.partial();
+
/**
* Validate data against a schema
* Returns { success: true, data } or { success: false, errors }
diff --git a/server/routes/socialAccounts.js b/server/routes/socialAccounts.js
new file mode 100644
index 0000000000..c43e571afc
--- /dev/null
+++ b/server/routes/socialAccounts.js
@@ -0,0 +1,122 @@
+/**
+ * Social Accounts Routes (Digital Twin)
+ *
+ * Manage the user's own social media accounts for the digital twin.
+ * Mounted at /api/digital-twin/social-accounts
+ */
+
+import { Router } from 'express';
+import { asyncHandler, ServerError } from '../lib/errorHandler.js';
+import { validate, socialAccountSchema, socialAccountUpdateSchema } from '../lib/validation.js';
+import * as socialAccounts from '../services/socialAccounts.js';
+
+const router = Router();
+
+// GET / - List all social accounts
+router.get('/', asyncHandler(async (req, res) => {
+ const { platform, category } = req.query;
+
+ let accounts;
+ if (platform) {
+ accounts = await socialAccounts.getAccountsByPlatform(platform);
+ } else if (category) {
+ accounts = await socialAccounts.getAccountsByCategory(category);
+ } else {
+ accounts = await socialAccounts.getAllAccounts();
+ }
+
+ res.json({ accounts });
+}));
+
+// GET /platforms - List supported platforms
+router.get('/platforms', asyncHandler(async (req, res) => {
+ const platforms = socialAccounts.getSupportedPlatforms();
+ res.json({ platforms });
+}));
+
+// GET /stats - Account summary stats
+router.get('/stats', asyncHandler(async (req, res) => {
+ const stats = await socialAccounts.getAccountStats();
+ res.json(stats);
+}));
+
+// GET /:id - Get account by ID
+router.get('/:id', asyncHandler(async (req, res) => {
+ const account = await socialAccounts.getAccountById(req.params.id);
+ if (!account) {
+ throw new ServerError('Social account not found', { status: 404, code: 'NOT_FOUND' });
+ }
+ res.json(account);
+}));
+
+// POST / - Create a social account
+router.post('/', asyncHandler(async (req, res) => {
+ const validation = validate(socialAccountSchema, req.body);
+ if (!validation.success) {
+ throw new ServerError('Validation failed', {
+ status: 400,
+ code: 'VALIDATION_ERROR',
+ context: { details: validation.errors }
+ });
+ }
+
+ const account = await socialAccounts.createAccount(validation.data);
+ res.status(201).json(account);
+}));
+
+// POST /bulk - Create multiple social accounts at once
+router.post('/bulk', asyncHandler(async (req, res) => {
+ const { accounts: accountsData } = req.body;
+ if (!Array.isArray(accountsData) || accountsData.length === 0) {
+ throw new ServerError('accounts array is required', {
+ status: 400,
+ code: 'VALIDATION_ERROR'
+ });
+ }
+
+ const results = [];
+ for (const accountData of accountsData) {
+ const validation = validate(socialAccountSchema, accountData);
+ if (!validation.success) {
+ results.push({ success: false, errors: validation.errors, input: accountData });
+ continue;
+ }
+ const account = await socialAccounts.createAccount(validation.data);
+ results.push({ success: true, account });
+ }
+
+ const created = results.filter(r => r.success).length;
+ const failed = results.filter(r => !r.success).length;
+ console.log(`🔗 Bulk social accounts: ${created} created, ${failed} failed`);
+
+ res.status(201).json({ results, summary: { created, failed } });
+}));
+
+// PUT /:id - Update a social account
+router.put('/:id', asyncHandler(async (req, res) => {
+ const validation = validate(socialAccountUpdateSchema, req.body);
+ if (!validation.success) {
+ throw new ServerError('Validation failed', {
+ status: 400,
+ code: 'VALIDATION_ERROR',
+ context: { details: validation.errors }
+ });
+ }
+
+ const account = await socialAccounts.updateAccount(req.params.id, validation.data);
+ if (!account) {
+ throw new ServerError('Social account not found', { status: 404, code: 'NOT_FOUND' });
+ }
+ res.json(account);
+}));
+
+// DELETE /:id - Delete a social account
+router.delete('/:id', asyncHandler(async (req, res) => {
+ const deleted = await socialAccounts.deleteAccount(req.params.id);
+ if (!deleted) {
+ throw new ServerError('Social account not found', { status: 404, code: 'NOT_FOUND' });
+ }
+ res.status(204).send();
+}));
+
+export default router;
diff --git a/server/services/socialAccounts.js b/server/services/socialAccounts.js
new file mode 100644
index 0000000000..94c6edb900
--- /dev/null
+++ b/server/services/socialAccounts.js
@@ -0,0 +1,322 @@
+/**
+ * Social Accounts Service
+ *
+ * Manages the user's social media accounts as part of the Digital Twin.
+ * These are the user's OWN accounts (not agent platform accounts) used for:
+ * - Content ingestion and style learning
+ * - Building a communication profile
+ * - Reference for content creation
+ * - Future account management automation
+ */
+
+import { readFile, writeFile } from 'fs/promises';
+import { existsSync } from 'fs';
+import { join } from 'path';
+import { v4 as uuidv4 } from 'uuid';
+import EventEmitter from 'events';
+import { ensureDir, PATHS } from '../lib/fileUtils.js';
+
+const DATA_FILE = join(PATHS.digitalTwin, 'social-accounts.json');
+
+export const socialAccountEvents = new EventEmitter();
+
+// In-memory cache
+let cache = null;
+let cacheTimestamp = 0;
+const CACHE_TTL_MS = 2000;
+
+// Supported platform definitions
+export const PLATFORMS = {
+ github: {
+ label: 'GitHub',
+ urlTemplate: 'https://github.com/{username}',
+ icon: 'github',
+ contentTypes: ['code', 'repositories', 'contributions'],
+ category: 'developer'
+ },
+ instagram: {
+ label: 'Instagram',
+ urlTemplate: 'https://instagram.com/{username}',
+ icon: 'instagram',
+ contentTypes: ['photos', 'stories', 'reels'],
+ category: 'social'
+ },
+ facebook: {
+ label: 'Facebook',
+ urlTemplate: 'https://facebook.com/{username}',
+ icon: 'facebook',
+ contentTypes: ['posts', 'photos', 'events'],
+ category: 'social'
+ },
+ linkedin: {
+ label: 'LinkedIn',
+ urlTemplate: 'https://linkedin.com/in/{username}',
+ icon: 'linkedin',
+ contentTypes: ['posts', 'articles', 'profile'],
+ category: 'professional'
+ },
+ x: {
+ label: 'X (Twitter)',
+ urlTemplate: 'https://x.com/{username}',
+ icon: 'twitter',
+ contentTypes: ['tweets', 'threads', 'likes'],
+ category: 'social'
+ },
+ substack: {
+ label: 'Substack',
+ urlTemplate: 'https://{username}.substack.com',
+ icon: 'newspaper',
+ contentTypes: ['articles', 'newsletters'],
+ category: 'writing'
+ },
+ medium: {
+ label: 'Medium',
+ urlTemplate: 'https://medium.com/@{username}',
+ icon: 'pen-tool',
+ contentTypes: ['articles', 'responses'],
+ category: 'writing'
+ },
+ youtube: {
+ label: 'YouTube',
+ urlTemplate: 'https://youtube.com/@{username}',
+ icon: 'youtube',
+ contentTypes: ['videos', 'shorts', 'comments'],
+ category: 'video'
+ },
+ tiktok: {
+ label: 'TikTok',
+ urlTemplate: 'https://tiktok.com/@{username}',
+ icon: 'music',
+ contentTypes: ['videos', 'sounds'],
+ category: 'video'
+ },
+ reddit: {
+ label: 'Reddit',
+ urlTemplate: 'https://reddit.com/user/{username}',
+ icon: 'message-circle',
+ contentTypes: ['posts', 'comments'],
+ category: 'community'
+ },
+ bluesky: {
+ label: 'Bluesky',
+ urlTemplate: 'https://bsky.app/profile/{username}',
+ icon: 'cloud',
+ contentTypes: ['posts', 'reposts'],
+ category: 'social'
+ },
+ mastodon: {
+ label: 'Mastodon',
+ urlTemplate: '{url}',
+ icon: 'globe',
+ contentTypes: ['toots', 'boosts'],
+ category: 'social'
+ },
+ threads: {
+ label: 'Threads',
+ urlTemplate: 'https://threads.net/@{username}',
+ icon: 'at-sign',
+ contentTypes: ['posts', 'replies'],
+ category: 'social'
+ },
+ other: {
+ label: 'Other',
+ urlTemplate: '{url}',
+ icon: 'link',
+ contentTypes: [],
+ category: 'other'
+ }
+};
+
+async function loadAccounts() {
+ const now = Date.now();
+ if (cache && (now - cacheTimestamp) < CACHE_TTL_MS) {
+ return cache;
+ }
+
+ await ensureDir(PATHS.digitalTwin);
+
+ if (!existsSync(DATA_FILE)) {
+ cache = { accounts: {} };
+ cacheTimestamp = now;
+ return cache;
+ }
+
+ const content = await readFile(DATA_FILE, 'utf-8');
+ cache = JSON.parse(content);
+ cacheTimestamp = now;
+ return cache;
+}
+
+async function saveAccounts(data) {
+ await ensureDir(PATHS.digitalTwin);
+ await writeFile(DATA_FILE, JSON.stringify(data, null, 2));
+ cache = data;
+ cacheTimestamp = Date.now();
+}
+
+export function invalidateCache() {
+ cache = null;
+ cacheTimestamp = 0;
+}
+
+export function notifyChanged(action = 'update', accountId = null) {
+ socialAccountEvents.emit('changed', { action, accountId, timestamp: Date.now() });
+}
+
+/**
+ * Get all social accounts
+ */
+export async function getAllAccounts() {
+ const data = await loadAccounts();
+ return Object.entries(data.accounts).map(([id, account]) => ({
+ id,
+ ...account
+ }));
+}
+
+/**
+ * Get account by ID
+ */
+export async function getAccountById(id) {
+ const data = await loadAccounts();
+ const account = data.accounts[id];
+ if (!account) return null;
+ return { id, ...account };
+}
+
+/**
+ * Get accounts by platform
+ */
+export async function getAccountsByPlatform(platform) {
+ const accounts = await getAllAccounts();
+ return accounts.filter(a => a.platform === platform);
+}
+
+/**
+ * Get accounts by category
+ */
+export async function getAccountsByCategory(category) {
+ const accounts = await getAllAccounts();
+ return accounts.filter(a => {
+ const platformDef = PLATFORMS[a.platform];
+ return platformDef && platformDef.category === category;
+ });
+}
+
+/**
+ * Create a new social account
+ */
+export async function createAccount(accountData) {
+ const data = await loadAccounts();
+ const id = uuidv4();
+ const now = new Date().toISOString();
+
+ const account = {
+ platform: accountData.platform,
+ username: accountData.username,
+ displayName: accountData.displayName || accountData.username,
+ url: accountData.url || buildUrl(accountData.platform, accountData.username),
+ bio: accountData.bio || '',
+ contentTypes: accountData.contentTypes || PLATFORMS[accountData.platform]?.contentTypes || [],
+ ingestionEnabled: accountData.ingestionEnabled ?? false,
+ ingestionStatus: 'pending',
+ lastIngested: null,
+ contentCount: 0,
+ notes: accountData.notes || '',
+ createdAt: now,
+ updatedAt: now
+ };
+
+ data.accounts[id] = account;
+ await saveAccounts(data);
+ notifyChanged('create', id);
+
+ console.log(`🔗 Added social account: ${account.platform}/${account.username} (${id})`);
+ return { id, ...account };
+}
+
+/**
+ * Update a social account
+ */
+export async function updateAccount(id, updates) {
+ const data = await loadAccounts();
+ if (!data.accounts[id]) return null;
+
+ const allowed = [
+ 'username', 'displayName', 'url', 'bio', 'contentTypes',
+ 'ingestionEnabled', 'ingestionStatus', 'lastIngested',
+ 'contentCount', 'notes'
+ ];
+
+ for (const key of allowed) {
+ if (updates[key] !== undefined) {
+ data.accounts[id][key] = updates[key];
+ }
+ }
+ data.accounts[id].updatedAt = new Date().toISOString();
+
+ await saveAccounts(data);
+ notifyChanged('update', id);
+
+ console.log(`📝 Updated social account: ${data.accounts[id].platform}/${data.accounts[id].username} (${id})`);
+ return { id, ...data.accounts[id] };
+}
+
+/**
+ * Delete a social account
+ */
+export async function deleteAccount(id) {
+ const data = await loadAccounts();
+ if (!data.accounts[id]) return false;
+
+ const account = data.accounts[id];
+ delete data.accounts[id];
+ await saveAccounts(data);
+ notifyChanged('delete', id);
+
+ console.log(`🗑️ Removed social account: ${account.platform}/${account.username} (${id})`);
+ return true;
+}
+
+/**
+ * Get supported platforms list
+ */
+export function getSupportedPlatforms() {
+ return Object.entries(PLATFORMS).map(([id, platform]) => ({
+ id,
+ ...platform
+ }));
+}
+
+/**
+ * Get account summary stats
+ */
+export async function getAccountStats() {
+ const accounts = await getAllAccounts();
+ const byCategory = {};
+ const byPlatform = {};
+
+ for (const account of accounts) {
+ const platformDef = PLATFORMS[account.platform];
+ const category = platformDef?.category || 'other';
+
+ byCategory[category] = (byCategory[category] || 0) + 1;
+ byPlatform[account.platform] = (byPlatform[account.platform] || 0) + 1;
+ }
+
+ return {
+ total: accounts.length,
+ ingestionEnabled: accounts.filter(a => a.ingestionEnabled).length,
+ byCategory,
+ byPlatform
+ };
+}
+
+/**
+ * Build a profile URL from platform and username
+ */
+function buildUrl(platform, username) {
+ const platformDef = PLATFORMS[platform];
+ if (!platformDef) return '';
+ return platformDef.urlTemplate.replace('{username}', username);
+}