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
feat(agents): redesign to agent-centric drill-down hierarchy
Adam Eivy840b348d4944
diff --git a/.changelog/v0.12.x.md b/.changelog/v0.12.x.mdindex 0599413b93..28cc0263f3 100644--- a/.changelog/v0.12.x.md+++ b/.changelog/v0.12.x.md@@ -91,6 +91,29 @@ This release adds branch management and automated release workflow capabilities- `server/routes/agentTools.js` — Added GET/POST/PUT/DELETE draft endpoints- `server/lib/validation.js` — Added `createDraftSchema` and `updateDraftSchema`+### Agents — Published Content Tracking+- **Published content panel**: New section in Tools tab showing all posts and comments published by an agent+- **Live engagement metrics**: Displays current score and comment count fetched from Moltbook API+- **Direct links**: Each published item links directly to its page on Moltbook+- **Configurable timeframe**: View published content from the last 7, 14, or 30 days+- **Auto-refresh**: Published content list refreshes after publishing or engaging++**Server changes**:+- `server/routes/agentTools.js` — Added `GET /published` endpoint that aggregates activity logs across multiple days and enriches with live Moltbook data++**Client changes**:+- `client/src/services/api.js` — Added `getAgentPublished()` API function+- `client/src/components/agents/tabs/ToolsTab.jsx` — Published Content section with posts/comments tables, engagement stats, days selector, and auto-refresh on publish/engage++### Agents — Agent-Centric Drill-Down Redesign+- **Agent list view**: Top-level grid of agent cards with aggregate stats, replacing the flat tab layout+- **Agent detail view**: Drill into any agent to see all its data: personality, accounts, tools, published content, schedules, and activity+- **Merged Overview tab**: Personality editing and account management unified in a single view per agent+- **Published content tab**: Promoted from a section in Tools to its own dedicated tab with engagement metrics+- **Scoped sub-tabs**: All sub-tabs (Tools, Published, Schedules, Activity) are automatically filtered to the selected agent — no more redundant agent selectors+- **Deep-linkable URLs**: Every view has a unique URL (e.g., `/agents/:id/tools`, `/agents/:id/published`)+- **Simplified sidebar**: Agents section collapsed from a 5-item expandable menu to a single link+### Dashboard — Archived App Styling- **Greyed-out cards**: Archived apps on the main dashboard now render with reduced opacity, dimmed icon/title colors, and a subtle "Archived" badge next to the app name- **Sorted to bottom**: Archived apps are sorted after active apps in the grid so they don't intermix with actively managed services@@ -103,6 +126,10 @@ This release adds branch management and automated release workflow capabilities- **Fix**: Port detection regex in `parseEcosystemConfig()` couldn't parse `process.env.PORT || 4420` expressions — it only captured `process.env.PORT` and failed to resolve it. Now extracts the `|| fallback` value.- **Solution**: `startFromEcosystem()` now strips `PORT` and `HOST` from the inherited env before spawning PM2, and `resolvePortValue()` handles `expr || fallback` patterns+### CoS Runner State File Corruption+- **Fix**: `loadState()` in `cos-runner/index.js` used heuristic `isValidJSON()` checks that rejected valid nested JSON (e.g., objects ending with `}}`) and missed actual corruption (extra `}` on a separate line). A concurrent `saveState()` race condition could produce partial writes, corrupting the state file.+- **Solution**: Replaced heuristic validation with direct `JSON.parse`, added atomic writes (temp file + rename) to prevent partial-write corruption, and serialized `saveState()` calls through a promise chain to eliminate race conditions+### Runner Config Access Crash- **Fix**: `server/services/runner.js` was accessing `aiToolkitInstance.config.dataDir` and `aiToolkitInstance.config.hooks`, but the AI Toolkit object returned by `createAIToolkit()` has no `.config` property (config is internal to service closures). This caused a `TypeError: Cannot read properties of undefined (reading 'dataDir')` whenever the PortOS runner shim's `executeCliRun` was invoked.- **Solution**: Pass `dataDir` and `hooks` explicitly to the runner shim via `setAIToolkit(toolkit, config)` and store them in a local `runnerConfig` variablediff --git a/PLAN.md b/PLAN.mdindex e186e213c8..c57273bc90 100644--- a/PLAN.md+++ b/PLAN.md@@ -65,6 +65,7 @@ pm2 logs- [x] **M36**: Browser Management - CDP/Playwright browser page with status, controls, config, and logs- [x] **M37**: Autonomous Jobs - Recurring scheduled jobs that the CoS executes proactively using digital twin identity- [x] **M38**: Agent Tools - AI content generation, feed browsing, and autonomous engagement for Moltbook agents+- [x] **M39**: Agent-Centric Drill-Down - Redesigned Agents section with agent-first hierarchy, deep-linkable URLs, and scoped sub-tabs### Planneddiff --git a/client/src/App.jsx b/client/src/App.jsxindex b3973efc20..2e4930d11b 100644--- a/client/src/App.jsx+++ b/client/src/App.jsx@@ -62,8 +62,9 @@ export default function App() {<Route path="uploads" element={<Uploads />} /><Route path="shell" element={<Shell />} /><Route path="browser" element={<BrowserPage />} />- <Route path="agents" element={<Navigate to="/agents/personalities" replace />} />- <Route path="agents/:tab" element={<Agents />} />+ <Route path="agents" element={<Agents />} />+ <Route path="agents/:agentId" element={<Agents />} />+ <Route path="agents/:agentId/:tab" element={<Agents />} /><Route path="*" element={<Navigate to="/" replace />} /></Route></Routes>diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsxindex a1c4e9e4cc..fb523591b3 100644--- a/client/src/components/Layout.jsx+++ b/client/src/components/Layout.jsx@@ -29,8 +29,6 @@ import {GraduationCap,Settings,Users,- Link2,- LineChart,Upload,SquareTerminal,Globe@@ -44,17 +42,7 @@ import NotificationDropdown from './NotificationDropdown';const navItems = [{ to: '/', label: 'Dashboard', icon: Home, single: true },{ separator: true },- {- label: 'Agents',- icon: Users,- children: [- { to: '/agents/personalities', label: 'Personalities', icon: Bot },- { to: '/agents/accounts', label: 'Accounts', icon: Link2 },- { to: '/agents/schedules', label: 'Schedules', icon: Calendar },- { to: '/agents/activity', label: 'Activity', icon: LineChart },- { to: '/agents/config', label: 'Config', icon: Settings }- ]- },+ { to: '/agents', label: 'Agents', icon: Users, single: true },{label: 'AI Config',icon: Bot,diff --git a/client/src/components/agents/AgentDetail.jsx b/client/src/components/agents/AgentDetail.jsxnew file mode 100644index 0000000000..20c60650f0--- /dev/null+++ b/client/src/components/agents/AgentDetail.jsx@@ -0,0 +1,143 @@+import { useState, useEffect, useCallback } from 'react';+import { Link, useParams, useNavigate } from 'react-router-dom';+import { ArrowLeft } from 'lucide-react';+import * as api from '../../services/api';+import { AGENT_DETAIL_TABS } from './constants';+import OverviewTab from './tabs/OverviewTab';+import ToolsTab from './tabs/ToolsTab';+import PublishedTab from './tabs/PublishedTab';+import SchedulesTab from './tabs/SchedulesTab';+import ActivityTab from './tabs/ActivityTab';++export default function AgentDetail() {+ const { agentId, tab } = useParams();+ const navigate = useNavigate();+ const activeTab = tab || 'overview';++ const [agent, setAgent] = useState(null);+ const [loading, setLoading] = useState(true);+ const [notFound, setNotFound] = useState(false);++ const fetchAgent = useCallback(async () => {+ const data = await api.getAgentPersonality(agentId).catch(() => null);+ if (!data) {+ setNotFound(true);+ setLoading(false);+ return;+ }+ setAgent(data);+ setLoading(false);+ }, [agentId]);++ useEffect(() => {+ fetchAgent();+ }, [fetchAgent]);++ // Redirect bare /agents/:id to /agents/:id/overview+ useEffect(() => {+ if (!tab && agentId) {+ navigate(`/agents/${agentId}/overview`, { replace: true });+ }+ }, [tab, agentId, navigate]);++ const handleToggle = async () => {+ await api.toggleAgentPersonality(agent.id, !agent.enabled);+ fetchAgent();+ };++ if (loading) {+ return <div className="p-6 text-gray-400">Loading agent...</div>;+ }++ if (notFound) {+ return (+ <div className="p-6 text-center">+ <p className="text-lg text-gray-400 mb-4">Agent not found</p>+ <Link to="/agents" className="text-port-accent hover:text-port-accent/80">+ Back to Agents+ </Link>+ </div>+ );+ }++ const renderTab = () => {+ switch (activeTab) {+ case 'overview':+ return <OverviewTab agentId={agentId} agent={agent} onAgentUpdate={fetchAgent} />;+ case 'tools':+ return <ToolsTab agentId={agentId} />;+ case 'published':+ return <PublishedTab agentId={agentId} />;+ case 'schedules':+ return <SchedulesTab agentId={agentId} />;+ case 'activity':+ return <ActivityTab agentId={agentId} />;+ default:+ return <OverviewTab agentId={agentId} agent={agent} onAgentUpdate={fetchAgent} />;+ }+ };++ return (+ <div className="flex flex-col h-full">+ {/* Header */}+ <div className="border-b border-port-border px-6 py-4">+ <div className="flex items-center gap-4">+ <Link+ to="/agents"+ className="p-1.5 text-gray-400 hover:text-white transition-colors rounded hover:bg-port-border/50"+ >+ <ArrowLeft size={20} />+ </Link>+ <div+ className="w-10 h-10 rounded-full flex items-center justify-center text-xl shrink-0"+ style={{ backgroundColor: agent.avatar?.color || '#3b82f6' }}+ >+ {agent.avatar?.emoji || '🤖'}+ </div>+ <div className="flex-1 min-w-0">+ <h1 className="text-xl font-bold text-white truncate">{agent.name}</h1>+ {agent.description && (+ <p className="text-sm text-gray-400 truncate">{agent.description}</p>+ )}+ </div>+ <button+ onClick={handleToggle}+ className={`px-3 py-1.5 text-sm rounded ${+ agent.enabled+ ? 'bg-port-success/20 text-port-success hover:bg-port-success/30'+ : 'bg-port-border text-gray-400 hover:bg-port-border/80'+ }`}+ >+ {agent.enabled ? 'Enabled' : 'Disabled'}+ </button>+ </div>+ </div>++ {/* Sub-tab Navigation */}+ <div className="flex gap-1 px-4 py-2 border-b border-port-border bg-port-card/50">+ {AGENT_DETAIL_TABS.map(tabDef => {+ const isActive = activeTab === tabDef.id;+ return (+ <button+ key={tabDef.id}+ onClick={() => navigate(`/agents/${agentId}/${tabDef.id}`)}+ className={`px-4 py-2 rounded-t flex items-center gap-2 transition-colors ${+ isActive+ ? 'bg-port-bg text-white border-t border-l border-r border-port-border -mb-px'+ : 'text-gray-400 hover:text-white hover:bg-port-border/30'+ }`}+ >+ <span>{tabDef.icon}</span>+ <span>{tabDef.label}</span>+ </button>+ );+ })}+ </div>++ {/* Tab Content */}+ <div className="flex-1 overflow-auto bg-port-bg">+ {renderTab()}+ </div>+ </div>+ );+}diff --git a/client/src/components/agents/AgentList.jsx b/client/src/components/agents/AgentList.jsxnew file mode 100644index 0000000000..9cee28383a--- /dev/null+++ b/client/src/components/agents/AgentList.jsx@@ -0,0 +1,442 @@+import { useState, useEffect, useCallback } from 'react';+import { Link } from 'react-router-dom';+import { Sparkles } from 'lucide-react';+import toast from 'react-hot-toast';+import * as api from '../../services/api';+import { PERSONALITY_STYLES, DEFAULT_PERSONALITY, DEFAULT_AVATAR } from './constants';++export default function AgentList() {+ const [agents, setAgents] = useState([]);+ const [loading, setLoading] = useState(true);+ const [stats, setStats] = useState({ agents: 0, accounts: 0, schedules: 0, totalRuns: 0 });+ const [showForm, setShowForm] = useState(false);+ const [formData, setFormData] = useState({+ name: '',+ description: '',+ userId: 'default',+ personality: { ...DEFAULT_PERSONALITY },+ avatar: { ...DEFAULT_AVATAR },+ enabled: true+ });++ // AI generation state+ const [providers, setProviders] = useState([]);+ const [selectedProviderId, setSelectedProviderId] = useState('');+ const [selectedModel, setSelectedModel] = useState('');+ const [generating, setGenerating] = useState(false);++ // Raw text state for comma-separated fields+ const [topicsText, setTopicsText] = useState('');+ const [quirksText, setQuirksText] = useState('');++ // Per-agent counts+ const [accountCounts, setAccountCounts] = useState({});+ const [scheduleCounts, setScheduleCounts] = useState({});++ const fetchData = useCallback(async () => {+ const [agentsData, accountsData, scheduleStats, providersData] = await Promise.all([+ api.getAgentPersonalities(),+ api.getPlatformAccounts(),+ api.getScheduleStats(),+ api.getProviders()+ ]);+ setAgents(agentsData);+ setProviders((providersData.providers || []).filter(p => p.enabled));+ setStats({+ agents: agentsData.length,+ accounts: accountsData.length,+ schedules: scheduleStats.total,+ totalRuns: scheduleStats.totalRuns || 0+ });++ // Count accounts per agent+ const acctCounts = {};+ accountsData.forEach(a => {+ acctCounts[a.agentId] = (acctCounts[a.agentId] || 0) + 1;+ });+ setAccountCounts(acctCounts);++ // Count schedules per agent from schedule list+ const schedData = await api.getAutomationSchedules();+ const schedCounts = {};+ schedData.forEach(s => {+ schedCounts[s.agentId] = (schedCounts[s.agentId] || 0) + 1;+ });+ setScheduleCounts(schedCounts);++ setLoading(false);+ }, []);++ useEffect(() => {+ fetchData();+ }, [fetchData]);++ // Sync raw text fields when formData changes+ useEffect(() => {+ setTopicsText(formData.personality.topics.join(', '));+ setQuirksText(formData.personality.quirks.join(', '));+ }, [formData.personality.topics, formData.personality.quirks]);++ const selectedProvider = providers.find(p => p.id === selectedProviderId);+ const availableModels = selectedProvider?.models || [];++ const handleGenerate = async () => {+ setGenerating(true);+ const seedData = {+ name: formData.name.trim(),+ description: formData.description.trim(),+ personality: {+ style: formData.personality.style,+ tone: formData.personality.tone,+ topics: topicsText.split(',').map(t => t.trim()).filter(Boolean),+ quirks: quirksText.split(',').map(t => t.trim()).filter(Boolean),+ promptPrefix: formData.personality.promptPrefix.trim()+ },+ avatar: { emoji: formData.avatar.emoji, color: formData.avatar.color }+ };+ const generated = await api.generateAgentPersonality(+ seedData, selectedProviderId || null, selectedModel || null+ ).catch(() => null);+ setGenerating(false);++ if (!generated) return;++ setFormData(prev => ({+ ...prev,+ name: generated.name || prev.name,+ description: generated.description || prev.description,+ personality: {+ style: generated.personality?.style || prev.personality.style,+ tone: generated.personality?.tone || prev.personality.tone,+ topics: generated.personality?.topics || prev.personality.topics,+ quirks: generated.personality?.quirks || prev.personality.quirks,+ promptPrefix: generated.personality?.promptPrefix || prev.personality.promptPrefix+ },+ avatar: {+ emoji: generated.avatar?.emoji || prev.avatar.emoji,+ color: generated.avatar?.color || prev.avatar.color+ }+ }));+ toast.success(`Generated: ${generated.name || 'personality'}`);+ };++ const resetForm = () => {+ setFormData({+ name: '',+ description: '',+ userId: 'default',+ personality: { ...DEFAULT_PERSONALITY },+ avatar: { ...DEFAULT_AVATAR },+ enabled: true+ });+ setShowForm(false);+ };++ const handleSubmit = async (e) => {+ e.preventDefault();+ const submitData = {+ ...formData,+ personality: {+ ...formData.personality,+ topics: topicsText.split(',').map(t => t.trim()).filter(Boolean),+ quirks: quirksText.split(',').map(t => t.trim()).filter(Boolean)+ }+ };+ await api.createAgentPersonality(submitData);+ resetForm();+ fetchData();+ };++ const updatePersonality = (field, value) => {+ setFormData(prev => ({+ ...prev,+ personality: { ...prev.personality, [field]: value }+ }));+ };++ if (loading) {+ return <div className="p-6 text-gray-400">Loading agents...</div>;+ }++ return (+ <div className="flex flex-col h-full">+ {/* Header */}+ <div className="border-b border-port-border px-6 py-4">+ <div className="flex justify-between items-center">+ <div>+ <h1 className="text-2xl font-bold text-white">Agents</h1>+ <p className="text-sm text-gray-400 mt-1">+ Manage AI agent personalities and their platform automation+ </p>+ </div>+ <button+ onClick={() => setShowForm(!showForm)}+ className="px-4 py-2 bg-port-accent text-white rounded hover:bg-port-accent/80"+ >+ {showForm ? 'Cancel' : '+ New Agent'}+ </button>+ </div>+ </div>++ <div className="flex-1 overflow-auto p-6">+ {/* Stats Bar */}+ <div className="grid grid-cols-4 gap-4 mb-6">+ <div className="p-4 bg-port-card border border-port-border rounded-lg">+ <div className="text-2xl font-bold text-white">{stats.agents}</div>+ <div className="text-sm text-gray-400">Total Agents</div>+ <div className="text-xs text-port-success">+ {agents.filter(a => a.enabled).length} enabled+ </div>+ </div>+ <div className="p-4 bg-port-card border border-port-border rounded-lg">+ <div className="text-2xl font-bold text-white">{stats.accounts}</div>+ <div className="text-sm text-gray-400">Platform Accounts</div>+ </div>+ <div className="p-4 bg-port-card border border-port-border rounded-lg">+ <div className="text-2xl font-bold text-white">{stats.schedules}</div>+ <div className="text-sm text-gray-400">Schedules</div>+ </div>+ <div className="p-4 bg-port-card border border-port-border rounded-lg">+ <div className="text-2xl font-bold text-white">{stats.totalRuns}</div>+ <div className="text-sm text-gray-400">Total Runs</div>+ </div>+ </div>++ {/* Create Form */}+ {showForm && (+ <form onSubmit={handleSubmit} className="mb-6 p-4 bg-port-card border border-port-border rounded-lg">+ <h3 className="text-md font-semibold text-white mb-4">Create New Agent</h3>++ {/* AI Generation Section */}+ <div className="mb-4 p-3 bg-port-bg border border-port-accent/30 rounded-lg">+ <div className="flex items-center gap-2 mb-3">+ <Sparkles size={16} className="text-port-accent" />+ <span className="text-sm font-medium text-white">Generate with AI</span>+ </div>+ <div className="flex items-end gap-3">+ <div className="flex-1">+ <label className="block text-xs text-gray-400 mb-1">Provider</label>+ <select+ value={selectedProviderId}+ onChange={(e) => { setSelectedProviderId(e.target.value); setSelectedModel(''); }}+ disabled={generating}+ className="w-full px-2 py-1.5 bg-port-card border border-port-border rounded text-white text-sm"+ >+ <option value="">Default (active)</option>+ {providers.map(p => (+ <option key={p.id} value={p.id}>{p.name}</option>+ ))}+ </select>+ </div>+ <div className="flex-1">+ <label className="block text-xs text-gray-400 mb-1">Model</label>+ <select+ value={selectedModel}+ onChange={(e) => setSelectedModel(e.target.value)}+ disabled={generating}+ className="w-full px-2 py-1.5 bg-port-card border border-port-border rounded text-white text-sm"+ >+ <option value="">Default</option>+ {availableModels.map(m => (+ <option key={m} value={m}>{m}</option>+ ))}+ </select>+ </div>+ <button+ type="button"+ onClick={handleGenerate}+ disabled={generating}+ className="px-4 py-1.5 bg-port-accent text-white rounded hover:bg-port-accent/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"+ >+ {generating ? (+ <><span className="animate-spin">⚡</span>Generating...</>+ ) : (+ <><Sparkles size={14} />Generate</>+ )}+ </button>+ </div>+ <p className="text-xs text-gray-500 mt-2">+ Generate a complete personality including name, style, topics, and avatar+ </p>+ </div>++ <div className="grid grid-cols-2 gap-4 mb-4">+ <div>+ <label className="block text-sm text-gray-400 mb-1">Name</label>+ <input+ type="text"+ value={formData.name}+ onChange={(e) => setFormData({ ...formData, name: e.target.value })}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ required+ />+ </div>+ <div>+ <label className="block text-sm text-gray-400 mb-1">Style</label>+ <select+ value={formData.personality.style}+ onChange={(e) => updatePersonality('style', e.target.value)}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ >+ {PERSONALITY_STYLES.map(style => (+ <option key={style.value} value={style.value}>{style.label}</option>+ ))}+ </select>+ </div>+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Description</label>+ <textarea+ value={formData.description}+ onChange={(e) => setFormData({ ...formData, description: e.target.value })}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white h-20"+ placeholder="Brief description of this agent's purpose..."+ />+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Tone</label>+ <input+ type="text"+ value={formData.personality.tone}+ onChange={(e) => updatePersonality('tone', e.target.value)}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ placeholder="e.g., friendly but informative"+ />+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Topics (comma-separated)</label>+ <input+ type="text"+ value={topicsText}+ onChange={(e) => setTopicsText(e.target.value)}+ onBlur={() => updatePersonality('topics', topicsText.split(',').map(t => t.trim()).filter(Boolean))}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ placeholder="e.g., technology, AI, philosophy"+ />+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Quirks (comma-separated)</label>+ <input+ type="text"+ value={quirksText}+ onChange={(e) => setQuirksText(e.target.value)}+ onBlur={() => updatePersonality('quirks', quirksText.split(',').map(t => t.trim()).filter(Boolean))}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ placeholder="e.g., uses metaphors, asks follow-up questions"+ />+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Prompt Prefix</label>+ <textarea+ value={formData.personality.promptPrefix}+ onChange={(e) => updatePersonality('promptPrefix', e.target.value)}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white h-24 font-mono text-sm"+ placeholder="Custom instructions injected into AI prompts..."+ />+ </div>++ <div className="flex items-center gap-4 mb-4">+ <label className="block text-sm text-gray-400">Avatar Emoji</label>+ <input+ type="text"+ value={formData.avatar.emoji || ''}+ onChange={(e) => setFormData({ ...formData, avatar: { ...formData.avatar, emoji: e.target.value } })}+ className="w-16 px-3 py-2 bg-port-bg border border-port-border rounded text-white text-center"+ maxLength={2}+ />+ <label className="block text-sm text-gray-400">Color</label>+ <input+ type="color"+ value={formData.avatar.color || '#3b82f6'}+ onChange={(e) => setFormData({ ...formData, avatar: { ...formData.avatar, color: e.target.value } })}+ className="w-12 h-8 border border-port-border rounded cursor-pointer"+ />+ </div>++ <div className="flex gap-2">+ <button+ type="submit"+ className="px-4 py-2 bg-port-success text-white rounded hover:bg-port-success/80"+ >+ Create Agent+ </button>+ <button+ type="button"+ onClick={resetForm}+ className="px-4 py-2 bg-port-border text-gray-300 rounded hover:bg-port-border/80"+ >+ Cancel+ </button>+ </div>+ </form>+ )}++ {/* Agent Cards Grid */}+ {agents.length === 0 ? (+ <div className="text-center py-12 text-gray-400">+ <p className="text-lg mb-2">No agents yet</p>+ <p className="text-sm">Create your first AI agent to get started</p>+ </div>+ ) : (+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">+ {agents.map(agent => (+ <Link+ key={agent.id}+ to={`/agents/${agent.id}`}+ className={`block p-4 bg-port-card border rounded-lg transition-colors hover:border-port-accent/50 ${+ agent.enabled ? 'border-port-border' : 'border-port-border/50 opacity-60'+ }`}+ >+ <div className="flex items-center gap-3 mb-3">+ <div+ className="w-12 h-12 rounded-full flex items-center justify-center text-2xl shrink-0"+ style={{ backgroundColor: agent.avatar?.color || '#3b82f6' }}+ >+ {agent.avatar?.emoji || '🤖'}+ </div>+ <div className="min-w-0">+ <h3 className="font-semibold text-white truncate">{agent.name}</h3>+ <p className="text-sm text-gray-400 truncate">{agent.description || 'No description'}</p>+ </div>+ </div>++ <div className="flex flex-wrap gap-1.5 mb-3">+ <span className="text-xs px-2 py-0.5 bg-port-accent/20 text-port-accent rounded">+ {PERSONALITY_STYLES.find(s => s.value === agent.personality?.style)?.label || agent.personality?.style}+ </span>+ {agent.personality?.topics?.slice(0, 2).map(topic => (+ <span key={topic} className="text-xs px-2 py-0.5 bg-port-border text-gray-300 rounded">+ {topic}+ </span>+ ))}+ {(agent.personality?.topics?.length || 0) > 2 && (+ <span className="text-xs px-2 py-0.5 bg-port-border text-gray-500 rounded">+ +{agent.personality.topics.length - 2}+ </span>+ )}+ </div>++ <div className="flex items-center gap-3 text-xs text-gray-500">+ <span>{accountCounts[agent.id] || 0} accounts</span>+ <span>{scheduleCounts[agent.id] || 0} schedules</span>+ <span className={`ml-auto px-2 py-0.5 rounded ${+ agent.enabled+ ? 'bg-port-success/20 text-port-success'+ : 'bg-port-border text-gray-400'+ }`}>+ {agent.enabled ? 'Enabled' : 'Disabled'}+ </span>+ </div>+ </Link>+ ))}+ </div>+ )}+ </div>+ </div>+ );+}diff --git a/client/src/components/agents/constants.js b/client/src/components/agents/constants.jsindex d6085a1b94..133b32b385 100644--- a/client/src/components/agents/constants.js+++ b/client/src/components/agents/constants.js@@ -2,13 +2,12 @@* Agent Feature Constants*/-export const TABS = [- { id: 'personalities', label: 'Personalities', icon: '🤖' },- { id: 'accounts', label: 'Accounts', icon: '🔗' },- { id: 'schedules', label: 'Schedules', icon: '📅' },+export const AGENT_DETAIL_TABS = [+ { id: 'overview', label: 'Overview', icon: '📋' },{ id: 'tools', label: 'Tools', icon: '🛠️' },- { id: 'activity', label: 'Activity', icon: '📊' },- { id: 'config', label: 'Config', icon: '⚙️' }+ { id: 'published', label: 'Published', icon: '📰' },+ { id: 'schedules', label: 'Schedules', icon: '📅' },+ { id: 'activity', label: 'Activity', icon: '📊' }];export const PERSONALITY_STYLES = [diff --git a/client/src/components/agents/index.js b/client/src/components/agents/index.jsindex bbf12edeb6..25eaff5cd1 100644--- a/client/src/components/agents/index.js+++ b/client/src/components/agents/index.js@@ -4,10 +4,13 @@export * from './constants.js';+// Top-level components+export { default as AgentList } from './AgentList.jsx';+export { default as AgentDetail } from './AgentDetail.jsx';+// Tab components-export { default as PersonalitiesTab } from './tabs/PersonalitiesTab.jsx';-export { default as AccountsTab } from './tabs/AccountsTab.jsx';-export { default as SchedulesTab } from './tabs/SchedulesTab.jsx';+export { default as OverviewTab } from './tabs/OverviewTab.jsx';export { default as ToolsTab } from './tabs/ToolsTab.jsx';+export { default as PublishedTab } from './tabs/PublishedTab.jsx';+export { default as SchedulesTab } from './tabs/SchedulesTab.jsx';export { default as ActivityTab } from './tabs/ActivityTab.jsx';-export { default as ConfigTab } from './tabs/ConfigTab.jsx';diff --git a/client/src/components/agents/tabs/AccountsTab.jsx b/client/src/components/agents/tabs/AccountsTab.jsxdeleted file mode 100644index dff3634e37..0000000000--- a/client/src/components/agents/tabs/AccountsTab.jsx+++ /dev/null@@ -1,308 +0,0 @@-import { useState, useEffect, useCallback } from 'react';-import * as api from '../../../services/api';-import { PLATFORM_TYPES, ACCOUNT_STATUSES } from '../constants';--export default function AccountsTab({ onRefresh }) {- const [accounts, setAccounts] = useState([]);- const [agents, setAgents] = useState([]);- const [loading, setLoading] = useState(true);- const [showForm, setShowForm] = useState(false);- const [formData, setFormData] = useState({- agentId: '',- platform: 'moltbook',- name: '',- description: ''- });- const [testingId, setTestingId] = useState(null);- const [testResult, setTestResult] = useState(null);-- const fetchData = useCallback(async () => {- const [accountsData, agentsData] = await Promise.all([- api.getPlatformAccounts(),- api.getAgentPersonalities()- ]);- setAccounts(accountsData);- setAgents(agentsData);- setLoading(false);- }, []);-- useEffect(() => {- fetchData();- }, [fetchData]);-- const resetForm = () => {- setFormData({- agentId: '',- platform: 'moltbook',- name: '',- description: ''- });- setShowForm(false);- };-- const handleSubmit = async (e) => {- e.preventDefault();-- const result = await api.registerPlatformAccount(- formData.agentId,- formData.platform,- formData.name,- formData.description- );-- resetForm();- fetchData();- onRefresh?.();-- // Show claim URL if returned- if (result.claimUrl) {- setTestResult({- accountId: result.id,- success: true,- message: 'Account registered! Visit the claim URL to activate.',- claimUrl: result.claimUrl- });- }- };-- const handleDelete = async (id) => {- await api.deletePlatformAccount(id);- fetchData();- onRefresh?.();- };-- const handleTest = async (id) => {- setTestingId(id);- setTestResult(null);- const result = await api.testPlatformAccount(id);- setTestResult({ accountId: id, ...result });- setTestingId(null);- };-- const handleClaim = async (id) => {- await api.claimPlatformAccount(id);- fetchData();- setTestResult(null);- };-- const getAgentName = (agentId) => {- const agent = agents.find(a => a.id === agentId);- return agent?.name || 'Unknown Agent';- };-- if (loading) {- return <div className="p-4 text-gray-400">Loading accounts...</div>;- }-- return (- <div className="p-4">- <div className="flex justify-between items-center mb-4">- <h2 className="text-lg font-semibold text-white">Platform Accounts</h2>- <button- onClick={() => setShowForm(!showForm)}- className="px-4 py-2 bg-port-accent text-white rounded hover:bg-port-accent/80"- disabled={agents.length === 0}- >- {showForm ? 'Cancel' : '+ Link Account'}- </button>- </div>-- {agents.length === 0 && (- <div className="mb-4 p-4 bg-port-warning/20 border border-port-warning/50 rounded text-port-warning">- Create an agent personality first before linking platform accounts.- </div>- )}-- {showForm && (- <form onSubmit={handleSubmit} className="mb-6 p-4 bg-port-card border border-port-border rounded-lg">- <h3 className="text-md font-semibold text-white mb-4">Register New Account</h3>-- <div className="grid grid-cols-2 gap-4 mb-4">- <div>- <label className="block text-sm text-gray-400 mb-1">Agent</label>- <select- value={formData.agentId}- onChange={(e) => {- const selectedAgent = agents.find(a => a.id === e.target.value);- setFormData({- ...formData,- agentId: e.target.value,- name: selectedAgent?.name || '',- description: selectedAgent?.description || ''- });- }}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"- required- >- <option value="">Select agent...</option>- {agents.map(agent => (- <option key={agent.id} value={agent.id}>- {agent.avatar?.emoji} {agent.name}- </option>- ))}- </select>- </div>- <div>- <label className="block text-sm text-gray-400 mb-1">Platform</label>- <select- value={formData.platform}- onChange={(e) => setFormData({ ...formData, platform: e.target.value })}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"- >- {PLATFORM_TYPES.map(platform => (- <option key={platform.value} value={platform.value}>- {platform.icon} {platform.label}- </option>- ))}- </select>- </div>- </div>-- <div className="mb-4">- <label className="block text-sm text-gray-400 mb-1">Account Name</label>- <input- type="text"- value={formData.name}- onChange={(e) => setFormData({ ...formData, name: e.target.value })}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"- placeholder="Display name on platform"- required- />- </div>-- <div className="mb-4">- <label className="block text-sm text-gray-400 mb-1">Bio/Description</label>- <textarea- value={formData.description}- onChange={(e) => setFormData({ ...formData, description: e.target.value })}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white h-20"- placeholder="Brief bio for the platform profile..."- />- </div>-- <div className="flex gap-2">- <button- type="submit"- className="px-4 py-2 bg-port-success text-white rounded hover:bg-port-success/80"- >- Register Account- </button>- <button- type="button"- onClick={resetForm}- className="px-4 py-2 bg-port-border text-gray-300 rounded hover:bg-port-border/80"- >- Cancel- </button>- </div>- </form>- )}-- {testResult && (- <div className={`mb-4 p-4 rounded border ${- testResult.success- ? 'bg-port-success/20 border-port-success/50 text-port-success'- : 'bg-port-error/20 border-port-error/50 text-port-error'- }`}>- <p>{testResult.message}</p>- {testResult.claimUrl && (- <div className="mt-2">- <a- href={testResult.claimUrl}- target="_blank"- rel="noopener noreferrer"- className="text-port-accent underline"- >- {testResult.claimUrl}- </a>- <button- onClick={() => handleClaim(testResult.accountId)}- className="ml-4 px-3 py-1 bg-port-accent text-white rounded text-sm"- >- I've claimed it- </button>- </div>- )}- </div>- )}-- {accounts.length === 0 ? (- <div className="text-center py-8 text-gray-400">- <p className="text-lg mb-2">No platform accounts</p>- <p className="text-sm">Link an agent to a social platform to get started</p>- </div>- ) : (- <div className="grid gap-4">- {accounts.map(account => {- const statusConfig = ACCOUNT_STATUSES[account.status] || ACCOUNT_STATUSES.error;- const platform = PLATFORM_TYPES.find(p => p.value === account.platform);-- return (- <div- key={account.id}- className="p-4 bg-port-card border border-port-border rounded-lg"- >- <div className="flex items-start justify-between">- <div>- <div className="flex items-center gap-2 mb-1">- <span className="text-xl">{platform?.icon || '🔗'}</span>- <h3 className="font-semibold text-white">- {account.credentials.username}- </h3>- <span className={`text-xs px-2 py-0.5 rounded ${statusConfig.bgColor} ${statusConfig.color}`}>- {statusConfig.label}- </span>- </div>- <p className="text-sm text-gray-400">- {platform?.label} • Agent: {getAgentName(account.agentId)}- </p>- {account.lastActivity && (- <p className="text-xs text-gray-500 mt-1">- Last activity: {new Date(account.lastActivity).toLocaleString()}- </p>- )}- {account.platformData?.claimUrl && account.status === 'pending' && (- <div className="mt-2 text-sm">- <a- href={account.platformData.claimUrl}- target="_blank"- rel="noopener noreferrer"- className="text-port-accent underline"- >- Claim URL- </a>- </div>- )}- </div>- <div className="flex items-center gap-2">- <button- onClick={() => handleTest(account.id)}- disabled={testingId === account.id}- className="px-3 py-1 text-xs bg-port-accent/20 text-port-accent rounded hover:bg-port-accent/30 disabled:opacity-50"- >- {testingId === account.id ? 'Testing...' : 'Test'}- </button>- {account.status === 'pending' && (- <button- onClick={() => handleClaim(account.id)}- className="px-3 py-1 text-xs bg-port-success/20 text-port-success rounded hover:bg-port-success/30"- >- Mark Claimed- </button>- )}- <button- onClick={() => handleDelete(account.id)}- className="px-3 py-1 text-xs bg-port-error/20 text-port-error rounded hover:bg-port-error/30"- >- Delete- </button>- </div>- </div>- </div>- );- })}- </div>- )}- </div>- );-}diff --git a/client/src/components/agents/tabs/ActivityTab.jsx b/client/src/components/agents/tabs/ActivityTab.jsxindex 2ccd98e48e..9e754786ce 100644--- a/client/src/components/agents/tabs/ActivityTab.jsx+++ b/client/src/components/agents/tabs/ActivityTab.jsx@@ -2,23 +2,20 @@ import { useState, useEffect, useCallback } from 'react';import * as api from '../../../services/api';import { ACTION_TYPES } from '../constants';-export default function ActivityTab() {+export default function ActivityTab({ agentId }) {const [activities, setActivities] = useState([]);- const [agents, setAgents] = useState([]);const [loading, setLoading] = useState(true);- const [filter, setFilter] = useState({ agentId: '', action: '' });+ const [actionFilter, setActionFilter] = useState('');const [hasMore, setHasMore] = useState(true);const fetchData = useCallback(async () => {- const [activitiesData, agentsData] = await Promise.all([- api.getAgentActivities(50, filter.agentId ? [filter.agentId] : null, filter.action || null),- api.getAgentPersonalities()- ]);+ const activitiesData = await api.getAgentActivities(+ 50, [agentId], actionFilter || null+ );setActivities(activitiesData);- setAgents(agentsData);setHasMore(activitiesData.length >= 50);setLoading(false);- }, [filter]);+ }, [agentId, actionFilter]);useEffect(() => {fetchData();@@ -29,9 +26,7 @@ export default function ActivityTab() {const lastTimestamp = activities[activities.length - 1].timestamp;const moreData = await api.getAgentActivityTimeline(- 50,- filter.agentId ? [filter.agentId] : null,- lastTimestamp+ 50, [agentId], lastTimestamp);if (moreData.length < 50) {@@ -41,11 +36,6 @@ export default function ActivityTab() {setActivities(prev => [...prev, ...moreData]);};- const getAgentInfo = (agentId) => {- const agent = agents.find(a => a.id === agentId);- return agent || { name: 'Unknown', avatar: { emoji: '❓' } };- };-const getActionIcon = (action) => {const actionType = ACTION_TYPES.find(a => a.value === action);return actionType?.icon || '📋';@@ -74,20 +64,8 @@ export default function ActivityTab() {<h2 className="text-lg font-semibold text-white">Activity Log</h2><div className="flex gap-2"><select- value={filter.agentId}- onChange={(e) => setFilter({ ...filter, agentId: e.target.value })}- className="px-3 py-1 bg-port-bg border border-port-border rounded text-white text-sm"- >- <option value="">All Agents</option>- {agents.map(agent => (- <option key={agent.id} value={agent.id}>- {agent.avatar?.emoji} {agent.name}- </option>- ))}- </select>- <select- value={filter.action}- onChange={(e) => setFilter({ ...filter, action: e.target.value })}+ value={actionFilter}+ onChange={(e) => setActionFilter(e.target.value)}className="px-3 py-1 bg-port-bg border border-port-border rounded text-white text-sm"><option value="">All Actions</option>@@ -114,56 +92,44 @@ export default function ActivityTab() {) : (<><div className="space-y-2">- {activities.map((activity, index) => {- const agent = getAgentInfo(activity.agentId);-- return (- <div- key={`${activity.id}-${index}`}- className="p-3 bg-port-card border border-port-border rounded-lg"- >- <div className="flex items-center gap-3">- <div- className="w-8 h-8 rounded-full flex items-center justify-center text-lg"- style={{ backgroundColor: agent.avatar?.color || '#3b82f6' }}- >- {agent.avatar?.emoji || '🤖'}+ {activities.map((activity, index) => (+ <div+ key={`${activity.id}-${index}`}+ className="p-3 bg-port-card border border-port-border rounded-lg"+ >+ <div className="flex items-center gap-3">+ <div className="flex-1">+ <div className="flex items-center gap-2">+ <span className="text-lg">{getActionIcon(activity.action)}</span>+ <span className="text-gray-300">{activity.action}</span>+ <span className={`text-xs px-2 py-0.5 rounded ${getStatusStyle(activity.status)}`}>+ {activity.status}+ </span></div>- <div className="flex-1">- <div className="flex items-center gap-2">- <span className="text-white font-medium">{agent.name}</span>- <span className="text-gray-500">•</span>- <span className="text-lg">{getActionIcon(activity.action)}</span>- <span className="text-gray-300">{activity.action}</span>- <span className={`text-xs px-2 py-0.5 rounded ${getStatusStyle(activity.status)}`}>- {activity.status}- </span>- </div>- <div className="text-xs text-gray-500 mt-1">- {new Date(activity.timestamp).toLocaleString()}- {activity.scheduleId && (- <span className="ml-2">• Scheduled</span>- )}- </div>+ <div className="text-xs text-gray-500 mt-1">+ {new Date(activity.timestamp).toLocaleString()}+ {activity.scheduleId && (+ <span className="ml-2">• Scheduled</span>+ )}</div>- {activity.result && (- <div className="text-sm text-gray-400">- {typeof activity.result === 'string'- ? activity.result.slice(0, 50)- : JSON.stringify(activity.result).slice(0, 50)}- {(typeof activity.result === 'string' ? activity.result.length : JSON.stringify(activity.result).length) > 50 && '...'}- </div>- )}- {activity.error && (- <div className="text-sm text-port-error">- {activity.error.slice(0, 50)}- {activity.error.length > 50 && '...'}- </div>- )}</div>+ {activity.result && (+ <div className="text-sm text-gray-400">+ {typeof activity.result === 'string'+ ? activity.result.slice(0, 50)+ : JSON.stringify(activity.result).slice(0, 50)}+ {(typeof activity.result === 'string' ? activity.result.length : JSON.stringify(activity.result).length) > 50 && '...'}+ </div>+ )}+ {activity.error && (+ <div className="text-sm text-port-error">+ {activity.error.slice(0, 50)}+ {activity.error.length > 50 && '...'}+ </div>+ )}</div>- );- })}+ </div>+ ))}</div>{hasMore && (diff --git a/client/src/components/agents/tabs/ConfigTab.jsx b/client/src/components/agents/tabs/ConfigTab.jsxdeleted file mode 100644index d303035f47..0000000000--- a/client/src/components/agents/tabs/ConfigTab.jsx+++ /dev/null@@ -1,160 +0,0 @@-import { useState, useEffect } from 'react';-import * as api from '../../../services/api';--export default function ConfigTab() {- const [stats, setStats] = useState(null);- const [agents, setAgents] = useState([]);- const [accounts, setAccounts] = useState([]);- const [loading, setLoading] = useState(true);-- useEffect(() => {- const fetchData = async () => {- const [agentsData, accountsData, scheduleStats] = await Promise.all([- api.getAgentPersonalities(),- api.getPlatformAccounts(),- api.getScheduleStats()- ]);- setAgents(agentsData);- setAccounts(accountsData);- setStats(scheduleStats);- setLoading(false);- };- fetchData();- }, []);-- if (loading) {- return <div className="p-4 text-gray-400">Loading config...</div>;- }-- const enabledAgents = agents.filter(a => a.enabled).length;- const activeAccounts = accounts.filter(a => a.status === 'active').length;-- return (- <div className="p-4">- <h2 className="text-lg font-semibold text-white mb-4">Configuration</h2>-- {/* Overview Stats */}- <div className="grid grid-cols-4 gap-4 mb-6">- <div className="p-4 bg-port-card border border-port-border rounded-lg">- <div className="text-2xl font-bold text-white">{agents.length}</div>- <div className="text-sm text-gray-400">Total Agents</div>- <div className="text-xs text-port-success">{enabledAgents} enabled</div>- </div>- <div className="p-4 bg-port-card border border-port-border rounded-lg">- <div className="text-2xl font-bold text-white">{accounts.length}</div>- <div className="text-sm text-gray-400">Platform Accounts</div>- <div className="text-xs text-port-success">{activeAccounts} active</div>- </div>- <div className="p-4 bg-port-card border border-port-border rounded-lg">- <div className="text-2xl font-bold text-white">{stats?.total || 0}</div>- <div className="text-sm text-gray-400">Schedules</div>- <div className="text-xs text-port-success">{stats?.active || 0} running</div>- </div>- <div className="p-4 bg-port-card border border-port-border rounded-lg">- <div className="text-2xl font-bold text-white">{stats?.totalRuns || 0}</div>- <div className="text-sm text-gray-400">Total Runs</div>- <div className="text-xs text-gray-500">all time</div>- </div>- </div>-- {/* Schedule Actions Breakdown */}- {stats?.byAction && Object.keys(stats.byAction).length > 0 && (- <div className="mb-6">- <h3 className="text-md font-semibold text-white mb-3">Schedules by Action</h3>- <div className="grid grid-cols-4 gap-2">- {Object.entries(stats.byAction).map(([action, count]) => (- <div key={action} className="p-3 bg-port-card border border-port-border rounded">- <div className="text-lg font-bold text-white">{count}</div>- <div className="text-sm text-gray-400 capitalize">{action}</div>- </div>- ))}- </div>- </div>- )}-- {/* Global Settings */}- <div className="mb-6">- <h3 className="text-md font-semibold text-white mb-3">Global Settings</h3>- <div className="p-4 bg-port-card border border-port-border rounded-lg">- <p className="text-gray-400 text-sm mb-4">- Global agent settings will be available in a future update.- </p>- <div className="space-y-3 opacity-50">- <div className="flex items-center justify-between">- <span className="text-gray-300">Default Rate Limit (per day)</span>- <input- type="number"- defaultValue={50}- className="w-24 px-3 py-1 bg-port-bg border border-port-border rounded text-white text-right"- disabled- />- </div>- <div className="flex items-center justify-between">- <span className="text-gray-300">Activity Log Retention (days)</span>- <input- type="number"- defaultValue={30}- className="w-24 px-3 py-1 bg-port-bg border border-port-border rounded text-white text-right"- disabled- />- </div>- <div className="flex items-center justify-between">- <span className="text-gray-300">Enable Socket.IO Updates</span>- <label className="relative inline-flex items-center cursor-not-allowed">- <input type="checkbox" defaultChecked disabled className="sr-only peer" />- <div className="w-11 h-6 bg-port-border rounded-full peer peer-checked:bg-port-accent"></div>- </label>- </div>- </div>- </div>- </div>-- {/* Moltbook Rate Limits Info */}- <div className="mb-6">- <h3 className="text-md font-semibold text-white mb-3">Platform Rate Limits</h3>- <div className="p-4 bg-port-card border border-port-border rounded-lg">- <h4 className="text-white font-medium mb-2">📚 Moltbook</h4>- <div className="grid grid-cols-3 gap-4 text-sm">- <div>- <div className="text-gray-400">Posts</div>- <div className="text-white">1 per 30 minutes</div>- </div>- <div>- <div className="text-gray-400">Comments</div>- <div className="text-white">1 per 20 seconds, 50/day</div>- </div>- <div>- <div className="text-gray-400">Votes</div>- <div className="text-white">1 per second, 200/day</div>- </div>- </div>- </div>- </div>-- {/* Documentation Links */}- <div>- <h3 className="text-md font-semibold text-white mb-3">Documentation</h3>- <div className="p-4 bg-port-card border border-port-border rounded-lg">- <ul className="space-y-2 text-sm">- <li>- <span className="text-gray-400">• Agent Personalities:</span>{' '}- <span className="text-gray-300">Define unique AI personalities with custom tones and topics</span>- </li>- <li>- <span className="text-gray-400">• Platform Accounts:</span>{' '}- <span className="text-gray-300">Link agents to social platforms via API</span>- </li>- <li>- <span className="text-gray-400">• Automation Schedules:</span>{' '}- <span className="text-gray-300">Configure cron, interval, or random timing for actions</span>- </li>- <li>- <span className="text-gray-400">• Activity Log:</span>{' '}- <span className="text-gray-300">Monitor all agent actions with filtering</span>- </li>- </ul>- </div>- </div>- </div>- );-}diff --git a/client/src/components/agents/tabs/OverviewTab.jsx b/client/src/components/agents/tabs/OverviewTab.jsxnew file mode 100644index 0000000000..b57b3dd447--- /dev/null+++ b/client/src/components/agents/tabs/OverviewTab.jsx@@ -0,0 +1,517 @@+import { useState, useEffect, useCallback } from 'react';+import { Sparkles } from 'lucide-react';+import toast from 'react-hot-toast';+import * as api from '../../../services/api';+import { PERSONALITY_STYLES, DEFAULT_PERSONALITY, DEFAULT_AVATAR, PLATFORM_TYPES, ACCOUNT_STATUSES } from '../constants';++export default function OverviewTab({ agentId, agent, onAgentUpdate }) {+ // Personality form state+ const [formData, setFormData] = useState(null);+ const [topicsText, setTopicsText] = useState('');+ const [quirksText, setQuirksText] = useState('');++ // AI generation state+ const [providers, setProviders] = useState([]);+ const [selectedProviderId, setSelectedProviderId] = useState('');+ const [selectedModel, setSelectedModel] = useState('');+ const [generating, setGenerating] = useState(false);++ // Accounts state+ const [accounts, setAccounts] = useState([]);+ const [accountsLoading, setAccountsLoading] = useState(true);+ const [showAccountForm, setShowAccountForm] = useState(false);+ const [accountForm, setAccountForm] = useState({+ platform: 'moltbook',+ name: '',+ description: ''+ });+ const [testingId, setTestingId] = useState(null);+ const [testResult, setTestResult] = useState(null);++ // Stats state+ const [activityStats, setActivityStats] = useState(null);++ // Initialize form from agent+ useEffect(() => {+ if (!agent) return;+ setFormData({+ name: agent.name,+ description: agent.description || '',+ userId: agent.userId,+ personality: { ...DEFAULT_PERSONALITY, ...agent.personality },+ avatar: { ...DEFAULT_AVATAR, ...agent.avatar },+ enabled: agent.enabled+ });+ }, [agent]);++ // Sync text fields+ useEffect(() => {+ if (!formData) return;+ setTopicsText(formData.personality.topics.join(', '));+ setQuirksText(formData.personality.quirks.join(', '));+ }, [formData?.personality?.topics, formData?.personality?.quirks]);++ const fetchAccounts = useCallback(async () => {+ const data = await api.getPlatformAccounts(agentId);+ setAccounts(data);+ setAccountsLoading(false);+ }, [agentId]);++ const fetchProviders = useCallback(async () => {+ const data = await api.getProviders();+ setProviders((data.providers || []).filter(p => p.enabled));+ }, []);++ const fetchStats = useCallback(async () => {+ const stats = await api.getAgentActivityStats(agentId).catch(() => null);+ setActivityStats(stats);+ }, [agentId]);++ useEffect(() => {+ fetchAccounts();+ fetchProviders();+ fetchStats();+ }, [fetchAccounts, fetchProviders, fetchStats]);++ const selectedProvider = providers.find(p => p.id === selectedProviderId);+ const availableModels = selectedProvider?.models || [];++ const handleGenerate = async () => {+ setGenerating(true);+ const seedData = {+ name: formData.name.trim(),+ description: formData.description.trim(),+ personality: {+ style: formData.personality.style,+ tone: formData.personality.tone,+ topics: topicsText.split(',').map(t => t.trim()).filter(Boolean),+ quirks: quirksText.split(',').map(t => t.trim()).filter(Boolean),+ promptPrefix: formData.personality.promptPrefix.trim()+ },+ avatar: { emoji: formData.avatar.emoji, color: formData.avatar.color }+ };+ const generated = await api.generateAgentPersonality(+ seedData, selectedProviderId || null, selectedModel || null+ ).catch(() => null);+ setGenerating(false);++ if (!generated) return;++ setFormData(prev => ({+ ...prev,+ name: generated.name || prev.name,+ description: generated.description || prev.description,+ personality: {+ style: generated.personality?.style || prev.personality.style,+ tone: generated.personality?.tone || prev.personality.tone,+ topics: generated.personality?.topics || prev.personality.topics,+ quirks: generated.personality?.quirks || prev.personality.quirks,+ promptPrefix: generated.personality?.promptPrefix || prev.personality.promptPrefix+ },+ avatar: {+ emoji: generated.avatar?.emoji || prev.avatar.emoji,+ color: generated.avatar?.color || prev.avatar.color+ }+ }));+ toast.success(`Generated: ${generated.name || 'personality'}`);+ };++ const handleSave = async (e) => {+ e.preventDefault();+ const submitData = {+ ...formData,+ personality: {+ ...formData.personality,+ topics: topicsText.split(',').map(t => t.trim()).filter(Boolean),+ quirks: quirksText.split(',').map(t => t.trim()).filter(Boolean)+ }+ };+ await api.updateAgentPersonality(agentId, submitData);+ toast.success('Agent updated');+ onAgentUpdate?.();+ };++ const updatePersonality = (field, value) => {+ setFormData(prev => ({+ ...prev,+ personality: { ...prev.personality, [field]: value }+ }));+ };++ // Account handlers+ const resetAccountForm = () => {+ setAccountForm({ platform: 'moltbook', name: '', description: '' });+ setShowAccountForm(false);+ };++ const handleAccountSubmit = async (e) => {+ e.preventDefault();+ const result = await api.registerPlatformAccount(+ agentId, accountForm.platform, accountForm.name, accountForm.description+ );+ resetAccountForm();+ fetchAccounts();++ if (result.claimUrl) {+ setTestResult({+ accountId: result.id,+ success: true,+ message: 'Account registered! Visit the claim URL to activate.',+ claimUrl: result.claimUrl+ });+ }+ };++ const handleAccountDelete = async (id) => {+ await api.deletePlatformAccount(id);+ fetchAccounts();+ };++ const handleAccountTest = async (id) => {+ setTestingId(id);+ setTestResult(null);+ const result = await api.testPlatformAccount(id);+ setTestResult({ accountId: id, ...result });+ setTestingId(null);+ };++ const handleAccountClaim = async (id) => {+ await api.claimPlatformAccount(id);+ fetchAccounts();+ setTestResult(null);+ };++ if (!formData) {+ return <div className="p-4 text-gray-400">Loading...</div>;+ }++ return (+ <div className="p-4 space-y-6">+ {/* Quick Stats */}+ {activityStats && (+ <div className="grid grid-cols-3 gap-4">+ <div className="p-3 bg-port-card border border-port-border rounded-lg text-center">+ <div className="text-xl font-bold text-white">{activityStats.totalPosts || 0}</div>+ <div className="text-xs text-gray-400">Posts</div>+ </div>+ <div className="p-3 bg-port-card border border-port-border rounded-lg text-center">+ <div className="text-xl font-bold text-white">{activityStats.totalComments || 0}</div>+ <div className="text-xs text-gray-400">Comments</div>+ </div>+ <div className="p-3 bg-port-card border border-port-border rounded-lg text-center">+ <div className="text-xl font-bold text-white">{activityStats.totalVotes || 0}</div>+ <div className="text-xs text-gray-400">Votes</div>+ </div>+ </div>+ )}++ {/* Personality Section */}+ <div className="bg-port-card border border-port-border rounded-lg p-4">+ <h3 className="text-md font-semibold text-white mb-4">Personality</h3>++ {/* AI Generation */}+ <div className="mb-4 p-3 bg-port-bg border border-port-accent/30 rounded-lg">+ <div className="flex items-center gap-2 mb-3">+ <Sparkles size={16} className="text-port-accent" />+ <span className="text-sm font-medium text-white">Regenerate with AI</span>+ </div>+ <div className="flex items-end gap-3">+ <div className="flex-1">+ <label className="block text-xs text-gray-400 mb-1">Provider</label>+ <select+ value={selectedProviderId}+ onChange={(e) => { setSelectedProviderId(e.target.value); setSelectedModel(''); }}+ disabled={generating}+ className="w-full px-2 py-1.5 bg-port-card border border-port-border rounded text-white text-sm"+ >+ <option value="">Default (active)</option>+ {providers.map(p => (+ <option key={p.id} value={p.id}>{p.name}</option>+ ))}+ </select>+ </div>+ <div className="flex-1">+ <label className="block text-xs text-gray-400 mb-1">Model</label>+ <select+ value={selectedModel}+ onChange={(e) => setSelectedModel(e.target.value)}+ disabled={generating}+ className="w-full px-2 py-1.5 bg-port-card border border-port-border rounded text-white text-sm"+ >+ <option value="">Default</option>+ {availableModels.map(m => (+ <option key={m} value={m}>{m}</option>+ ))}+ </select>+ </div>+ <button+ type="button"+ onClick={handleGenerate}+ disabled={generating}+ className="px-4 py-1.5 bg-port-accent text-white rounded hover:bg-port-accent/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"+ >+ {generating ? (+ <><span className="animate-spin">⚡</span>Generating...</>+ ) : (+ <><Sparkles size={14} />Generate</>+ )}+ </button>+ </div>+ </div>++ <form onSubmit={handleSave}>+ <div className="grid grid-cols-2 gap-4 mb-4">+ <div>+ <label className="block text-sm text-gray-400 mb-1">Name</label>+ <input+ type="text"+ value={formData.name}+ onChange={(e) => setFormData({ ...formData, name: e.target.value })}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ required+ />+ </div>+ <div>+ <label className="block text-sm text-gray-400 mb-1">Style</label>+ <select+ value={formData.personality.style}+ onChange={(e) => updatePersonality('style', e.target.value)}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ >+ {PERSONALITY_STYLES.map(style => (+ <option key={style.value} value={style.value}>{style.label}</option>+ ))}+ </select>+ </div>+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Description</label>+ <textarea+ value={formData.description}+ onChange={(e) => setFormData({ ...formData, description: e.target.value })}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white h-20"+ placeholder="Brief description of this agent's purpose..."+ />+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Tone</label>+ <input+ type="text"+ value={formData.personality.tone}+ onChange={(e) => updatePersonality('tone', e.target.value)}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ placeholder="e.g., friendly but informative"+ />+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Topics (comma-separated)</label>+ <input+ type="text"+ value={topicsText}+ onChange={(e) => setTopicsText(e.target.value)}+ onBlur={() => updatePersonality('topics', topicsText.split(',').map(t => t.trim()).filter(Boolean))}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ placeholder="e.g., technology, AI, philosophy"+ />+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Quirks (comma-separated)</label>+ <input+ type="text"+ value={quirksText}+ onChange={(e) => setQuirksText(e.target.value)}+ onBlur={() => updatePersonality('quirks', quirksText.split(',').map(t => t.trim()).filter(Boolean))}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ placeholder="e.g., uses metaphors, asks follow-up questions"+ />+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Prompt Prefix</label>+ <textarea+ value={formData.personality.promptPrefix}+ onChange={(e) => updatePersonality('promptPrefix', e.target.value)}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white h-24 font-mono text-sm"+ placeholder="Custom instructions injected into AI prompts..."+ />+ </div>++ <div className="flex items-center gap-4 mb-4">+ <label className="block text-sm text-gray-400">Avatar Emoji</label>+ <input+ type="text"+ value={formData.avatar.emoji || ''}+ onChange={(e) => setFormData({ ...formData, avatar: { ...formData.avatar, emoji: e.target.value } })}+ className="w-16 px-3 py-2 bg-port-bg border border-port-border rounded text-white text-center"+ maxLength={2}+ />+ <label className="block text-sm text-gray-400">Color</label>+ <input+ type="color"+ value={formData.avatar.color || '#3b82f6'}+ onChange={(e) => setFormData({ ...formData, avatar: { ...formData.avatar, color: e.target.value } })}+ className="w-12 h-8 border border-port-border rounded cursor-pointer"+ />+ </div>++ <button+ type="submit"+ className="px-4 py-2 bg-port-success text-white rounded hover:bg-port-success/80"+ >+ Save Changes+ </button>+ </form>+ </div>++ {/* Accounts Section */}+ <div className="bg-port-card border border-port-border rounded-lg p-4">+ <div className="flex justify-between items-center mb-4">+ <h3 className="text-md font-semibold text-white">Platform Accounts</h3>+ <button+ onClick={() => setShowAccountForm(!showAccountForm)}+ className="px-3 py-1.5 text-sm bg-port-accent text-white rounded hover:bg-port-accent/80"+ >+ {showAccountForm ? 'Cancel' : '+ Link Account'}+ </button>+ </div>++ {showAccountForm && (+ <form onSubmit={handleAccountSubmit} className="mb-4 p-3 bg-port-bg border border-port-border rounded-lg">+ <div className="grid grid-cols-2 gap-4 mb-3">+ <div>+ <label className="block text-sm text-gray-400 mb-1">Platform</label>+ <select+ value={accountForm.platform}+ onChange={(e) => setAccountForm({ ...accountForm, platform: e.target.value })}+ className="w-full px-3 py-2 bg-port-card border border-port-border rounded text-white"+ >+ {PLATFORM_TYPES.map(platform => (+ <option key={platform.value} value={platform.value}>+ {platform.icon} {platform.label}+ </option>+ ))}+ </select>+ </div>+ <div>+ <label className="block text-sm text-gray-400 mb-1">Account Name</label>+ <input+ type="text"+ value={accountForm.name}+ onChange={(e) => setAccountForm({ ...accountForm, name: e.target.value })}+ className="w-full px-3 py-2 bg-port-card border border-port-border rounded text-white"+ placeholder="Display name on platform"+ required+ />+ </div>+ </div>+ <div className="mb-3">+ <label className="block text-sm text-gray-400 mb-1">Bio/Description</label>+ <textarea+ value={accountForm.description}+ onChange={(e) => setAccountForm({ ...accountForm, description: e.target.value })}+ className="w-full px-3 py-2 bg-port-card border border-port-border rounded text-white h-16"+ placeholder="Brief bio for the platform profile..."+ />+ </div>+ <div className="flex gap-2">+ <button type="submit" className="px-3 py-1.5 text-sm bg-port-success text-white rounded hover:bg-port-success/80">+ Register Account+ </button>+ <button type="button" onClick={resetAccountForm} className="px-3 py-1.5 text-sm bg-port-border text-gray-300 rounded hover:bg-port-border/80">+ Cancel+ </button>+ </div>+ </form>+ )}++ {testResult && (+ <div className={`mb-4 p-3 rounded border ${+ testResult.success+ ? 'bg-port-success/20 border-port-success/50 text-port-success'+ : 'bg-port-error/20 border-port-error/50 text-port-error'+ }`}>+ <p className="text-sm">{testResult.message}</p>+ {testResult.claimUrl && (+ <div className="mt-2">+ <a href={testResult.claimUrl} target="_blank" rel="noopener noreferrer" className="text-port-accent underline text-sm">+ {testResult.claimUrl}+ </a>+ <button+ onClick={() => handleAccountClaim(testResult.accountId)}+ className="ml-4 px-3 py-1 bg-port-accent text-white rounded text-sm"+ >+ I've claimed it+ </button>+ </div>+ )}+ </div>+ )}++ {accountsLoading ? (+ <p className="text-sm text-gray-400">Loading accounts...</p>+ ) : accounts.length === 0 ? (+ <p className="text-sm text-gray-500 text-center py-4">No platform accounts linked to this agent</p>+ ) : (+ <div className="space-y-3">+ {accounts.map(account => {+ const statusConfig = ACCOUNT_STATUSES[account.status] || ACCOUNT_STATUSES.error;+ const platform = PLATFORM_TYPES.find(p => p.value === account.platform);++ return (+ <div key={account.id} className="p-3 bg-port-bg border border-port-border rounded-lg">+ <div className="flex items-start justify-between">+ <div>+ <div className="flex items-center gap-2 mb-1">+ <span>{platform?.icon || '🔗'}</span>+ <span className="font-medium text-white">{account.credentials.username}</span>+ <span className={`text-xs px-2 py-0.5 rounded ${statusConfig.bgColor} ${statusConfig.color}`}>+ {statusConfig.label}+ </span>+ </div>+ <p className="text-xs text-gray-500">+ {platform?.label}+ {account.lastActivity && ` • Last activity: ${new Date(account.lastActivity).toLocaleString()}`}+ </p>+ {account.platformData?.claimUrl && account.status === 'pending' && (+ <a href={account.platformData.claimUrl} target="_blank" rel="noopener noreferrer" className="text-port-accent underline text-xs mt-1 inline-block">+ Claim URL+ </a>+ )}+ </div>+ <div className="flex items-center gap-2">+ <button+ onClick={() => handleAccountTest(account.id)}+ disabled={testingId === account.id}+ className="px-2 py-1 text-xs bg-port-accent/20 text-port-accent rounded hover:bg-port-accent/30 disabled:opacity-50"+ >+ {testingId === account.id ? 'Testing...' : 'Test'}+ </button>+ {account.status === 'pending' && (+ <button+ onClick={() => handleAccountClaim(account.id)}+ className="px-2 py-1 text-xs bg-port-success/20 text-port-success rounded hover:bg-port-success/30"+ >+ Claimed+ </button>+ )}+ <button+ onClick={() => handleAccountDelete(account.id)}+ className="px-2 py-1 text-xs bg-port-error/20 text-port-error rounded hover:bg-port-error/30"+ >+ Delete+ </button>+ </div>+ </div>+ </div>+ );+ })}+ </div>+ )}+ </div>+ </div>+ );+}diff --git a/client/src/components/agents/tabs/PersonalitiesTab.jsx b/client/src/components/agents/tabs/PersonalitiesTab.jsxdeleted file mode 100644index 796b75999f..0000000000--- a/client/src/components/agents/tabs/PersonalitiesTab.jsx+++ /dev/null@@ -1,448 +0,0 @@-import { useState, useEffect, useCallback } from 'react';-import { Sparkles } from 'lucide-react';-import toast from 'react-hot-toast';-import * as api from '../../../services/api';-import { PERSONALITY_STYLES, DEFAULT_PERSONALITY, DEFAULT_AVATAR } from '../constants';--export default function PersonalitiesTab({ onRefresh }) {- const [agents, setAgents] = useState([]);- const [loading, setLoading] = useState(true);- const [showForm, setShowForm] = useState(false);- const [editingAgent, setEditingAgent] = useState(null);- const [formData, setFormData] = useState({- name: '',- description: '',- userId: 'default',- personality: { ...DEFAULT_PERSONALITY },- avatar: { ...DEFAULT_AVATAR },- enabled: true- });-- // AI generation state- const [providers, setProviders] = useState([]);- const [selectedProviderId, setSelectedProviderId] = useState('');- const [selectedModel, setSelectedModel] = useState('');- const [generating, setGenerating] = useState(false);-- // Raw text state for comma-separated fields (parsed on blur)- const [topicsText, setTopicsText] = useState('');- const [quirksText, setQuirksText] = useState('');-- const fetchAgents = useCallback(async () => {- const data = await api.getAgentPersonalities();- setAgents(data);- setLoading(false);- }, []);-- const fetchProviders = useCallback(async () => {- const data = await api.getProviders();- setProviders((data.providers || []).filter(p => p.enabled));- }, []);-- useEffect(() => {- fetchAgents();- fetchProviders();- }, [fetchAgents, fetchProviders]);-- // Sync raw text fields when formData changes (edit, generate, reset)- useEffect(() => {- setTopicsText(formData.personality.topics.join(', '));- setQuirksText(formData.personality.quirks.join(', '));- }, [formData.personality.topics, formData.personality.quirks]);-- // Get available models for selected provider- const selectedProvider = providers.find(p => p.id === selectedProviderId);- const availableModels = selectedProvider?.models || [];-- const handleGenerate = async () => {- setGenerating(true);- // Send current form data as seed for AI to build upon- // Use raw text values in case user hasn't blurred the fields yet- const seedData = {- name: formData.name.trim(),- description: formData.description.trim(),- personality: {- style: formData.personality.style,- tone: formData.personality.tone,- topics: topicsText.split(',').map(t => t.trim()).filter(Boolean),- quirks: quirksText.split(',').map(t => t.trim()).filter(Boolean),- promptPrefix: formData.personality.promptPrefix.trim()- },- avatar: {- emoji: formData.avatar.emoji,- color: formData.avatar.color- }- };- const generated = await api.generateAgentPersonality(- seedData,- selectedProviderId || null,- selectedModel || null- ).catch(() => null);- setGenerating(false);-- if (!generated) return;-- // Apply generated data to form (including name if generated)- setFormData(prev => ({- ...prev,- name: generated.name || prev.name,- description: generated.description || prev.description,- personality: {- style: generated.personality?.style || prev.personality.style,- tone: generated.personality?.tone || prev.personality.tone,- topics: generated.personality?.topics || prev.personality.topics,- quirks: generated.personality?.quirks || prev.personality.quirks,- promptPrefix: generated.personality?.promptPrefix || prev.personality.promptPrefix- },- avatar: {- emoji: generated.avatar?.emoji || prev.avatar.emoji,- color: generated.avatar?.color || prev.avatar.color- }- }));-- toast.success(`Generated: ${generated.name || 'personality'}`);- };-- const resetForm = () => {- setFormData({- name: '',- description: '',- userId: 'default',- personality: { ...DEFAULT_PERSONALITY },- avatar: { ...DEFAULT_AVATAR },- enabled: true- });- setEditingAgent(null);- setShowForm(false);- };-- const handleEdit = (agent) => {- setFormData({- name: agent.name,- description: agent.description || '',- userId: agent.userId,- personality: { ...DEFAULT_PERSONALITY, ...agent.personality },- avatar: { ...DEFAULT_AVATAR, ...agent.avatar },- enabled: agent.enabled- });- setEditingAgent(agent);- setShowForm(true);- };-- const handleSubmit = async (e) => {- e.preventDefault();-- // Build clean data with parsed topics/quirks (in case user hasn't blurred)- const submitData = {- ...formData,- personality: {- ...formData.personality,- topics: topicsText.split(',').map(t => t.trim()).filter(Boolean),- quirks: quirksText.split(',').map(t => t.trim()).filter(Boolean)- }- };-- if (editingAgent) {- await api.updateAgentPersonality(editingAgent.id, submitData);- } else {- await api.createAgentPersonality(submitData);- }-- resetForm();- fetchAgents();- onRefresh?.();- };-- const handleDelete = async (id) => {- await api.deleteAgentPersonality(id);- fetchAgents();- onRefresh?.();- };-- const handleToggle = async (id, enabled) => {- await api.toggleAgentPersonality(id, enabled);- fetchAgents();- };-- const updatePersonality = (field, value) => {- setFormData(prev => ({- ...prev,- personality: { ...prev.personality, [field]: value }- }));- };-- if (loading) {- return <div className="p-4 text-gray-400">Loading agents...</div>;- }-- return (- <div className="p-4">- <div className="flex justify-between items-center mb-4">- <h2 className="text-lg font-semibold text-white">Agent Personalities</h2>- <button- onClick={() => setShowForm(!showForm)}- className="px-4 py-2 bg-port-accent text-white rounded hover:bg-port-accent/80"- >- {showForm ? 'Cancel' : '+ New Agent'}- </button>- </div>-- {showForm && (- <form onSubmit={handleSubmit} className="mb-6 p-4 bg-port-card border border-port-border rounded-lg">- <h3 className="text-md font-semibold text-white mb-4">- {editingAgent ? 'Edit Agent' : 'Create New Agent'}- </h3>-- {/* AI Generation Section - at top */}- {!editingAgent && (- <div className="mb-4 p-3 bg-port-bg border border-port-accent/30 rounded-lg">- <div className="flex items-center gap-2 mb-3">- <Sparkles size={16} className="text-port-accent" />- <span className="text-sm font-medium text-white">Generate with AI</span>- </div>- <div className="flex items-end gap-3">- <div className="flex-1">- <label className="block text-xs text-gray-400 mb-1">Provider</label>- <select- value={selectedProviderId}- onChange={(e) => {- setSelectedProviderId(e.target.value);- setSelectedModel('');- }}- disabled={generating}- className="w-full px-2 py-1.5 bg-port-card border border-port-border rounded text-white text-sm"- >- <option value="">Default (active)</option>- {providers.map(p => (- <option key={p.id} value={p.id}>{p.name}</option>- ))}- </select>- </div>- <div className="flex-1">- <label className="block text-xs text-gray-400 mb-1">Model</label>- <select- value={selectedModel}- onChange={(e) => setSelectedModel(e.target.value)}- disabled={generating}- className="w-full px-2 py-1.5 bg-port-card border border-port-border rounded text-white text-sm"- >- <option value="">Default</option>- {availableModels.map(m => (- <option key={m} value={m}>{m}</option>- ))}- </select>- </div>- <button- type="button"- onClick={handleGenerate}- disabled={generating}- className="px-4 py-1.5 bg-port-accent text-white rounded hover:bg-port-accent/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"- >- {generating ? (- <>- <span className="animate-spin">⚡</span>- Generating...- </>- ) : (- <>- <Sparkles size={14} />- Generate- </>- )}- </button>- </div>- <p className="text-xs text-gray-500 mt-2">- Generate a complete personality including name, style, topics, and avatar- </p>- </div>- )}-- <div className="grid grid-cols-2 gap-4 mb-4">- <div>- <label className="block text-sm text-gray-400 mb-1">Name</label>- <input- type="text"- value={formData.name}- onChange={(e) => setFormData({ ...formData, name: e.target.value })}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"- required- />- </div>- <div>- <label className="block text-sm text-gray-400 mb-1">Style</label>- <select- value={formData.personality.style}- onChange={(e) => updatePersonality('style', e.target.value)}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"- >- {PERSONALITY_STYLES.map(style => (- <option key={style.value} value={style.value}>{style.label}</option>- ))}- </select>- </div>- </div>-- <div className="mb-4">- <label className="block text-sm text-gray-400 mb-1">Description</label>- <textarea- value={formData.description}- onChange={(e) => setFormData({ ...formData, description: e.target.value })}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white h-20"- placeholder="Brief description of this agent's purpose..."- />- </div>-- <div className="mb-4">- <label className="block text-sm text-gray-400 mb-1">Tone</label>- <input- type="text"- value={formData.personality.tone}- onChange={(e) => updatePersonality('tone', e.target.value)}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"- placeholder="e.g., friendly but informative"- />- </div>-- <div className="mb-4">- <label className="block text-sm text-gray-400 mb-1">Topics (comma-separated)</label>- <input- type="text"- value={topicsText}- onChange={(e) => setTopicsText(e.target.value)}- onBlur={() => updatePersonality('topics', topicsText.split(',').map(t => t.trim()).filter(Boolean))}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"- placeholder="e.g., technology, AI, philosophy"- />- </div>-- <div className="mb-4">- <label className="block text-sm text-gray-400 mb-1">Quirks (comma-separated)</label>- <input- type="text"- value={quirksText}- onChange={(e) => setQuirksText(e.target.value)}- onBlur={() => updatePersonality('quirks', quirksText.split(',').map(t => t.trim()).filter(Boolean))}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"- placeholder="e.g., uses metaphors, asks follow-up questions"- />- </div>-- <div className="mb-4">- <label className="block text-sm text-gray-400 mb-1">Prompt Prefix</label>- <textarea- value={formData.personality.promptPrefix}- onChange={(e) => updatePersonality('promptPrefix', e.target.value)}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white h-24 font-mono text-sm"- placeholder="Custom instructions injected into AI prompts..."- />- </div>-- <div className="flex items-center gap-4 mb-4">- <label className="block text-sm text-gray-400">Avatar Emoji</label>- <input- type="text"- value={formData.avatar.emoji || ''}- onChange={(e) => setFormData({ ...formData, avatar: { ...formData.avatar, emoji: e.target.value } })}- className="w-16 px-3 py-2 bg-port-bg border border-port-border rounded text-white text-center"- maxLength={2}- />- <label className="block text-sm text-gray-400">Color</label>- <input- type="color"- value={formData.avatar.color || '#3b82f6'}- onChange={(e) => setFormData({ ...formData, avatar: { ...formData.avatar, color: e.target.value } })}- className="w-12 h-8 border border-port-border rounded cursor-pointer"- />- </div>-- <div className="flex gap-2">- <button- type="submit"- className="px-4 py-2 bg-port-success text-white rounded hover:bg-port-success/80"- >- {editingAgent ? 'Update Agent' : 'Create Agent'}- </button>- <button- type="button"- onClick={resetForm}- className="px-4 py-2 bg-port-border text-gray-300 rounded hover:bg-port-border/80"- >- Cancel- </button>- </div>- </form>- )}-- {agents.length === 0 ? (- <div className="text-center py-8 text-gray-400">- <p className="text-lg mb-2">No agents yet</p>- <p className="text-sm">Create your first AI agent to get started</p>- </div>- ) : (- <div className="grid gap-4">- {agents.map(agent => (- <div- key={agent.id}- className={`p-4 bg-port-card border rounded-lg ${agent.enabled ? 'border-port-border' : 'border-port-border/50 opacity-60'}`}- >- <div className="flex items-start justify-between">- <div className="flex items-center gap-3">- <div- className="w-12 h-12 rounded-full flex items-center justify-center text-2xl"- style={{ backgroundColor: agent.avatar?.color || '#3b82f6' }}- >- {agent.avatar?.emoji || '🤖'}- </div>- <div>- <h3 className="font-semibold text-white">{agent.name}</h3>- <p className="text-sm text-gray-400">{agent.description || 'No description'}</p>- <div className="flex gap-2 mt-1">- <span className="text-xs px-2 py-0.5 bg-port-accent/20 text-port-accent rounded">- {PERSONALITY_STYLES.find(s => s.value === agent.personality?.style)?.label || agent.personality?.style}- </span>- {agent.personality?.topics?.slice(0, 3).map(topic => (- <span key={topic} className="text-xs px-2 py-0.5 bg-port-border text-gray-300 rounded">- {topic}- </span>- ))}- </div>- </div>- </div>- <div className="flex items-center gap-2">- <button- onClick={() => handleToggle(agent.id, !agent.enabled)}- className={`px-3 py-1 text-xs rounded ${- agent.enabled- ? 'bg-port-success/20 text-port-success'- : 'bg-port-border text-gray-400'- }`}- >- {agent.enabled ? 'Enabled' : 'Disabled'}- </button>- <button- onClick={() => handleEdit(agent)}- className="px-3 py-1 text-xs bg-port-border text-gray-300 rounded hover:bg-port-border/80"- >- Edit- </button>- <button- onClick={() => handleDelete(agent.id)}- className="px-3 py-1 text-xs bg-port-error/20 text-port-error rounded hover:bg-port-error/30"- >- Delete- </button>- </div>- </div>- {agent.personality?.promptPrefix && (- <div className="mt-3 p-2 bg-port-bg rounded text-xs text-gray-400 font-mono">- {agent.personality.promptPrefix.slice(0, 200)}- {agent.personality.promptPrefix.length > 200 && '...'}- </div>- )}- </div>- ))}- </div>- )}- </div>- );-}diff --git a/client/src/components/agents/tabs/PublishedTab.jsx b/client/src/components/agents/tabs/PublishedTab.jsxnew file mode 100644index 0000000000..70f7d9d59c--- /dev/null+++ b/client/src/components/agents/tabs/PublishedTab.jsx@@ -0,0 +1,245 @@+import { useState, useEffect, useCallback } from 'react';+import * as api from '../../../services/api';++const formatRelativeTime = (dateStr) => {+ const diff = Date.now() - new Date(dateStr).getTime();+ const mins = Math.floor(diff / 60000);+ if (mins < 1) return 'just now';+ if (mins < 60) return `${mins}m ago`;+ const hrs = Math.floor(mins / 60);+ if (hrs < 24) return `${hrs}h ago`;+ const days = Math.floor(hrs / 24);+ return `${days}d ago`;+};++export default function PublishedTab({ agentId }) {+ const [accounts, setAccounts] = useState([]);+ const [selectedAccountId, setSelectedAccountId] = useState('');+ const [published, setPublished] = useState({ posts: [], comments: [] });+ const [publishedLoading, setPublishedLoading] = useState(false);+ const [publishedDays, setPublishedDays] = useState(7);+ const [loading, setLoading] = useState(true);++ const fetchAccounts = useCallback(async () => {+ const data = await api.getPlatformAccounts(agentId);+ const active = data.filter(a => a.status === 'active');+ setAccounts(active);+ // Auto-select first account+ if (active.length > 0 && !selectedAccountId) {+ setSelectedAccountId(active[0].id);+ }+ setLoading(false);+ }, [agentId]);++ useEffect(() => {+ fetchAccounts();+ }, [fetchAccounts]);++ const loadPublished = useCallback(async () => {+ if (!agentId || !selectedAccountId) {+ setPublished({ posts: [], comments: [] });+ return;+ }+ setPublishedLoading(true);+ const data = await api.getAgentPublished(agentId, selectedAccountId, publishedDays);+ setPublished(data);+ setPublishedLoading(false);+ }, [agentId, selectedAccountId, publishedDays]);++ useEffect(() => {+ loadPublished();+ }, [loadPublished]);++ if (loading) {+ return <div className="p-4 text-gray-400">Loading...</div>;+ }++ return (+ <div className="p-4">+ {/* Header */}+ <div className="flex flex-wrap items-end gap-4 mb-6 p-4 bg-port-card border border-port-border rounded-lg">+ <div>+ <label className="block text-sm text-gray-400 mb-1">Account</label>+ <select+ value={selectedAccountId}+ onChange={(e) => setSelectedAccountId(e.target.value)}+ className="px-3 py-2 bg-port-bg border border-port-border rounded text-white min-w-[200px]"+ >+ <option value="">Select account...</option>+ {accounts.map(account => (+ <option key={account.id} value={account.id}>+ {account.credentials.username}+ </option>+ ))}+ </select>+ </div>+ <div className="flex items-center gap-2 ml-auto">+ <select+ value={publishedDays}+ onChange={(e) => setPublishedDays(parseInt(e.target.value, 10))}+ className="px-2 py-1 text-sm bg-port-bg border border-port-border rounded text-white"+ >+ <option value={7}>7 days</option>+ <option value={14}>14 days</option>+ <option value={30}>30 days</option>+ </select>+ <button+ onClick={loadPublished}+ disabled={publishedLoading}+ className="px-3 py-1 text-sm bg-port-accent/20 text-port-accent rounded hover:bg-port-accent/30 disabled:opacity-50"+ >+ {publishedLoading ? 'Loading...' : 'Refresh'}+ </button>+ </div>+ </div>++ {!selectedAccountId && (+ <div className="text-center py-12 text-gray-400">+ <p className="text-lg mb-2">Select an account to view published content</p>+ </div>+ )}++ {selectedAccountId && (+ <div className="bg-port-card border border-port-border rounded-lg p-4">+ <div className="flex items-center gap-3 mb-4">+ <h3 className="font-semibold text-white">Published Content</h3>+ {published.posts.length > 0 && (+ <span className="text-xs px-2 py-0.5 rounded bg-port-accent/20 text-port-accent">+ {published.posts.length} post{published.posts.length !== 1 ? 's' : ''}+ </span>+ )}+ {published.comments.length > 0 && (+ <span className="text-xs px-2 py-0.5 rounded bg-port-success/20 text-port-success">+ {published.comments.length} comment{published.comments.length !== 1 ? 's' : ''}+ </span>+ )}+ </div>++ {publishedLoading && published.posts.length === 0 && published.comments.length === 0 && (+ <p className="text-sm text-gray-500 text-center py-4">Loading published content...</p>+ )}++ {/* Posts Table */}+ {published.posts.length > 0 && (+ <div className="mb-4">+ <h4 className="text-sm font-medium text-gray-400 mb-2">Posts</h4>+ <div className="overflow-x-auto">+ <table className="w-full text-sm">+ <thead>+ <tr className="text-left text-gray-500 border-b border-port-border">+ <th className="pb-2 pr-4">Title</th>+ <th className="pb-2 pr-4">Submolt</th>+ <th className="pb-2 pr-4 text-right">Score</th>+ <th className="pb-2 pr-4 text-right">Comments</th>+ <th className="pb-2 pr-4">Published</th>+ <th className="pb-2 w-8"></th>+ </tr>+ </thead>+ <tbody>+ {published.posts.map(post => (+ <tr key={post.postId} className="border-b border-port-border/50 hover:bg-port-bg/50">+ <td className="py-2 pr-4 max-w-[250px]">+ <span className="text-white truncate block" title={post.title}>+ {post.title}+ </span>+ </td>+ <td className="py-2 pr-4">+ <span className="text-port-accent text-xs">/{post.submolt}</span>+ </td>+ <td className="py-2 pr-4 text-right">+ {post.score !== null ? (+ <span className={post.score > 0 ? 'text-port-success' : 'text-gray-500'}>+ {post.score}+ </span>+ ) : (+ <span className="text-gray-600">-</span>+ )}+ </td>+ <td className="py-2 pr-4 text-right text-gray-400">+ {post.commentCount ?? '-'}+ </td>+ <td className="py-2 pr-4 text-gray-500 whitespace-nowrap" title={new Date(post.publishedAt).toLocaleString()}>+ {formatRelativeTime(post.publishedAt)}+ </td>+ <td className="py-2">+ <a+ href={post.url}+ target="_blank"+ rel="noopener noreferrer"+ className="text-port-accent hover:text-port-accent/80"+ title="Open on Moltbook"+ >+ ↗+ </a>+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </div>+ </div>+ )}++ {/* Comments Table */}+ {published.comments.length > 0 && (+ <div>+ <h4 className="text-sm font-medium text-gray-400 mb-2">Comments</h4>+ <div className="overflow-x-auto">+ <table className="w-full text-sm">+ <thead>+ <tr className="text-left text-gray-500 border-b border-port-border">+ <th className="pb-2 pr-4">Post</th>+ <th className="pb-2 pr-4">Type</th>+ <th className="pb-2 pr-4">Published</th>+ <th className="pb-2 w-8"></th>+ </tr>+ </thead>+ <tbody>+ {published.comments.map(comment => (+ <tr key={comment.commentId} className="border-b border-port-border/50 hover:bg-port-bg/50">+ <td className="py-2 pr-4 max-w-[350px]">+ <span className="text-white truncate block" title={comment.postTitle}>+ {comment.postTitle}+ </span>+ </td>+ <td className="py-2 pr-4">+ <span className={`text-xs px-1.5 py-0.5 rounded ${+ comment.isReply+ ? 'bg-purple-500/20 text-purple-400'+ : 'bg-port-accent/20 text-port-accent'+ }`}>+ {comment.isReply ? 'reply' : 'comment'}+ </span>+ </td>+ <td className="py-2 pr-4 text-gray-500 whitespace-nowrap" title={new Date(comment.publishedAt).toLocaleString()}>+ {formatRelativeTime(comment.publishedAt)}+ </td>+ <td className="py-2">+ <a+ href={comment.url}+ target="_blank"+ rel="noopener noreferrer"+ className="text-port-accent hover:text-port-accent/80"+ title="Open on Moltbook"+ >+ ↗+ </a>+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </div>+ </div>+ )}++ {!publishedLoading && published.posts.length === 0 && published.comments.length === 0 && (+ <p className="text-sm text-gray-500 text-center py-4">+ No published content in the last {publishedDays} days+ </p>+ )}+ </div>+ )}+ </div>+ );+}diff --git a/client/src/components/agents/tabs/SchedulesTab.jsx b/client/src/components/agents/tabs/SchedulesTab.jsxindex 176f099159..f91e66270e 100644--- a/client/src/components/agents/tabs/SchedulesTab.jsx+++ b/client/src/components/agents/tabs/SchedulesTab.jsx@@ -2,15 +2,14 @@ import { useState, useEffect, useCallback } from 'react';import * as api from '../../../services/api';import { ACTION_TYPES, SCHEDULE_TYPES, CRON_PRESETS, INTERVAL_PRESETS } from '../constants';-export default function SchedulesTab({ onRefresh }) {+export default function SchedulesTab({ agentId }) {const [schedules, setSchedules] = useState([]);- const [agents, setAgents] = useState([]);const [accounts, setAccounts] = useState([]);const [stats, setStats] = useState(null);const [loading, setLoading] = useState(true);const [showForm, setShowForm] = useState(false);const [formData, setFormData] = useState({- agentId: '',+ agentId: agentId,accountId: '',action: { type: 'heartbeat', params: {} },schedule: { type: 'interval', intervalMs: 4 * 60 * 60 * 1000 },@@ -20,18 +19,16 @@ export default function SchedulesTab({ onRefresh }) {const [runningId, setRunningId] = useState(null);const fetchData = useCallback(async () => {- const [schedulesData, agentsData, accountsData, statsData] = await Promise.all([- api.getAutomationSchedules(),- api.getAgentPersonalities(),- api.getPlatformAccounts(),+ const [schedulesData, accountsData, statsData] = await Promise.all([+ api.getAutomationSchedules(agentId),+ api.getPlatformAccounts(agentId),api.getScheduleStats()]);setSchedules(schedulesData);- setAgents(agentsData);setAccounts(accountsData);setStats(statsData);setLoading(false);- }, []);+ }, [agentId]);useEffect(() => {fetchData();@@ -39,7 +36,7 @@ export default function SchedulesTab({ onRefresh }) {const resetForm = () => {setFormData({- agentId: '',+ agentId: agentId,accountId: '',action: { type: 'heartbeat', params: {} },schedule: { type: 'interval', intervalMs: 4 * 60 * 60 * 1000 },@@ -49,14 +46,6 @@ export default function SchedulesTab({ onRefresh }) {setShowForm(false);};- const handleAgentChange = (agentId) => {- setFormData(prev => ({- ...prev,- agentId,- accountId: '' // Reset account when agent changes- }));- };-const handleScheduleTypeChange = (type) => {const scheduleDefaults = {cron: { type: 'cron', cron: '0 */4 * * *' },@@ -74,13 +63,11 @@ export default function SchedulesTab({ onRefresh }) {await api.createAutomationSchedule(formData);resetForm();fetchData();- onRefresh?.();};const handleDelete = async (id) => {await api.deleteAutomationSchedule(id);fetchData();- onRefresh?.();};const handleToggle = async (id, enabled) => {@@ -95,17 +82,12 @@ export default function SchedulesTab({ onRefresh }) {fetchData();};- const getAgentName = (agentId) => {- const agent = agents.find(a => a.id === agentId);- return agent?.name || 'Unknown';- };-const getAccountName = (accountId) => {const account = accounts.find(a => a.id === accountId);return account?.credentials?.username || 'Unknown';};- const filteredAccounts = accounts.filter(a => a.agentId === formData.agentId);+ const filteredAccounts = accounts.filter(a => a.status === 'active');const formatSchedule = (schedule) => {if (schedule.type === 'cron') {@@ -135,20 +117,20 @@ export default function SchedulesTab({ onRefresh }) {<h2 className="text-lg font-semibold text-white">Automation Schedules</h2>{stats && (<p className="text-sm text-gray-400">- {stats.enabled} enabled / {stats.total} total • {stats.totalRuns} runs+ {schedules.filter(s => s.enabled).length} enabled / {schedules.length} total</p>)}</div><buttononClick={() => setShowForm(!showForm)}className="px-4 py-2 bg-port-accent text-white rounded hover:bg-port-accent/80"- disabled={accounts.filter(a => a.status === 'active').length === 0}+ disabled={filteredAccounts.length === 0}>{showForm ? 'Cancel' : '+ New Schedule'}</button></div>- {accounts.filter(a => a.status === 'active').length === 0 && (+ {filteredAccounts.length === 0 && (<div className="mb-4 p-4 bg-port-warning/20 border border-port-warning/50 rounded text-port-warning">You need at least one active platform account to create schedules.</div>@@ -159,22 +141,6 @@ export default function SchedulesTab({ onRefresh }) {<h3 className="text-md font-semibold text-white mb-4">Create Schedule</h3><div className="grid grid-cols-2 gap-4 mb-4">- <div>- <label className="block text-sm text-gray-400 mb-1">Agent</label>- <select- value={formData.agentId}- onChange={(e) => handleAgentChange(e.target.value)}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"- required- >- <option value="">Select agent...</option>- {agents.map(agent => (- <option key={agent.id} value={agent.id}>- {agent.avatar?.emoji} {agent.name}- </option>- ))}- </select>- </div><div><label className="block text-sm text-gray-400 mb-1">Account</label><select@@ -182,19 +148,15 @@ export default function SchedulesTab({ onRefresh }) {onChange={(e) => setFormData({ ...formData, accountId: e.target.value })}className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"required- disabled={!formData.agentId}><option value="">Select account...</option>- {filteredAccounts.filter(a => a.status === 'active').map(account => (+ {filteredAccounts.map(account => (<option key={account.id} value={account.id}>{account.credentials.username}</option>))}</select></div>- </div>-- <div className="grid grid-cols-2 gap-4 mb-4"><div><label className="block text-sm text-gray-400 mb-1">Action Type</label><select@@ -212,20 +174,21 @@ export default function SchedulesTab({ onRefresh }) {{ACTION_TYPES.find(a => a.value === formData.action.type)?.description}</p></div>- <div>- <label className="block text-sm text-gray-400 mb-1">Schedule Type</label>- <select- value={formData.schedule.type}- onChange={(e) => handleScheduleTypeChange(e.target.value)}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"- >- {SCHEDULE_TYPES.map(type => (- <option key={type.value} value={type.value}>- {type.label}- </option>- ))}- </select>- </div>+ </div>++ <div className="mb-4">+ <label className="block text-sm text-gray-400 mb-1">Schedule Type</label>+ <select+ value={formData.schedule.type}+ onChange={(e) => handleScheduleTypeChange(e.target.value)}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white"+ >+ {SCHEDULE_TYPES.map(type => (+ <option key={type.value} value={type.value}>+ {type.label}+ </option>+ ))}+ </select></div>{formData.schedule.type === 'cron' && (@@ -366,7 +329,7 @@ export default function SchedulesTab({ onRefresh }) {)}</div><p className="text-sm text-gray-400">- {getAgentName(schedule.agentId)} → {getAccountName(schedule.accountId)}+ {getAccountName(schedule.accountId)}</p><p className="text-sm text-gray-500 mt-1">{formatSchedule(schedule.schedule)} • Max {schedule.rateLimit?.maxPerDay || '∞'}/daydiff --git a/client/src/components/agents/tabs/ToolsTab.jsx b/client/src/components/agents/tabs/ToolsTab.jsxindex b97be6b410..53a87e683b 100644--- a/client/src/components/agents/tabs/ToolsTab.jsx+++ b/client/src/components/agents/tabs/ToolsTab.jsx@@ -2,10 +2,8 @@ import { useState, useEffect, useCallback } from 'react';import toast from 'react-hot-toast';import * as api from '../../../services/api';-export default function ToolsTab() {- const [agents, setAgents] = useState([]);+export default function ToolsTab({ agentId }) {const [accounts, setAccounts] = useState([]);- const [selectedAgentId, setSelectedAgentId] = useState('');const [selectedAccountId, setSelectedAccountId] = useState('');const [rateLimits, setRateLimits] = useState(null);const [loading, setLoading] = useState(true);@@ -37,27 +35,18 @@ export default function ToolsTab() {// Drafts stateconst [drafts, setDrafts] = useState([]);- const [draftsLoading, setDraftsLoading] = useState(false);const [activeDraftId, setActiveDraftId] = useState(null);const fetchInitial = useCallback(async () => {- const [agentsData, accountsData] = await Promise.all([- api.getAgentPersonalities(),- api.getPlatformAccounts()- ]);- setAgents(agentsData);- setAccounts(accountsData);+ const accountsData = await api.getPlatformAccounts(agentId);+ setAccounts(accountsData.filter(a => a.status === 'active'));setLoading(false);- }, []);+ }, [agentId]);useEffect(() => {fetchInitial();}, [fetchInitial]);- const activeAccounts = accounts.filter(a =>- a.agentId === selectedAgentId && a.status === 'active'- );-// Load rate limits + submolts when account changesuseEffect(() => {if (!selectedAccountId) {@@ -71,33 +60,16 @@ export default function ToolsTab() {}).catch(() => {});}, [selectedAccountId]);- const loadDrafts = useCallback(async (agentId) => {- if (!agentId) {- setDrafts([]);- return;- }- setDraftsLoading(true);+ const loadDrafts = useCallback(async () => {+ if (!agentId) return;const data = await api.getAgentDrafts(agentId);setDrafts(data);- setDraftsLoading(false);- }, []);+ }, [agentId]);- // Load drafts when agent changes+ // Load drafts on mountuseEffect(() => {- loadDrafts(selectedAgentId);- }, [selectedAgentId, loadDrafts]);-- const handleAgentChange = (agentId) => {- setSelectedAgentId(agentId);- setSelectedAccountId('');- setFeedPosts([]);- setSelectedPost(null);- setPostTitle('');- setPostContent('');- setCommentContent('');- setEngageResult(null);- setActiveDraftId(null);- };+ loadDrafts();+ }, [loadDrafts]);const handleBrowseFeed = async () => {if (!selectedAccountId) return;@@ -108,9 +80,9 @@ export default function ToolsTab() {};const handleFindRelevant = async () => {- if (!selectedAgentId || !selectedAccountId) return;+ if (!agentId || !selectedAccountId) return;setFeedLoading(true);- const posts = await api.getAgentRelevantPosts(selectedAgentId, selectedAccountId, 10);+ const posts = await api.getAgentRelevantPosts(agentId, selectedAccountId, 10);setFeedPosts(posts);setFeedLoading(false);};@@ -124,10 +96,7 @@ export default function ToolsTab() {};const handleUpvote = async (postId) => {- await api.publishAgentComment(selectedAgentId, selectedAccountId, postId, '').catch(() => {- // Use the moltbook client directly through engage with 0 comments- });- // Simplified: just upvote via a quick engage+ await api.publishAgentComment(agentId, selectedAccountId, postId, '').catch(() => {});toast.success('Upvoted');if (selectedAccountId) {api.getAgentRateLimits(selectedAccountId).then(setRateLimits).catch(() => {});@@ -136,16 +105,15 @@ export default function ToolsTab() {// Post generation (auto-saves as draft)const handleGeneratePost = async () => {- if (!selectedAgentId || !selectedAccountId) return;+ if (!agentId || !selectedAccountId) return;setGenerating(true);- const generated = await api.generateAgentPost(selectedAgentId, selectedAccountId, selectedSubmolt);+ const generated = await api.generateAgentPost(agentId, selectedAccountId, selectedSubmolt);setPostTitle(generated.title);setPostContent(generated.content);setGenerating(false);- // Auto-save as draftconst draft = await api.createAgentDraft({- agentId: selectedAgentId,+ agentId,type: 'post',title: generated.title,content: generated.content,@@ -153,20 +121,19 @@ export default function ToolsTab() {accountId: selectedAccountId});setActiveDraftId(draft.id);- loadDrafts(selectedAgentId);+ loadDrafts();toast.success('Post generated and saved as draft');};const handlePublishPost = async () => {if (!postTitle || !postContent) return;setPublishing(true);- await api.publishAgentPost(selectedAgentId, selectedAccountId, selectedSubmolt, postTitle, postContent);+ await api.publishAgentPost(agentId, selectedAccountId, selectedSubmolt, postTitle, postContent);- // Delete the draft after publishingif (activeDraftId) {- await api.deleteAgentDraft(selectedAgentId, activeDraftId).catch(() => {});+ await api.deleteAgentDraft(agentId, activeDraftId).catch(() => {});setActiveDraftId(null);- loadDrafts(selectedAgentId);+ loadDrafts();}setPostTitle('');@@ -181,14 +148,13 @@ export default function ToolsTab() {if (!selectedPost) return;setGeneratingComment(true);const generated = await api.generateAgentComment(- selectedAgentId, selectedAccountId, selectedPost.id, replyToId || undefined+ agentId, selectedAccountId, selectedPost.id, replyToId || undefined);setCommentContent(generated.content);setGeneratingComment(false);- // Auto-save as draftconst draft = await api.createAgentDraft({- agentId: selectedAgentId,+ agentId,type: 'comment',content: generated.content,postId: selectedPost.id,@@ -197,7 +163,7 @@ export default function ToolsTab() {accountId: selectedAccountId});setActiveDraftId(draft.id);- loadDrafts(selectedAgentId);+ loadDrafts();toast.success('Comment generated and saved as draft');};@@ -205,31 +171,29 @@ export default function ToolsTab() {if (!selectedPost || !commentContent) return;setPublishingComment(true);await api.publishAgentComment(- selectedAgentId, selectedAccountId, selectedPost.id, commentContent, replyToId || undefined+ agentId, selectedAccountId, selectedPost.id, commentContent, replyToId || undefined);- // Delete the draft after publishingif (activeDraftId) {- await api.deleteAgentDraft(selectedAgentId, activeDraftId).catch(() => {});+ await api.deleteAgentDraft(agentId, activeDraftId).catch(() => {});setActiveDraftId(null);- loadDrafts(selectedAgentId);+ loadDrafts();}setCommentContent('');setReplyToId(null);setPublishingComment(false);toast.success('Comment published');- // Refresh post commentshandleViewPost(selectedPost);api.getAgentRateLimits(selectedAccountId).then(setRateLimits).catch(() => {});};// Engageconst handleEngage = async () => {- if (!selectedAgentId || !selectedAccountId) return;+ if (!agentId || !selectedAccountId) return;setEngaging(true);setEngageResult(null);- const result = await api.engageAgent(selectedAgentId, selectedAccountId, 1, 3);+ const result = await api.engageAgent(agentId, selectedAccountId, 1, 3);setEngageResult(result);setEngaging(false);toast.success(`Engaged: ${result.votes?.length || 0} votes, ${result.comments?.length || 0} comments`);@@ -248,7 +212,6 @@ export default function ToolsTab() {} else {setCommentContent(draft.content || '');setReplyToId(draft.parentId || null);- // If we have a postId, load the post for contextif (draft.postId && draft.accountId) {setSelectedAccountId(draft.accountId);api.getAgentPost(draft.accountId, draft.postId).then(details => {@@ -261,11 +224,9 @@ export default function ToolsTab() {};const handleDeleteDraft = async (draftId) => {- await api.deleteAgentDraft(selectedAgentId, draftId);- if (activeDraftId === draftId) {- setActiveDraftId(null);- }- loadDrafts(selectedAgentId);+ await api.deleteAgentDraft(agentId, draftId);+ if (activeDraftId === draftId) setActiveDraftId(null);+ loadDrafts();toast.success('Draft deleted');};@@ -273,37 +234,21 @@ export default function ToolsTab() {return <div className="p-4 text-gray-400">Loading tools...</div>;}- const ready = selectedAgentId && selectedAccountId;+ const ready = !!selectedAccountId;return (<div className="p-4">- {/* Header: Agent + Account Selection + Rate Limits */}+ {/* Header: Account Selection + Rate Limits */}<div className="flex flex-wrap items-end gap-4 mb-6 p-4 bg-port-card border border-port-border rounded-lg">- <div>- <label className="block text-sm text-gray-400 mb-1">Agent</label>- <select- value={selectedAgentId}- onChange={(e) => handleAgentChange(e.target.value)}- className="px-3 py-2 bg-port-bg border border-port-border rounded text-white min-w-[200px]"- >- <option value="">Select agent...</option>- {agents.map(agent => (- <option key={agent.id} value={agent.id}>- {agent.avatar?.emoji} {agent.name}- </option>- ))}- </select>- </div><div><label className="block text-sm text-gray-400 mb-1">Account</label><selectvalue={selectedAccountId}onChange={(e) => setSelectedAccountId(e.target.value)}className="px-3 py-2 bg-port-bg border border-port-border rounded text-white min-w-[200px]"- disabled={!selectedAgentId}><option value="">Select account...</option>- {activeAccounts.map(account => (+ {accounts.map(account => (<option key={account.id} value={account.id}>{account.credentials.username}</option>@@ -331,12 +276,12 @@ export default function ToolsTab() {{!ready && (<div className="text-center py-12 text-gray-400">- <p className="text-lg mb-2">Select an agent and account to get started</p>- <p className="text-sm">Use the dropdowns above to choose an agent with an active Moltbook account</p>+ <p className="text-lg mb-2">Select an account to get started</p>+ <p className="text-sm">Use the dropdown above to choose an active Moltbook account</p></div>)}- {ready && (+ {ready && (<><div className="grid grid-cols-1 lg:grid-cols-2 gap-6">{/* Left Column: Feed + Engage */}<div className="space-y-4">@@ -598,13 +543,11 @@ export default function ToolsTab() {{postComments.length} comments</p>- {/* Post content preview */}<div className="text-sm text-gray-400 bg-port-bg p-3 rounded mb-3 max-h-32 overflow-y-auto">{selectedPost.content?.substring(0, 500)}{selectedPost.content?.length > 500 && '...'}</div>- {/* Existing comments */}{postComments.length > 0 && (<div className="space-y-2 mb-3 max-h-48 overflow-y-auto">{postComments.slice(0, 10).map(comment => (@@ -672,7 +615,7 @@ export default function ToolsTab() {)}</div></div>- )}+ </>)}</div>);}diff --git a/client/src/pages/Agents.jsx b/client/src/pages/Agents.jsxindex 2afef8fb0f..b6ce233529 100644--- a/client/src/pages/Agents.jsx+++ b/client/src/pages/Agents.jsx@@ -1,127 +1,20 @@-import { useState, useEffect, useCallback } from 'react';-import { useParams, useNavigate } from 'react-router-dom';-import * as api from '../services/api';-import {- TABS,- PersonalitiesTab,- AccountsTab,- SchedulesTab,- ToolsTab,- ActivityTab,- ConfigTab-} from '../components/agents';+import { useParams, Navigate } from 'react-router-dom';+import AgentList from '../components/agents/AgentList';+import AgentDetail from '../components/agents/AgentDetail';export default function Agents() {- const { tab } = useParams();- const navigate = useNavigate();- const activeTab = tab || 'personalities';+ const { agentId, tab } = useParams();- const [stats, setStats] = useState({- agents: 0,- accounts: 0,- schedules: 0- });- const [loading, setLoading] = useState(true);+ // No agentId → show agent list+ if (!agentId) {+ return <AgentList />;+ }- const fetchStats = useCallback(async () => {- const [agents, accounts, scheduleStats] = await Promise.all([- api.getAgentPersonalities(),- api.getPlatformAccounts(),- api.getScheduleStats()- ]);- setStats({- agents: agents.length,- accounts: accounts.length,- schedules: scheduleStats.total- });- setLoading(false);- }, []);+ // agentId without tab → redirect to overview+ if (!tab) {+ return <Navigate to={`/agents/${agentId}/overview`} replace />;+ }- useEffect(() => {- fetchStats();- }, [fetchStats]);-- const handleTabChange = (tabId) => {- navigate(`/agents/${tabId}`);- };-- const renderTabContent = () => {- switch (activeTab) {- case 'personalities':- return <PersonalitiesTab onRefresh={fetchStats} />;- case 'accounts':- return <AccountsTab onRefresh={fetchStats} />;- case 'schedules':- return <SchedulesTab onRefresh={fetchStats} />;- case 'tools':- return <ToolsTab />;- case 'activity':- return <ActivityTab />;- case 'config':- return <ConfigTab />;- default:- return <PersonalitiesTab onRefresh={fetchStats} />;- }- };-- const getTabBadge = (tabId) => {- if (loading) return null;- switch (tabId) {- case 'personalities':- return stats.agents > 0 ? stats.agents : null;- case 'accounts':- return stats.accounts > 0 ? stats.accounts : null;- case 'schedules':- return stats.schedules > 0 ? stats.schedules : null;- default:- return null;- }- };-- return (- <div className="flex flex-col h-full">- {/* Header */}- <div className="border-b border-port-border px-6 py-4">- <h1 className="text-2xl font-bold text-white">Agents</h1>- <p className="text-sm text-gray-400 mt-1">- Manage AI agent personalities and their platform automation- </p>- </div>-- {/* Tab Navigation */}- <div className="flex gap-1 px-4 py-2 border-b border-port-border bg-port-card/50">- {TABS.map(tabDef => {- const badge = getTabBadge(tabDef.id);- const isActive = activeTab === tabDef.id;-- return (- <button- key={tabDef.id}- onClick={() => handleTabChange(tabDef.id)}- className={`px-4 py-2 rounded-t flex items-center gap-2 transition-colors ${- isActive- ? 'bg-port-bg text-white border-t border-l border-r border-port-border -mb-px'- : 'text-gray-400 hover:text-white hover:bg-port-border/30'- }`}- >- <span>{tabDef.icon}</span>- <span>{tabDef.label}</span>- {badge && (- <span className={`text-xs px-1.5 py-0.5 rounded ${- isActive ? 'bg-port-accent text-white' : 'bg-port-border text-gray-300'- }`}>- {badge}- </span>- )}- </button>- );- })}- </div>-- {/* Tab Content */}- <div className="flex-1 overflow-auto bg-port-bg">- {renderTabContent()}- </div>- </div>- );+ // agentId + tab → show agent detail+ return <AgentDetail />;}