@engram-mem/graph 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +20 -0
- package/dist/config.js.map +1 -0
- package/dist/context-extractors.d.ts +15 -0
- package/dist/context-extractors.d.ts.map +1 -0
- package/dist/context-extractors.js +206 -0
- package/dist/context-extractors.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/neural-graph.d.ts +151 -0
- package/dist/neural-graph.d.ts.map +1 -0
- package/dist/neural-graph.js +893 -0
- package/dist/neural-graph.js.map +1 -0
- package/dist/schema.d.ts +4 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +23 -0
- package/dist/schema.js.map +1 -0
- package/dist/spreading-activation.d.ts +9 -0
- package/dist/spreading-activation.d.ts.map +1 -0
- package/dist/spreading-activation.js +108 -0
- package/dist/spreading-activation.js.map +1 -0
- package/dist/types.d.ts +128 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +33 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface GraphConfig {
|
|
2
|
+
neo4jUri: string;
|
|
3
|
+
neo4jUser: string;
|
|
4
|
+
neo4jPassword: string;
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseGraphConfig(env?: Record<string, string | undefined>): GraphConfig;
|
|
8
|
+
export declare function validateGraphConfig(config: GraphConfig): void;
|
|
9
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,WAAW,CAOnG;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAO7D"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function parseGraphConfig(env = process.env) {
|
|
2
|
+
return {
|
|
3
|
+
neo4jUri: env.NEO4J_URI ?? 'bolt://localhost:7687',
|
|
4
|
+
neo4jUser: env.NEO4J_USER ?? 'neo4j',
|
|
5
|
+
neo4jPassword: env.NEO4J_PASSWORD ?? 'engram-dev',
|
|
6
|
+
enabled: env.ENGRAM_GRAPH_ENABLED !== 'false',
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function validateGraphConfig(config) {
|
|
10
|
+
if (!config.neo4jUri)
|
|
11
|
+
throw new Error('GraphConfig: neo4jUri is required');
|
|
12
|
+
if (!config.neo4jUri.startsWith('bolt://') && !config.neo4jUri.startsWith('neo4j://')) {
|
|
13
|
+
throw new Error(`GraphConfig: neo4jUri must start with bolt:// or neo4j://, got: ${config.neo4jUri}`);
|
|
14
|
+
}
|
|
15
|
+
if (!config.neo4jUser)
|
|
16
|
+
throw new Error('GraphConfig: neo4jUser is required');
|
|
17
|
+
if (!config.neo4jPassword)
|
|
18
|
+
throw new Error('GraphConfig: neo4jPassword is required');
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,gBAAgB,CAAC,MAA0C,OAAO,CAAC,GAAG;IACpF,OAAO;QACL,QAAQ,EAAE,GAAG,CAAC,SAAS,IAAI,uBAAuB;QAClD,SAAS,EAAE,GAAG,CAAC,UAAU,IAAI,OAAO;QACpC,aAAa,EAAE,GAAG,CAAC,cAAc,IAAI,YAAY;QACjD,OAAO,EAAE,GAAG,CAAC,oBAAoB,KAAK,OAAO;KAC9C,CAAA;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAmB;IACrD,IAAI,CAAC,MAAM,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;IAC1E,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACtF,MAAM,IAAI,KAAK,CAAC,mEAAmE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;IACvG,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IAC5E,IAAI,CAAC,MAAM,CAAC,aAAa;QAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;AACtF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IntentType } from '@engram-mem/core';
|
|
2
|
+
import type { EmotionLabel } from './types.js';
|
|
3
|
+
export interface PersonExtraction {
|
|
4
|
+
name: string;
|
|
5
|
+
confidence: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function extractPersons(text: string): PersonExtraction[];
|
|
8
|
+
export interface EmotionClassification {
|
|
9
|
+
label: EmotionLabel;
|
|
10
|
+
intensity: number;
|
|
11
|
+
patternMatches: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function classifyEmotion(text: string): EmotionClassification;
|
|
14
|
+
export declare function classifyContentIntent(text: string, intentPatterns: Record<IntentType, RegExp[]>): IntentType;
|
|
15
|
+
//# sourceMappingURL=context-extractors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-extractors.d.ts","sourceRoot":"","sources":["../src/context-extractors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAyE9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAgC/D;AAwCD,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,YAAY,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CA+BnE;AAMD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,GAC3C,UAAU,CAyCZ"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Person Extraction
|
|
3
|
+
// ============================================================================
|
|
4
|
+
//
|
|
5
|
+
// Precision over recall: a person-extracted name becomes a :Person node,
|
|
6
|
+
// which is a singleton across the whole graph and is used for entity-based
|
|
7
|
+
// seed injection in Wave 2. False positives like "Project Context" or
|
|
8
|
+
// "Work Session" becoming Person nodes directly poisons the retrieval
|
|
9
|
+
// signal, so these patterns all require a strong contextual cue
|
|
10
|
+
// (verb like "said/told/asked", directed-at markers like "@", or
|
|
11
|
+
// co-occurrence with "with/from/by").
|
|
12
|
+
//
|
|
13
|
+
// The old pattern that matched any two consecutive capitalized words was
|
|
14
|
+
// removed because it was catching titles, UI labels, heading text, and
|
|
15
|
+
// compound technical nouns far more often than it was catching real names.
|
|
16
|
+
const PERSON_PATTERNS = [
|
|
17
|
+
// Directed-at cues — high confidence ("tell Muhammad", "ask Sarah", "@alice")
|
|
18
|
+
/(?:(?:tell|told|ask|asked|ping|cc|dm|email|emailed)\s+|@)([A-Z][a-z]+(?:\s+[A-Z][a-z]+)?)/g,
|
|
19
|
+
// Conversational cues — medium confidence ("with Sarah", "from Muhammad")
|
|
20
|
+
/(?:with|from|by)\s+([A-Z][a-z]+(?:\s+[A-Z][a-z]+)?)(?=\s+(?:said|says|thinks|mentioned|suggested|wants|wanted|is|was|will|can|and|or|,|\.))/g,
|
|
21
|
+
// Quotative verbs — high confidence ("Muhammad said", "Sarah thinks")
|
|
22
|
+
/([A-Z][a-z]+(?:\s+[A-Z][a-z]+)?)\s+(?:said|says|told|mentioned|suggested|asked|thinks|wants|wrote|replied)/g,
|
|
23
|
+
];
|
|
24
|
+
// Words that must NOT be treated as a first name even if capitalized.
|
|
25
|
+
// Covers pronouns, determiners, conjunctions, time words, technical
|
|
26
|
+
// products seen during the Wave 2 dogfood backfill that polluted the
|
|
27
|
+
// graph, and common English headers/labels.
|
|
28
|
+
const NAME_BLOCKLIST = new Set([
|
|
29
|
+
// Personal pronouns — these leak through quotative patterns ("She said")
|
|
30
|
+
'I', 'You', 'He', 'She', 'It', 'We', 'They', 'Me', 'Him', 'Her',
|
|
31
|
+
'Us', 'Them', 'My', 'Your', 'His', 'Its', 'Our', 'Their', 'Mine',
|
|
32
|
+
'Yours', 'Hers', 'Ours', 'Theirs', 'Myself', 'Yourself', 'Himself',
|
|
33
|
+
'Herself', 'Itself', 'Ourselves', 'Yourselves', 'Themselves',
|
|
34
|
+
// Indefinite pronouns / discourse particles
|
|
35
|
+
'Someone', 'Somebody', 'Anyone', 'Anybody', 'Everyone', 'Everybody',
|
|
36
|
+
'Noone', 'No-one', 'Nobody', 'One', 'Ones',
|
|
37
|
+
// Determiners / conjunctions / adverbs that get capitalized sentence-initially
|
|
38
|
+
'The', 'This', 'That', 'These', 'Those', 'What', 'How', 'Why',
|
|
39
|
+
'When', 'Where', 'Who', 'Which', 'There', 'Here', 'Some', 'Any',
|
|
40
|
+
'Each', 'Every', 'Both', 'All', 'Most', 'Many', 'Much', 'More',
|
|
41
|
+
'Other', 'Another', 'Such', 'Same', 'Good', 'Great', 'Best',
|
|
42
|
+
'New', 'Old', 'First', 'Last', 'Next', 'Previous', 'Note',
|
|
43
|
+
'True', 'False', 'Yes', 'No', 'Maybe', 'None', 'Nothing',
|
|
44
|
+
'And', 'But', 'Or', 'So', 'If', 'Then', 'Because', 'Although',
|
|
45
|
+
'While', 'As', 'Now', 'Just', 'Also', 'Still', 'Is', 'Was', 'Are',
|
|
46
|
+
'Were', 'Will', 'Would', 'Should', 'Could', 'May', 'Might', 'Must',
|
|
47
|
+
'Do', 'Does', 'Did', 'Have', 'Has', 'Had', 'Be', 'Been', 'Being',
|
|
48
|
+
// Time
|
|
49
|
+
'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday',
|
|
50
|
+
'January', 'February', 'March', 'April', 'June', 'July',
|
|
51
|
+
'August', 'September', 'October', 'November', 'December',
|
|
52
|
+
'Today', 'Yesterday', 'Tomorrow', 'Morning', 'Afternoon', 'Evening', 'Night',
|
|
53
|
+
// Note: 'May' omitted because it's a real first name.
|
|
54
|
+
// Engram internals / Wave terms
|
|
55
|
+
'Light', 'Deep', 'Dream', 'Wave', 'Engram', 'Memory',
|
|
56
|
+
// Products, tools, companies, and common compound-noun heads that
|
|
57
|
+
// polluted the graph during Wave 2 dogfood backfill. NOT people.
|
|
58
|
+
'Claude', 'Google', 'Github', 'GitHub', 'Supabase', 'Neo4j', 'Docker',
|
|
59
|
+
'OpenAI', 'Anthropic', 'Slack', 'Telegram', 'WhatsApp', 'Fizzy', 'Plane',
|
|
60
|
+
'Ouija', 'OpenClaw', 'Snyk', 'Keystatic', 'Aithentic', 'Vercel', 'Linear',
|
|
61
|
+
'Notion', 'Figma', 'Stripe', 'Turbo', 'Turborepo', 'Vitest', 'TypeScript',
|
|
62
|
+
'JavaScript', 'Python', 'Rust', 'Node', 'React', 'Next', 'Nuxt',
|
|
63
|
+
'Project', 'Session', 'Work', 'Code', 'Agent', 'Server', 'Client',
|
|
64
|
+
'Task', 'Context', 'Action', 'System', 'Hot', 'Added', 'Status',
|
|
65
|
+
'Phase', 'Stage', 'Build', 'Deploy', 'Update', 'Summary', 'Error',
|
|
66
|
+
'Scout', 'Acceptance', 'Solutions', 'Solution', 'Items', 'Item',
|
|
67
|
+
'Ad', 'Not', 'About', 'After', 'Before', 'During', 'Through',
|
|
68
|
+
]);
|
|
69
|
+
export function extractPersons(text) {
|
|
70
|
+
const found = new Map();
|
|
71
|
+
for (let idx = 0; idx < PERSON_PATTERNS.length; idx++) {
|
|
72
|
+
const pattern = PERSON_PATTERNS[idx];
|
|
73
|
+
pattern.lastIndex = 0;
|
|
74
|
+
let match;
|
|
75
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
76
|
+
const rawName = (match[1] ?? '').trim();
|
|
77
|
+
if (rawName.length <= 1)
|
|
78
|
+
continue;
|
|
79
|
+
const parts = rawName.split(/\s+/);
|
|
80
|
+
const firstName = parts[0] ?? '';
|
|
81
|
+
const lastName = parts[1];
|
|
82
|
+
if (NAME_BLOCKLIST.has(firstName))
|
|
83
|
+
continue;
|
|
84
|
+
if (lastName && NAME_BLOCKLIST.has(lastName))
|
|
85
|
+
continue;
|
|
86
|
+
// Confidence: directed-at (idx 0) > quotative (idx 2) > conversational (idx 1)
|
|
87
|
+
const baseConfidence = idx === 0 ? 0.9 : idx === 2 ? 0.8 : 0.7;
|
|
88
|
+
// Full names score slightly higher
|
|
89
|
+
const confidence = lastName ? Math.min(0.95, baseConfidence + 0.05) : baseConfidence;
|
|
90
|
+
const existing = found.get(rawName) ?? 0;
|
|
91
|
+
found.set(rawName, Math.max(existing, confidence));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return Array.from(found.entries()).map(([name, confidence]) => ({
|
|
95
|
+
name,
|
|
96
|
+
confidence,
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
// ============================================================================
|
|
100
|
+
// Emotion Classification
|
|
101
|
+
// ============================================================================
|
|
102
|
+
const EMOTION_PATTERNS = {
|
|
103
|
+
excited: [
|
|
104
|
+
/\b(excited|awesome|amazing|fantastic|love it|great news|thrilled|pumped)\b/i,
|
|
105
|
+
/!{2,}/,
|
|
106
|
+
/\b(can'?t wait|looking forward|let'?s go)\b/i,
|
|
107
|
+
],
|
|
108
|
+
frustrated: [
|
|
109
|
+
/\b(frustrated|annoyed|stuck|blocked|broken|hate|ugh|damn|aargh)\b/i,
|
|
110
|
+
/\b(not working|keeps? failing|still (broken|stuck|wrong))\b/i,
|
|
111
|
+
/\b(wast(ed?|ing) time|going in circles|ridiculous)\b/i,
|
|
112
|
+
],
|
|
113
|
+
urgent: [
|
|
114
|
+
/\b(urgent|asap|critical|emergency|production( is)? down|blocking)\b/i,
|
|
115
|
+
/\b(immediately|right now|drop everything)\b/i,
|
|
116
|
+
],
|
|
117
|
+
curious: [
|
|
118
|
+
/\b(curious|interesting|wonder|hmm|intriguing|fascinated)\b/i,
|
|
119
|
+
/\b(what if|how does|i wonder|could we)\b/i,
|
|
120
|
+
],
|
|
121
|
+
determined: [
|
|
122
|
+
/\b(determined|committed|going to|must|will not stop|push through)\b/i,
|
|
123
|
+
/\b(no matter what|whatever it takes|let'?s do this)\b/i,
|
|
124
|
+
],
|
|
125
|
+
confused: [
|
|
126
|
+
/\b(confused|don'?t understand|what does|makes no sense|lost)\b/i,
|
|
127
|
+
/\b(huh|wait what|i'?m not following|unclear)\b/i,
|
|
128
|
+
],
|
|
129
|
+
satisfied: [
|
|
130
|
+
/\b(satisfied|pleased|glad|happy with|works? (perfectly|great|well))\b/i,
|
|
131
|
+
/\b(nailed it|exactly right|that'?s it|perfect)\b/i,
|
|
132
|
+
],
|
|
133
|
+
neutral: [],
|
|
134
|
+
};
|
|
135
|
+
export function classifyEmotion(text) {
|
|
136
|
+
let bestLabel = 'neutral';
|
|
137
|
+
let bestCount = 0;
|
|
138
|
+
for (const [label, patterns] of Object.entries(EMOTION_PATTERNS)) {
|
|
139
|
+
if (label === 'neutral' || patterns.length === 0)
|
|
140
|
+
continue;
|
|
141
|
+
let matchCount = 0;
|
|
142
|
+
for (const pattern of patterns) {
|
|
143
|
+
pattern.lastIndex = 0;
|
|
144
|
+
if (pattern.test(text))
|
|
145
|
+
matchCount++;
|
|
146
|
+
}
|
|
147
|
+
if (matchCount >= 2 && matchCount > bestCount) {
|
|
148
|
+
bestCount = matchCount;
|
|
149
|
+
bestLabel = label;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (bestLabel === 'neutral') {
|
|
153
|
+
return { label: 'neutral', intensity: 0.1, patternMatches: 0 };
|
|
154
|
+
}
|
|
155
|
+
let intensity;
|
|
156
|
+
if (bestCount === 2) {
|
|
157
|
+
intensity = 0.5;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
intensity = Math.min(0.7 + 0.1 * (bestCount - 3), 0.95);
|
|
161
|
+
}
|
|
162
|
+
return { label: bestLabel, intensity, patternMatches: bestCount };
|
|
163
|
+
}
|
|
164
|
+
// ============================================================================
|
|
165
|
+
// Intent Classification
|
|
166
|
+
// ============================================================================
|
|
167
|
+
export function classifyContentIntent(text, intentPatterns) {
|
|
168
|
+
const trimmed = text.trim();
|
|
169
|
+
const socialPatterns = intentPatterns['SOCIAL'] ?? [];
|
|
170
|
+
if (trimmed.length < 20) {
|
|
171
|
+
for (const p of socialPatterns) {
|
|
172
|
+
p.lastIndex = 0;
|
|
173
|
+
if (p.test(trimmed))
|
|
174
|
+
return 'SOCIAL';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const emotionalPatterns = intentPatterns['EMOTIONAL'] ?? [];
|
|
178
|
+
for (const p of emotionalPatterns) {
|
|
179
|
+
p.lastIndex = 0;
|
|
180
|
+
if (p.test(trimmed))
|
|
181
|
+
return 'EMOTIONAL';
|
|
182
|
+
}
|
|
183
|
+
const SCOREABLE = [
|
|
184
|
+
'RECALL_EXPLICIT', 'TASK_START', 'TASK_CONTINUE', 'QUESTION',
|
|
185
|
+
'DEBUGGING', 'PREFERENCE', 'REVIEW', 'CONTEXT_SWITCH',
|
|
186
|
+
];
|
|
187
|
+
let bestType = 'INFORMATIONAL';
|
|
188
|
+
let bestScore = 0;
|
|
189
|
+
for (const type of SCOREABLE) {
|
|
190
|
+
const patterns = intentPatterns[type] ?? [];
|
|
191
|
+
let score = 0;
|
|
192
|
+
for (const p of patterns) {
|
|
193
|
+
p.lastIndex = 0;
|
|
194
|
+
if (p.test(trimmed))
|
|
195
|
+
score++;
|
|
196
|
+
}
|
|
197
|
+
if (score > bestScore) {
|
|
198
|
+
bestScore = score;
|
|
199
|
+
bestType = type;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (bestScore > 0)
|
|
203
|
+
return bestType;
|
|
204
|
+
return trimmed.length > 15 ? 'INFORMATIONAL' : 'SOCIAL';
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=context-extractors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-extractors.js","sourceRoot":"","sources":["../src/context-extractors.ts"],"names":[],"mappings":"AAGA,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAC/E,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,sEAAsE;AACtE,sEAAsE;AACtE,gEAAgE;AAChE,iEAAiE;AACjE,sCAAsC;AACtC,EAAE;AACF,yEAAyE;AACzE,uEAAuE;AACvE,2EAA2E;AAE3E,MAAM,eAAe,GAAa;IAChC,8EAA8E;IAC9E,4FAA4F;IAC5F,0EAA0E;IAC1E,8IAA8I;IAC9I,sEAAsE;IACtE,6GAA6G;CAC9G,CAAA;AAED,sEAAsE;AACtE,oEAAoE;AACpE,qEAAqE;AACrE,4CAA4C;AAC5C,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,yEAAyE;I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G,SAAS,EAAE,CAAC;YACtB,SAAS,GAAG,KAAK,CAAA;YACjB,QAAQ,GAAG,IAAI,CAAA;QACjB,CAAC;IACH,CAAC;IAED,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAA;IAElC,OAAO,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAA;AACzD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { NeuralGraph } from './neural-graph.js';
|
|
2
|
+
export { SpreadingActivation } from './spreading-activation.js';
|
|
3
|
+
export type { SimpleEpisodeInput, EntitySeedResult, SpreadActivationOpts, ActivatedNode, } from './neural-graph.js';
|
|
4
|
+
export { parseGraphConfig, validateGraphConfig } from './config.js';
|
|
5
|
+
export type { GraphConfig } from './config.js';
|
|
6
|
+
export { extractPersons, classifyEmotion, classifyContentIntent } from './context-extractors.js';
|
|
7
|
+
export type { PersonExtraction, EmotionClassification } from './context-extractors.js';
|
|
8
|
+
export { ALL_SCHEMA_STATEMENTS, CONSTRAINTS, INDEXES } from './schema.js';
|
|
9
|
+
export type { NodeLabel, BaseNodeProperties, MemoryNodeProperties, MemoryNodeInput, PersonNodeProperties, PersonNodeInput, TopicNodeProperties, TopicNodeInput, EntityNodeProperties, EntityNodeInput, EmotionNodeProperties, EmotionNodeInput, EmotionLabel, IntentNodeProperties, IntentNodeInput, SessionNodeProperties, SessionNodeInput, TimeContextNodeProperties, TimeContextNodeInput, GraphNodeProperties, RelationType, RelationshipProperties, ActivationParams, ActivationResult, EpisodeDecomposition, } from './types.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAG/D,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,GACd,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACnE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAChG,YAAY,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAGtF,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAGzE,YAAY,EACV,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// === Core classes ===
|
|
2
|
+
export { NeuralGraph } from './neural-graph.js';
|
|
3
|
+
export { SpreadingActivation } from './spreading-activation.js';
|
|
4
|
+
// === Configuration ===
|
|
5
|
+
export { parseGraphConfig, validateGraphConfig } from './config.js';
|
|
6
|
+
// === Context extractors ===
|
|
7
|
+
export { extractPersons, classifyEmotion, classifyContentIntent } from './context-extractors.js';
|
|
8
|
+
// === Schema ===
|
|
9
|
+
export { ALL_SCHEMA_STATEMENTS, CONSTRAINTS, INDEXES } from './schema.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAU/D,wBAAwB;AACxB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAGnE,6BAA6B;AAC7B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAGhG,iBAAiB;AACjB,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { GraphConfig } from './config.js';
|
|
2
|
+
import type { MemoryNodeInput, PersonNodeInput, TopicNodeInput, EntityNodeInput, EmotionNodeInput, IntentNodeInput, SessionNodeInput, TimeContextNodeInput, EpisodeDecomposition, RelationType } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Simplified episode shape used by consumers that don't want to build a
|
|
5
|
+
* full EpisodeDecomposition. `ingestEpisode` extracts persons/emotion from
|
|
6
|
+
* `content` internally and maps `entities` (string[]) to typed entity nodes.
|
|
7
|
+
*
|
|
8
|
+
* When `llmEntities` is provided (from an IntelligenceAdapter-backed
|
|
9
|
+
* entity extractor), the regex-based person/entity extraction is SKIPPED
|
|
10
|
+
* and the structured entities are used directly. This is the production
|
|
11
|
+
* path for high-precision NER. The regex path remains as a fallback when
|
|
12
|
+
* no intelligence adapter is available.
|
|
13
|
+
*/
|
|
14
|
+
export interface SimpleEpisodeInput {
|
|
15
|
+
id: string;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
role: 'user' | 'assistant' | 'system';
|
|
18
|
+
content: string;
|
|
19
|
+
salience: number;
|
|
20
|
+
entities: string[];
|
|
21
|
+
createdAt: string | Date;
|
|
22
|
+
previousEpisodeId?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional LLM-extracted typed entities. When present, takes precedence
|
|
25
|
+
* over regex-based extraction for persons and entities. Type values:
|
|
26
|
+
* - 'person' → added to persons[]
|
|
27
|
+
* - 'tech' → Entity with entityType='tech'
|
|
28
|
+
* - 'project' → Entity with entityType='project'
|
|
29
|
+
* - 'concept' → Entity with entityType='concept'
|
|
30
|
+
* - 'org' → Entity with entityType='concept' (Wave 1 has no 'org' type)
|
|
31
|
+
*/
|
|
32
|
+
llmEntities?: Array<{
|
|
33
|
+
name: string;
|
|
34
|
+
type: 'person' | 'org' | 'tech' | 'project' | 'concept';
|
|
35
|
+
confidence: number;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Optional project scope tag. Memories with the same project share a
|
|
39
|
+
* :Project node via the PROJECT edge. Used by Wave 2 retrieval to
|
|
40
|
+
* cluster same-project memories together via spreading activation.
|
|
41
|
+
*/
|
|
42
|
+
project?: string;
|
|
43
|
+
}
|
|
44
|
+
/** Result of looking up a query entity name in Neo4j */
|
|
45
|
+
export interface EntitySeedResult {
|
|
46
|
+
nodeId: string;
|
|
47
|
+
nodeType: 'Person' | 'Entity' | 'Topic';
|
|
48
|
+
name: string;
|
|
49
|
+
}
|
|
50
|
+
/** Wave 2 spreadActivation options (wraps SpreadingActivation.activate) */
|
|
51
|
+
export interface SpreadActivationOpts {
|
|
52
|
+
seedNodeIds: string[];
|
|
53
|
+
/** Optional per-seed initial activation (currently unused by the Cypher query) */
|
|
54
|
+
seedActivations?: Map<string, number>;
|
|
55
|
+
maxHops?: number;
|
|
56
|
+
decay?: number;
|
|
57
|
+
threshold?: number;
|
|
58
|
+
budget?: number;
|
|
59
|
+
edgeFilter?: string[];
|
|
60
|
+
}
|
|
61
|
+
/** Wave 2 ActivatedNode — matches ActivationResult with stable field names */
|
|
62
|
+
export interface ActivatedNode {
|
|
63
|
+
nodeId: string;
|
|
64
|
+
nodeType: string;
|
|
65
|
+
activation: number;
|
|
66
|
+
depth: number;
|
|
67
|
+
properties: Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
export declare class NeuralGraph {
|
|
70
|
+
private driver;
|
|
71
|
+
constructor(config: GraphConfig);
|
|
72
|
+
initialize(): Promise<void>;
|
|
73
|
+
dispose(): Promise<void>;
|
|
74
|
+
addMemoryNode(input: MemoryNodeInput): Promise<string>;
|
|
75
|
+
addPersonNode(input: PersonNodeInput): Promise<string>;
|
|
76
|
+
addTopicNode(input: TopicNodeInput): Promise<string>;
|
|
77
|
+
addEntityNode(input: EntityNodeInput): Promise<string>;
|
|
78
|
+
addEmotionNode(input: EmotionNodeInput): Promise<string>;
|
|
79
|
+
addIntentNode(input: IntentNodeInput): Promise<string>;
|
|
80
|
+
addSessionNode(input: SessionNodeInput): Promise<string>;
|
|
81
|
+
addTimeContextNode(input: TimeContextNodeInput): Promise<string>;
|
|
82
|
+
addEdge(sourceId: string, targetId: string, type: RelationType, weight: number): Promise<void>;
|
|
83
|
+
getNode(id: string): Promise<{
|
|
84
|
+
id: string;
|
|
85
|
+
label: string;
|
|
86
|
+
properties: Record<string, unknown>;
|
|
87
|
+
} | null>;
|
|
88
|
+
getNeighbors(id: string, opts?: {
|
|
89
|
+
edgeType?: RelationType;
|
|
90
|
+
direction?: 'in' | 'out' | 'both';
|
|
91
|
+
limit?: number;
|
|
92
|
+
}): Promise<Array<{
|
|
93
|
+
id: string;
|
|
94
|
+
label: string;
|
|
95
|
+
properties: Record<string, unknown>;
|
|
96
|
+
edgeWeight: number;
|
|
97
|
+
}>>;
|
|
98
|
+
decomposeEpisode(input: EpisodeDecomposition): Promise<void>;
|
|
99
|
+
ensureSchema(): Promise<void>;
|
|
100
|
+
ping(): Promise<boolean>;
|
|
101
|
+
stats(): Promise<{
|
|
102
|
+
nodes: Record<string, number>;
|
|
103
|
+
relationships: Record<string, number>;
|
|
104
|
+
total: {
|
|
105
|
+
nodes: number;
|
|
106
|
+
relationships: number;
|
|
107
|
+
};
|
|
108
|
+
}>;
|
|
109
|
+
clearAll(): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Availability check — alias for ping(). Returns true iff Neo4j is reachable
|
|
112
|
+
* and responsive. Does NOT throw.
|
|
113
|
+
*/
|
|
114
|
+
isAvailable(): Promise<boolean>;
|
|
115
|
+
/**
|
|
116
|
+
* Look up Person, Entity, and Topic nodes by name. Case-insensitive match
|
|
117
|
+
* on Entity and Topic; exact match on Person.name.
|
|
118
|
+
*
|
|
119
|
+
* Used by Wave 2's entity-based seed injection: extract names from the
|
|
120
|
+
* query, pass them here, feed the resulting node IDs into spreading
|
|
121
|
+
* activation as independent graph seeds.
|
|
122
|
+
*/
|
|
123
|
+
lookupEntityNodes(names: string[]): Promise<EntitySeedResult[]>;
|
|
124
|
+
/**
|
|
125
|
+
* Wave 2 spreading activation facade. Wraps the standalone
|
|
126
|
+
* SpreadingActivation class with the option shape Wave 2 uses.
|
|
127
|
+
*
|
|
128
|
+
* Note: seedActivations is accepted for forward compatibility but the
|
|
129
|
+
* underlying Cypher query uses uniform activation (1.0) per seed.
|
|
130
|
+
* Per-seed initial weights are a Wave 3 enhancement.
|
|
131
|
+
*/
|
|
132
|
+
spreadActivation(opts: SpreadActivationOpts): Promise<ActivatedNode[]>;
|
|
133
|
+
/**
|
|
134
|
+
* Strengthen a set of directed edge pairs (sourceId, targetId).
|
|
135
|
+
* For each pair, increments weight by 0.02 (capped at 1.0), bumps
|
|
136
|
+
* traversalCount, and updates lastTraversed.
|
|
137
|
+
*
|
|
138
|
+
* This is the reconsolidation analog: edges we actually traversed
|
|
139
|
+
* during recall get slightly stronger, making future retrieval faster.
|
|
140
|
+
*/
|
|
141
|
+
strengthenTraversedEdges(pairs: Array<[string, string]>): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Simplified ingestion path for Wave 2. Takes a core-shaped episode,
|
|
144
|
+
* extracts persons/emotion internally (or uses LLM-extracted entities
|
|
145
|
+
* when provided), and delegates to decomposeEpisode().
|
|
146
|
+
*
|
|
147
|
+
* Also creates the TEMPORAL edge from previousEpisodeId when provided.
|
|
148
|
+
*/
|
|
149
|
+
ingestEpisode(input: SimpleEpisodeInput): Promise<void>;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=neural-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neural-graph.d.ts","sourceRoot":"","sources":["../src/neural-graph.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EAGb,MAAM,YAAY,CAAA;AAQnB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC;QAClB,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;QACvD,UAAU,EAAE,MAAM,CAAA;KACnB,CAAC,CAAA;IACF;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,QAA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