Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat(cos): improve memory extraction and show memory status in UI

Adam Eivy9fff0dd2ab03
diff --git a/client/src/components/cos/tabs/AgentCard.jsx b/client/src/components/cos/tabs/AgentCard.jsx
index c621f86c89..d433123f11 100644
--- a/client/src/components/cos/tabs/AgentCard.jsx
+++ b/client/src/components/cos/tabs/AgentCard.jsx
@@ -9,7 +9,8 @@ import {
Loader2,
Skull,
Activity,
- Clock
+ Clock,
+ Brain
} from 'lucide-react';
import * as api from '../../../services/api';
@@ -284,11 +285,29 @@ export default function AgentCard({ agent, onTerminate, onKill, onDelete, onResu
)}
{agent.result && (
- <div className={`text-sm flex items-center gap-2 ${agent.result.success ? 'text-port-success' : 'text-port-error'}`}>
- {agent.result.success ? (
- <><CheckCircle size={14} aria-hidden="true" /> Completed successfully</>
- ) : (
- <><AlertCircle size={14} aria-hidden="true" /> {agent.result.error || 'Failed'}</>
+ <div className="flex items-center gap-4 flex-wrap">
+ <div className={`text-sm flex items-center gap-2 ${agent.result.success ? 'text-port-success' : 'text-port-error'}`}>
+ {agent.result.success ? (
+ <><CheckCircle size={14} aria-hidden="true" /> Completed successfully</>
+ ) : (
+ <><AlertCircle size={14} aria-hidden="true" /> {agent.result.error || 'Failed'}</>
+ )}
+ </div>
+ {/* Memory extraction status */}
+ {agent.result.success && (
+ <div className={`text-sm flex items-center gap-1 ${
+ agent.memoryExtraction?.created > 0 ? 'text-purple-400' :
+ agent.memoryExtraction?.pendingApproval > 0 ? 'text-yellow-400' : 'text-gray-500'
+ }`} title={agent.memoryExtraction?.extractedAt ? `Extracted at ${new Date(agent.memoryExtraction.extractedAt).toLocaleString()}` : 'No memories extracted'}>
+ <Brain size={14} aria-hidden="true" />
+ {agent.memoryExtraction?.created > 0 ? (
+ <span>{agent.memoryExtraction.created} memor{agent.memoryExtraction.created === 1 ? 'y' : 'ies'}</span>
+ ) : agent.memoryExtraction?.pendingApproval > 0 ? (
+ <span>{agent.memoryExtraction.pendingApproval} pending</span>
+ ) : (
+ <span className="opacity-50">No memories</span>
+ )}
+ </div>
)}
</div>
)}
diff --git a/server/services/memoryExtractor.js b/server/services/memoryExtractor.js
index 47e2d747fe..534c82ed9f 100644
--- a/server/services/memoryExtractor.js
+++ b/server/services/memoryExtractor.js
@@ -55,10 +55,10 @@ function parseMemoryBlocks(output) {
*/
function extractPatterns(output) {
const memories = [];
+ let match;
// Pattern: "I learned that..." or "I discovered that..."
const learnedRegex = /(?:I\s+)?(?:learned|discovered|found out|realized|noticed)\s+that\s+(.+?)(?:\.|$)/gi;
- let match;
while ((match = learnedRegex.exec(output)) !== null) {
memories.push({
type: 'learning',
@@ -117,6 +117,58 @@ function extractPatterns(output) {
});
}
+ // Pattern: "No Issues Found" / "No issues detected" / "No fixes required"
+ // High confidence - this is a clear finding that something is working well
+ const noIssuesRegex = /\*\*(?:No\s+(?:Issues?|Problems?|Errors?|Bugs?)\s+Found|No\s+(?:fixes?|changes?)\s+(?:required|needed|necessary))\*\*/gi;
+ if (noIssuesRegex.test(output)) {
+ memories.push({
+ type: 'observation',
+ content: 'Analysis found no issues requiring fixes',
+ confidence: 0.85,
+ category: 'codebase',
+ tags: ['audit-result', 'no-action-needed']
+ });
+ }
+
+ // Pattern: "already well-optimized" / "already has excellent" / "already implemented"
+ const alreadyWorkingRegex = /(?:already|currently)\s+(?:has\s+)?(?:excellent|good|great|proper|well[- ]?optimized|well[- ]?implemented|working\s+well|fully\s+implemented)\s+([^\n.]+)/gi;
+ while ((match = alreadyWorkingRegex.exec(output)) !== null) {
+ memories.push({
+ type: 'fact',
+ content: `Already has excellent ${match[1].trim()}`,
+ confidence: 0.85,
+ category: 'codebase',
+ tags: ['existing-feature', 'no-action-needed']
+ });
+ }
+
+ // Pattern: Conclusion sections - extract the actual conclusion content
+ const conclusionRegex = /#{1,3}\s*Conclusion\s*\n+(.+?)(?:\n\n|\n#|$)/gis;
+ while ((match = conclusionRegex.exec(output)) !== null) {
+ const conclusion = match[1].trim().replace(/\n/g, ' ').substring(0, 300);
+ if (conclusion.length > 20) {
+ memories.push({
+ type: 'learning',
+ content: conclusion,
+ confidence: 0.85,
+ category: 'codebase',
+ tags: ['conclusion', 'audit-result']
+ });
+ }
+ }
+
+ // Pattern: "The application/UI/system is..." followed by positive assessment
+ const assessmentRegex = /(?:The\s+)?(?:application|app|UI|system|codebase|code)\s+(?:is|has)\s+(?:already\s+)?(?:well[- ]?(?:optimized|designed|structured|implemented)|properly\s+(?:configured|set up)|fully\s+(?:functional|working))/gi;
+ while ((match = assessmentRegex.exec(output)) !== null) {
+ memories.push({
+ type: 'observation',
+ content: match[0].trim(),
+ confidence: 0.8,
+ category: 'codebase',
+ tags: ['assessment', 'status']
+ });
+ }
+
return memories;
}
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index b399bd9616..97a107fd56 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -681,9 +681,20 @@ async function handleAgentCompletion(agentId, exitCode, success, duration) {
// Extract memories from successful output
if (success && outputBuffer.length > 100) {
- extractAndStoreMemories(agentId, task.id, outputBuffer, task).catch(err => {
+ const memoryResult = await extractAndStoreMemories(agentId, task.id, outputBuffer, task).catch(err => {
console.log(`⚠️ Memory extraction failed: ${err.message}`);
+ return { created: 0, pendingApproval: 0 };
});
+ // Update agent with memory extraction result
+ if (memoryResult.created > 0 || memoryResult.pendingApproval > 0) {
+ await updateAgent(agentId, {
+ memoryExtraction: {
+ created: memoryResult.created,
+ pendingApproval: memoryResult.pendingApproval,
+ extractedAt: new Date().toISOString()
+ }
+ });
+ }
}
// Handle app cooldown
@@ -825,9 +836,20 @@ async function spawnDirectly(agentId, task, prompt, workspacePath, model, provid
}
if (success && outputBuffer.length > 100) {
- extractAndStoreMemories(agentId, task.id, outputBuffer, task).catch(err => {
+ const memoryResult = await extractAndStoreMemories(agentId, task.id, outputBuffer, task).catch(err => {
console.log(`⚠️ Memory extraction failed: ${err.message}`);
+ return { created: 0, pendingApproval: 0 };
});
+ // Update agent with memory extraction result
+ if (memoryResult.created > 0 || memoryResult.pendingApproval > 0) {
+ await updateAgent(agentId, {
+ memoryExtraction: {
+ created: memoryResult.created,
+ pendingApproval: memoryResult.pendingApproval,
+ extractedAt: new Date().toISOString()
+ }
+ });
+ }
}
const appId = task.metadata?.app;