diff --git a/src/app/dashboard/memory/page.tsx b/src/app/dashboard/memory/page.tsx new file mode 100644 index 0000000..12aab6c --- /dev/null +++ b/src/app/dashboard/memory/page.tsx @@ -0,0 +1,100 @@ +'use client'; + +import { useMemo } from 'react'; +import { useQuery } from '@tanstack/react-query'; +import Link from 'next/link'; +import { apiFetch } from '../../../lib/api'; +import { useSession } from '../../../components/session-provider'; + +interface ResearchBrief { id: string; title: string; subjectType: string | null; subjectId: string | null; tags: string[]; createdAt: string; } +interface Decision { id: string; title: string; rationale: string | null; tags: string[]; createdAt: string; } +interface Observation { id: string; metric: string; value: string; subjectType: string; source: string | null; createdAt: string; } + +export default function MemoryKnowledgePage() { + const { activeTenant } = useSession(); + const tenantId = activeTenant?.tenantId ?? ''; + + const { data: briefs = [] } = useQuery({ queryKey: ['mem-briefs', tenantId], queryFn: () => apiFetch('/v1/research-briefs', { tenantId }), enabled: Boolean(tenantId), staleTime: 120_000 }); + const { data: decisions = [] } = useQuery({ queryKey: ['mem-decisions', tenantId], queryFn: () => apiFetch('/v1/decisions?limit=200', { tenantId }), enabled: Boolean(tenantId), staleTime: 120_000 }); + const { data: observations = [] } = useQuery({ queryKey: ['mem-obs', tenantId], queryFn: () => apiFetch('/v1/observations', { tenantId }), enabled: Boolean(tenantId), staleTime: 120_000 }); + + const stats = useMemo(() => { + const facts = observations.filter((o) => o.source && o.source.trim().length > 0); + const uniqueTypes = new Set(observations.map((o) => o.subjectType)).size; + const uniqueMetrics = new Set(observations.map((o) => o.metric)).size; + const withRationale = decisions.filter((d) => d.rationale && d.rationale.length > 20); + return { facts, uniqueTypes, uniqueMetrics, withRationale }; + }, [observations, decisions]); + + return ( +
+
+

Memory & Knowledge

+

Graf de cunoaștere CEO OS — fapte, relații și context cu provenance.

+
+ +
+

Apache AGE — neconectat la ceo-api

+

+ Apache AGE (PostgreSQL extension for graph queries) rulează pe server. + Conexiunea la ceo-api și UI-ul graf complet (entități/relații/provenance) sunt în dezvoltare. + Datele curente sunt stocate în PostgreSQL standard și accesibile prin modulele de mai jos. +

+
+ + {/* Current knowledge stats */} +
+
+

{observations.length}

+

fapte logate

+
+
+

{briefs.length}

+

research briefs

+
+
+

{stats.withRationale.length}

+

decizii documentate

+
+
+

{stats.uniqueMetrics}

+

tipuri metrici

+
+
+ + {/* Modules currently available */} +
+

Module de cunoaștere disponibile acum

+
+ {[ + { label: 'Research Briefs', href: '/dashboard/intelligence/insights', desc: `${briefs.length} briefs`, icon: '📚' }, + { label: 'Decizii documentate', href: '/dashboard/decisions', desc: `${stats.withRationale.length} cu rațional`, icon: '🧠' }, + { label: 'Observații personale', href: '/dashboard/personal-kpi', desc: `${observations.length} fapte`, icon: '📊' }, + { label: 'Intelligence Persoane', href: '/dashboard/intelligence/people', desc: 'Contacte + observații', icon: '👤' }, + { label: 'Intelligence Companii', href: '/dashboard/intelligence/companies', desc: 'ClickHouse 147M+', icon: '🏢' }, + { label: 'AnythingLLM RAG', href: '/dashboard/integrations', desc: 'Q&A pe documente', icon: '🔍' }, + ].map((m) => ( + + {m.icon} +
+

{m.label}

+

{m.desc}

+
+ + ))} +
+
+ + {/* Architecture note */} +
+

Arhitectură Memory Graph (planificată)

+
+

PostgreSQL + Apache AGE → Cypher queries

+

Entități: Person, Company, Document, Decision, Observation

+

Relații: WORKS_AT, MENTIONED_IN, SUPPORTS, CONFLICTS_WITH, CAUSED_BY

+

Provenance: source + timestamp + confidence pe fiecare fap

+
+
+
+ ); +}