@recallbricks/runtime 0.2.0
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/LICENSE +21 -0
- package/README.md +502 -0
- package/dist/adapters/api/index.d.ts +2 -0
- package/dist/adapters/api/index.d.ts.map +1 -0
- package/dist/adapters/api/index.js +6 -0
- package/dist/adapters/api/index.js.map +1 -0
- package/dist/adapters/api/server.d.ts +13 -0
- package/dist/adapters/api/server.d.ts.map +1 -0
- package/dist/adapters/api/server.js +241 -0
- package/dist/adapters/api/server.js.map +1 -0
- package/dist/adapters/mcp/index.d.ts +2 -0
- package/dist/adapters/mcp/index.d.ts.map +1 -0
- package/dist/adapters/mcp/index.js +6 -0
- package/dist/adapters/mcp/index.js.map +1 -0
- package/dist/adapters/mcp/server.d.ts +27 -0
- package/dist/adapters/mcp/server.d.ts.map +1 -0
- package/dist/adapters/mcp/server.js +227 -0
- package/dist/adapters/mcp/server.js.map +1 -0
- package/dist/adapters/typescript/index.d.ts +4 -0
- package/dist/adapters/typescript/index.d.ts.map +1 -0
- package/dist/adapters/typescript/index.js +24 -0
- package/dist/adapters/typescript/index.js.map +1 -0
- package/dist/api/RecallBricksClient.d.ts +53 -0
- package/dist/api/RecallBricksClient.d.ts.map +1 -0
- package/dist/api/RecallBricksClient.js +129 -0
- package/dist/api/RecallBricksClient.js.map +1 -0
- package/dist/api/TelemetryClient.d.ts +54 -0
- package/dist/api/TelemetryClient.d.ts.map +1 -0
- package/dist/api/TelemetryClient.js +190 -0
- package/dist/api/TelemetryClient.js.map +1 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +6 -0
- package/dist/api/index.js.map +1 -0
- package/dist/config/index.d.ts +13 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +206 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/AgentRuntime.d.ts +45 -0
- package/dist/core/AgentRuntime.d.ts.map +1 -0
- package/dist/core/AgentRuntime.js +328 -0
- package/dist/core/AgentRuntime.js.map +1 -0
- package/dist/core/AutoSaver.d.ts +26 -0
- package/dist/core/AutoSaver.d.ts.map +1 -0
- package/dist/core/AutoSaver.js +162 -0
- package/dist/core/AutoSaver.js.map +1 -0
- package/dist/core/CircuitBreaker.d.ts +64 -0
- package/dist/core/CircuitBreaker.d.ts.map +1 -0
- package/dist/core/CircuitBreaker.js +201 -0
- package/dist/core/CircuitBreaker.js.map +1 -0
- package/dist/core/ContextLoader.d.ts +31 -0
- package/dist/core/ContextLoader.d.ts.map +1 -0
- package/dist/core/ContextLoader.js +236 -0
- package/dist/core/ContextLoader.js.map +1 -0
- package/dist/core/ContextWeaver.d.ts +49 -0
- package/dist/core/ContextWeaver.d.ts.map +1 -0
- package/dist/core/ContextWeaver.js +216 -0
- package/dist/core/ContextWeaver.js.map +1 -0
- package/dist/core/IdentityValidator.d.ts +24 -0
- package/dist/core/IdentityValidator.d.ts.map +1 -0
- package/dist/core/IdentityValidator.js +161 -0
- package/dist/core/IdentityValidator.js.map +1 -0
- package/dist/core/LLMAdapter.d.ts +19 -0
- package/dist/core/LLMAdapter.d.ts.map +1 -0
- package/dist/core/LLMAdapter.js +223 -0
- package/dist/core/LLMAdapter.js.map +1 -0
- package/dist/core/Metrics.d.ts +96 -0
- package/dist/core/Metrics.d.ts.map +1 -0
- package/dist/core/Metrics.js +271 -0
- package/dist/core/Metrics.js.map +1 -0
- package/dist/core/RateLimiter.d.ts +39 -0
- package/dist/core/RateLimiter.d.ts.map +1 -0
- package/dist/core/RateLimiter.js +251 -0
- package/dist/core/RateLimiter.js.map +1 -0
- package/dist/core/ReflectionEngine.d.ts +70 -0
- package/dist/core/ReflectionEngine.d.ts.map +1 -0
- package/dist/core/ReflectionEngine.js +319 -0
- package/dist/core/ReflectionEngine.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +259 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +38 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReflectionEngine = void 0;
|
|
4
|
+
class ReflectionEngine {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
this.interactionCount = 0;
|
|
8
|
+
this.recentTurns = [];
|
|
9
|
+
this.reflectionHistory = [];
|
|
10
|
+
this.pendingContradictions = [];
|
|
11
|
+
config.logger.debug('ReflectionEngine initialized', {
|
|
12
|
+
reflectionInterval: config.reflectionInterval,
|
|
13
|
+
confidenceThreshold: config.confidenceThreshold,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
recordInteraction(turn, confidence) {
|
|
17
|
+
this.interactionCount++;
|
|
18
|
+
this.recentTurns.push(turn);
|
|
19
|
+
if (this.recentTurns.length > 10) {
|
|
20
|
+
this.recentTurns.shift();
|
|
21
|
+
}
|
|
22
|
+
this.config.logger.debug('Interaction recorded', {
|
|
23
|
+
count: this.interactionCount,
|
|
24
|
+
confidence,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
shouldReflect(context) {
|
|
28
|
+
if (context?.taskComplete) {
|
|
29
|
+
return { shouldReflect: true, trigger: 'task_complete' };
|
|
30
|
+
}
|
|
31
|
+
if (context?.confidence !== undefined &&
|
|
32
|
+
context.confidence < this.config.confidenceThreshold) {
|
|
33
|
+
return { shouldReflect: true, trigger: 'confidence_below_threshold' };
|
|
34
|
+
}
|
|
35
|
+
if (context?.contradictionDetected || this.pendingContradictions.length > 0) {
|
|
36
|
+
return { shouldReflect: true, trigger: 'contradiction_detected' };
|
|
37
|
+
}
|
|
38
|
+
if (this.interactionCount >= this.config.reflectionInterval) {
|
|
39
|
+
return { shouldReflect: true, trigger: 'interaction_count' };
|
|
40
|
+
}
|
|
41
|
+
return { shouldReflect: false };
|
|
42
|
+
}
|
|
43
|
+
async reflect(trigger = 'manual') {
|
|
44
|
+
this.config.logger.info('Starting reflection', { trigger });
|
|
45
|
+
const startTime = Date.now();
|
|
46
|
+
const prompt = this.buildReflectionPrompt(trigger);
|
|
47
|
+
const messages = [
|
|
48
|
+
{
|
|
49
|
+
role: 'system',
|
|
50
|
+
content: `You are ${this.config.agentName}'s metacognition module. Analyze the recent interactions and provide insights for self-improvement. Be concise and actionable.`,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
role: 'user',
|
|
54
|
+
content: prompt,
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
const llmResponse = await this.config.llmAdapter.chat(messages);
|
|
58
|
+
const reflectionContent = llmResponse.content;
|
|
59
|
+
const insights = this.extractInsights(reflectionContent);
|
|
60
|
+
const confidence = this.estimateConfidence(reflectionContent, insights);
|
|
61
|
+
const reflection = {
|
|
62
|
+
id: `ref_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
63
|
+
type: this.getReflectionType(trigger),
|
|
64
|
+
content: reflectionContent,
|
|
65
|
+
insights,
|
|
66
|
+
confidence,
|
|
67
|
+
timestamp: new Date().toISOString(),
|
|
68
|
+
triggerCondition: trigger,
|
|
69
|
+
relatedMemories: this.recentTurns.slice(-3).map((t) => t.userMessage.slice(0, 50)),
|
|
70
|
+
};
|
|
71
|
+
await this.saveReflectionAsMemory(reflection);
|
|
72
|
+
this.interactionCount = 0;
|
|
73
|
+
this.pendingContradictions = [];
|
|
74
|
+
this.reflectionHistory.push(reflection);
|
|
75
|
+
if (this.reflectionHistory.length > 20) {
|
|
76
|
+
this.reflectionHistory.shift();
|
|
77
|
+
}
|
|
78
|
+
const duration = Date.now() - startTime;
|
|
79
|
+
this.config.logger.info('Reflection completed', {
|
|
80
|
+
duration: `${duration}ms`,
|
|
81
|
+
insights: insights.length,
|
|
82
|
+
confidence,
|
|
83
|
+
});
|
|
84
|
+
return reflection;
|
|
85
|
+
}
|
|
86
|
+
async explain(query, memories) {
|
|
87
|
+
this.config.logger.debug('Generating reasoning trace', { query });
|
|
88
|
+
const memoryContext = memories
|
|
89
|
+
.slice(0, 5)
|
|
90
|
+
.map((m, i) => `[${i + 1}] ${m.content}`)
|
|
91
|
+
.join('\n');
|
|
92
|
+
const messages = [
|
|
93
|
+
{
|
|
94
|
+
role: 'system',
|
|
95
|
+
content: `You are ${this.config.agentName}. Think step by step to answer the query. For each step, provide your thought process. Reference relevant memories by their number.`,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
role: 'user',
|
|
99
|
+
content: `Query: ${query}\n\nRelevant memories:\n${memoryContext}\n\nThink through this step by step:`,
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
const llmResponse = await this.config.llmAdapter.chat(messages);
|
|
103
|
+
const reasoning = llmResponse.content;
|
|
104
|
+
const steps = this.parseReasoningSteps(reasoning);
|
|
105
|
+
const conclusion = this.extractConclusion(reasoning);
|
|
106
|
+
const memoryRefs = this.extractMemoryReferences(reasoning);
|
|
107
|
+
const confidence = Math.min(1, 0.5 + steps.length * 0.1 + memoryRefs.length * 0.1);
|
|
108
|
+
return {
|
|
109
|
+
query,
|
|
110
|
+
steps,
|
|
111
|
+
conclusion,
|
|
112
|
+
confidence,
|
|
113
|
+
memoryReferences: memoryRefs,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
detectContradiction(memory1, memory2) {
|
|
117
|
+
const opposingPairs = [
|
|
118
|
+
['love', 'hate'],
|
|
119
|
+
['like', 'dislike'],
|
|
120
|
+
['yes', 'no'],
|
|
121
|
+
['always', 'never'],
|
|
122
|
+
['true', 'false'],
|
|
123
|
+
['good', 'bad'],
|
|
124
|
+
['want', "don't want"],
|
|
125
|
+
['prefer', "don't prefer"],
|
|
126
|
+
];
|
|
127
|
+
const content1 = memory1.content.toLowerCase();
|
|
128
|
+
const content2 = memory2.content.toLowerCase();
|
|
129
|
+
for (const [word1, word2] of opposingPairs) {
|
|
130
|
+
if ((content1.includes(word1) && content2.includes(word2)) ||
|
|
131
|
+
(content1.includes(word2) && content2.includes(word1))) {
|
|
132
|
+
const words1 = new Set(content1.split(/\s+/));
|
|
133
|
+
const words2 = new Set(content2.split(/\s+/));
|
|
134
|
+
const overlap = [...words1].filter((w) => words2.has(w) && w.length > 3);
|
|
135
|
+
if (overlap.length >= 2) {
|
|
136
|
+
this.pendingContradictions.push({ memory1, memory2 });
|
|
137
|
+
this.config.logger.warn('Potential contradiction detected', {
|
|
138
|
+
overlap,
|
|
139
|
+
});
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
getReflectionHistory() {
|
|
147
|
+
return [...this.reflectionHistory];
|
|
148
|
+
}
|
|
149
|
+
getPendingContradictions() {
|
|
150
|
+
return [...this.pendingContradictions];
|
|
151
|
+
}
|
|
152
|
+
buildReflectionPrompt(trigger) {
|
|
153
|
+
const recentContext = this.recentTurns
|
|
154
|
+
.slice(-5)
|
|
155
|
+
.map((t) => `User: ${t.userMessage.slice(0, 100)}...\nAssistant: ${t.assistantResponse.slice(0, 100)}...`)
|
|
156
|
+
.join('\n\n');
|
|
157
|
+
let prompt = `Reflect on these recent interactions:\n\n${recentContext}\n\n`;
|
|
158
|
+
switch (trigger) {
|
|
159
|
+
case 'task_complete':
|
|
160
|
+
prompt +=
|
|
161
|
+
'The user has indicated task completion. Reflect on:\n' +
|
|
162
|
+
'1. What was accomplished?\n' +
|
|
163
|
+
'2. What could have been done better?\n' +
|
|
164
|
+
'3. What should I remember for future similar tasks?';
|
|
165
|
+
break;
|
|
166
|
+
case 'confidence_below_threshold':
|
|
167
|
+
prompt +=
|
|
168
|
+
'I detected low confidence in my responses. Reflect on:\n' +
|
|
169
|
+
'1. Why was my confidence low?\n' +
|
|
170
|
+
'2. What information was missing?\n' +
|
|
171
|
+
'3. How can I improve for similar questions?';
|
|
172
|
+
break;
|
|
173
|
+
case 'contradiction_detected':
|
|
174
|
+
const contradictions = this.pendingContradictions
|
|
175
|
+
.slice(0, 3)
|
|
176
|
+
.map((c) => `Memory 1: "${c.memory1.content.slice(0, 50)}..."\n` +
|
|
177
|
+
`Memory 2: "${c.memory2.content.slice(0, 50)}..."`)
|
|
178
|
+
.join('\n\n');
|
|
179
|
+
prompt +=
|
|
180
|
+
`Contradictions detected in my memory:\n${contradictions}\n\n` +
|
|
181
|
+
'Reflect on:\n' +
|
|
182
|
+
'1. Which information is more recent/reliable?\n' +
|
|
183
|
+
'2. How should I reconcile these?\n' +
|
|
184
|
+
'3. What questions should I ask to clarify?';
|
|
185
|
+
break;
|
|
186
|
+
case 'interaction_count':
|
|
187
|
+
case 'manual':
|
|
188
|
+
default:
|
|
189
|
+
prompt +=
|
|
190
|
+
'Periodic self-reflection. Consider:\n' +
|
|
191
|
+
'1. What patterns do I notice in user needs?\n' +
|
|
192
|
+
'2. What have I learned that should be remembered?\n' +
|
|
193
|
+
'3. How can I be more helpful?';
|
|
194
|
+
}
|
|
195
|
+
return prompt;
|
|
196
|
+
}
|
|
197
|
+
extractInsights(content) {
|
|
198
|
+
const insights = [];
|
|
199
|
+
const listMatches = content.match(/(?:\d+\.|[-•*])\s*([^\n]+)/g);
|
|
200
|
+
if (listMatches) {
|
|
201
|
+
insights.push(...listMatches.map((m) => m.replace(/^(?:\d+\.|[-•*])\s*/, '').trim()));
|
|
202
|
+
}
|
|
203
|
+
const sentences = content.split(/[.!?]+/);
|
|
204
|
+
const insightKeywords = [
|
|
205
|
+
'should',
|
|
206
|
+
'could',
|
|
207
|
+
'need to',
|
|
208
|
+
'important',
|
|
209
|
+
'remember',
|
|
210
|
+
'notice',
|
|
211
|
+
'pattern',
|
|
212
|
+
'improve',
|
|
213
|
+
'better',
|
|
214
|
+
'learn',
|
|
215
|
+
];
|
|
216
|
+
for (const sentence of sentences) {
|
|
217
|
+
const trimmed = sentence.trim();
|
|
218
|
+
if (trimmed.length > 20 &&
|
|
219
|
+
insightKeywords.some((k) => trimmed.toLowerCase().includes(k)) &&
|
|
220
|
+
!insights.includes(trimmed)) {
|
|
221
|
+
insights.push(trimmed);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return insights.slice(0, 5);
|
|
225
|
+
}
|
|
226
|
+
estimateConfidence(content, insights) {
|
|
227
|
+
let confidence = 0.5;
|
|
228
|
+
confidence += Math.min(insights.length * 0.1, 0.3);
|
|
229
|
+
if (content.length > 500)
|
|
230
|
+
confidence += 0.1;
|
|
231
|
+
if (content.length > 1000)
|
|
232
|
+
confidence += 0.05;
|
|
233
|
+
if (content.includes('1.') || content.includes('-'))
|
|
234
|
+
confidence += 0.05;
|
|
235
|
+
return Math.min(confidence, 1);
|
|
236
|
+
}
|
|
237
|
+
getReflectionType(trigger) {
|
|
238
|
+
switch (trigger) {
|
|
239
|
+
case 'task_complete':
|
|
240
|
+
return 'task_completion';
|
|
241
|
+
case 'confidence_below_threshold':
|
|
242
|
+
return 'low_confidence';
|
|
243
|
+
case 'contradiction_detected':
|
|
244
|
+
return 'contradiction';
|
|
245
|
+
case 'interaction_count':
|
|
246
|
+
return 'periodic';
|
|
247
|
+
default:
|
|
248
|
+
return 'self_improvement';
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async saveReflectionAsMemory(reflection) {
|
|
252
|
+
try {
|
|
253
|
+
await this.config.apiClient.saveMemory({
|
|
254
|
+
text: `[Reflection - ${reflection.type}] ${reflection.content}`,
|
|
255
|
+
tags: ['reflection', reflection.type],
|
|
256
|
+
source: 'reflection-engine',
|
|
257
|
+
metadata: {
|
|
258
|
+
reflectionId: reflection.id,
|
|
259
|
+
insights: reflection.insights,
|
|
260
|
+
confidence: reflection.confidence,
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
this.config.logger.debug('Reflection saved as memory');
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
this.config.logger.warn('Failed to save reflection as memory', { error });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
parseReasoningSteps(reasoning) {
|
|
270
|
+
const steps = [];
|
|
271
|
+
const stepPatterns = [
|
|
272
|
+
/(?:Step\s*\d+[:.]\s*|(?:\d+)[.)]\s*)([^\n]+(?:\n(?![Ss]tep|\d+[.)]).*)*)/g,
|
|
273
|
+
/(?:First|Second|Third|Fourth|Fifth|Then|Next|Finally)[,:]?\s*([^\n]+)/gi,
|
|
274
|
+
];
|
|
275
|
+
for (const pattern of stepPatterns) {
|
|
276
|
+
let match;
|
|
277
|
+
while ((match = pattern.exec(reasoning)) !== null) {
|
|
278
|
+
steps.push({
|
|
279
|
+
thought: match[1].trim(),
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (steps.length === 0) {
|
|
284
|
+
const sentences = reasoning.split(/[.!?]+/).filter((s) => s.trim().length > 20);
|
|
285
|
+
for (const sentence of sentences.slice(0, 5)) {
|
|
286
|
+
steps.push({ thought: sentence.trim() });
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return steps;
|
|
290
|
+
}
|
|
291
|
+
extractConclusion(reasoning) {
|
|
292
|
+
const conclusionPatterns = [
|
|
293
|
+
/(?:Therefore|Thus|In conclusion|So|Finally|The answer is)[,:]?\s*([^.]+\.)/i,
|
|
294
|
+
/(?:Based on|Given|Considering)[^.]+,\s*([^.]+\.)/i,
|
|
295
|
+
];
|
|
296
|
+
for (const pattern of conclusionPatterns) {
|
|
297
|
+
const match = reasoning.match(pattern);
|
|
298
|
+
if (match) {
|
|
299
|
+
return match[1].trim();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const sentences = reasoning.split(/[.!?]+/).filter((s) => s.trim().length > 0);
|
|
303
|
+
return sentences[sentences.length - 1]?.trim() || reasoning.slice(-200);
|
|
304
|
+
}
|
|
305
|
+
extractMemoryReferences(reasoning) {
|
|
306
|
+
const refs = [];
|
|
307
|
+
const refMatches = reasoning.match(/\[(\d+)\]/g);
|
|
308
|
+
if (refMatches) {
|
|
309
|
+
refs.push(...refMatches.map((r) => r.slice(1, -1)));
|
|
310
|
+
}
|
|
311
|
+
const wordRefs = reasoning.match(/(?:memory|fact|observation)\s*(\d+)/gi);
|
|
312
|
+
if (wordRefs) {
|
|
313
|
+
refs.push(...wordRefs.map((r) => r.match(/\d+/)?.[0] || '').filter(Boolean));
|
|
314
|
+
}
|
|
315
|
+
return [...new Set(refs)];
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
exports.ReflectionEngine = ReflectionEngine;
|
|
319
|
+
//# sourceMappingURL=ReflectionEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReflectionEngine.js","sourceRoot":"","sources":["../../src/core/ReflectionEngine.ts"],"names":[],"mappings":";;;AA2EA,MAAa,gBAAgB;IAM3B,YAAoB,MAA8B;QAA9B,WAAM,GAAN,MAAM,CAAwB;QAL1C,qBAAgB,GAAG,CAAC,CAAC;QACrB,gBAAW,GAAuB,EAAE,CAAC;QACrC,sBAAiB,GAAiB,EAAE,CAAC;QACrC,0BAAqB,GAAgD,EAAE,CAAC;QAG9E,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE;YAClD,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;YAC7C,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;SAChD,CAAC,CAAC;IACL,CAAC;IAKD,iBAAiB,CAAC,IAAsB,EAAE,UAAmB;QAC3D,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAG5B,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACjC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,E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S,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1E,CAAC;IAKO,uBAAuB,CAAC,SAAiB;QAC/C,MAAM,IAAI,GAAa,EAAE,CAAC;QAG1B,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACjD,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,CAAC;QAGD,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC1E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,IAAI,CACP,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAClE,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5B,CAAC;CACF;AAzdD,4CAydC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { AgentRuntime } from './core/AgentRuntime';
|
|
2
|
+
export { LLMAdapter } from './core/LLMAdapter';
|
|
3
|
+
export { ContextLoader } from './core/ContextLoader';
|
|
4
|
+
export { ContextWeaver } from './core/ContextWeaver';
|
|
5
|
+
export type { Context, ContextWeaverConfig, ContextBuildOptions } from './core/ContextWeaver';
|
|
6
|
+
export { AutoSaver } from './core/AutoSaver';
|
|
7
|
+
export { IdentityValidator } from './core/IdentityValidator';
|
|
8
|
+
export { ReflectionEngine } from './core/ReflectionEngine';
|
|
9
|
+
export type { Reflection, ReflectionType, ReflectionTrigger, ReasoningTrace, ReasoningStep, } from './core/ReflectionEngine';
|
|
10
|
+
export { RecallBricksClient } from './api/RecallBricksClient';
|
|
11
|
+
export type { RecallBricksClientConfig, SaveMemoryRequest, RecallMemoriesRequest, RegisterAgentRequest, RegisterAgentResponse, RuntimeHeuristics, } from './api/RecallBricksClient';
|
|
12
|
+
export { buildConfigFromEnv, buildConfigFromOptions, createLogger, ConfigBuilder, } from './config';
|
|
13
|
+
export * from './types';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,YAAY,EAAE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EACV,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,YAAY,EACV,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,aAAa,GACd,MAAM,UAAU,CAAC;AAGlB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ConfigBuilder = exports.createLogger = exports.buildConfigFromOptions = exports.buildConfigFromEnv = exports.RecallBricksClient = exports.ReflectionEngine = exports.IdentityValidator = exports.AutoSaver = exports.ContextWeaver = exports.ContextLoader = exports.LLMAdapter = exports.AgentRuntime = void 0;
|
|
18
|
+
var AgentRuntime_1 = require("./core/AgentRuntime");
|
|
19
|
+
Object.defineProperty(exports, "AgentRuntime", { enumerable: true, get: function () { return AgentRuntime_1.AgentRuntime; } });
|
|
20
|
+
var LLMAdapter_1 = require("./core/LLMAdapter");
|
|
21
|
+
Object.defineProperty(exports, "LLMAdapter", { enumerable: true, get: function () { return LLMAdapter_1.LLMAdapter; } });
|
|
22
|
+
var ContextLoader_1 = require("./core/ContextLoader");
|
|
23
|
+
Object.defineProperty(exports, "ContextLoader", { enumerable: true, get: function () { return ContextLoader_1.ContextLoader; } });
|
|
24
|
+
var ContextWeaver_1 = require("./core/ContextWeaver");
|
|
25
|
+
Object.defineProperty(exports, "ContextWeaver", { enumerable: true, get: function () { return ContextWeaver_1.ContextWeaver; } });
|
|
26
|
+
var AutoSaver_1 = require("./core/AutoSaver");
|
|
27
|
+
Object.defineProperty(exports, "AutoSaver", { enumerable: true, get: function () { return AutoSaver_1.AutoSaver; } });
|
|
28
|
+
var IdentityValidator_1 = require("./core/IdentityValidator");
|
|
29
|
+
Object.defineProperty(exports, "IdentityValidator", { enumerable: true, get: function () { return IdentityValidator_1.IdentityValidator; } });
|
|
30
|
+
var ReflectionEngine_1 = require("./core/ReflectionEngine");
|
|
31
|
+
Object.defineProperty(exports, "ReflectionEngine", { enumerable: true, get: function () { return ReflectionEngine_1.ReflectionEngine; } });
|
|
32
|
+
var RecallBricksClient_1 = require("./api/RecallBricksClient");
|
|
33
|
+
Object.defineProperty(exports, "RecallBricksClient", { enumerable: true, get: function () { return RecallBricksClient_1.RecallBricksClient; } });
|
|
34
|
+
var config_1 = require("./config");
|
|
35
|
+
Object.defineProperty(exports, "buildConfigFromEnv", { enumerable: true, get: function () { return config_1.buildConfigFromEnv; } });
|
|
36
|
+
Object.defineProperty(exports, "buildConfigFromOptions", { enumerable: true, get: function () { return config_1.buildConfigFromOptions; } });
|
|
37
|
+
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return config_1.createLogger; } });
|
|
38
|
+
Object.defineProperty(exports, "ConfigBuilder", { enumerable: true, get: function () { return config_1.ConfigBuilder; } });
|
|
39
|
+
__exportStar(require("./types"), exports);
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAQA,oDAAmD;AAA1C,4GAAA,YAAY,OAAA;AACrB,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AACnB,sDAAqD;AAA5C,8GAAA,aAAa,OAAA;AACtB,sDAAqD;AAA5C,8GAAA,aAAa,OAAA;AAEtB,8CAA6C;AAApC,sGAAA,SAAS,OAAA;AAClB,8DAA6D;AAApD,sHAAA,iBAAiB,OAAA;AAC1B,4DAA2D;AAAlD,oHAAA,gBAAgB,OAAA;AAUzB,+DAA8D;AAArD,wHAAA,kBAAkB,OAAA;AAW3B,mCAKkB;AAJhB,4GAAA,kBAAkB,OAAA;AAClB,gHAAA,sBAAsB,OAAA;AACtB,sGAAA,YAAY,OAAA;AACZ,uGAAA,aAAa,OAAA;AAIf,0CAAwB"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
export type LLMProvider = 'anthropic' | 'openai' | 'gemini' | 'ollama' | 'cohere' | 'local';
|
|
2
|
+
export type RecallBricksTier = 'starter' | 'professional' | 'enterprise';
|
|
3
|
+
export interface LLMMessage {
|
|
4
|
+
role: 'user' | 'assistant' | 'system';
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
export interface LLMResponse {
|
|
8
|
+
content: string;
|
|
9
|
+
provider: LLMProvider;
|
|
10
|
+
model: string;
|
|
11
|
+
usage?: {
|
|
12
|
+
promptTokens: number;
|
|
13
|
+
completionTokens: number;
|
|
14
|
+
totalTokens: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface LLMConfig {
|
|
18
|
+
provider: LLMProvider;
|
|
19
|
+
apiKey: string;
|
|
20
|
+
model?: string;
|
|
21
|
+
temperature?: number;
|
|
22
|
+
maxTokens?: number;
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AgentIdentity {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
purpose: string;
|
|
29
|
+
traits: string[];
|
|
30
|
+
rules: string[];
|
|
31
|
+
createdAt: string;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
}
|
|
34
|
+
export interface AgentBehavioralRule {
|
|
35
|
+
rule: string;
|
|
36
|
+
priority: number;
|
|
37
|
+
enforced: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface Memory {
|
|
40
|
+
id: string;
|
|
41
|
+
content: string;
|
|
42
|
+
type: 'conversation' | 'fact' | 'observation' | 'insight';
|
|
43
|
+
importance: number;
|
|
44
|
+
timestamp: string;
|
|
45
|
+
metadata?: Record<string, unknown>;
|
|
46
|
+
tags?: string[];
|
|
47
|
+
}
|
|
48
|
+
export interface MemoryContext {
|
|
49
|
+
recentMemories: Memory[];
|
|
50
|
+
relevantMemories: Memory[];
|
|
51
|
+
predictedContext: string[];
|
|
52
|
+
totalMemories: number;
|
|
53
|
+
lastUpdated: string;
|
|
54
|
+
}
|
|
55
|
+
export interface ConversationTurn {
|
|
56
|
+
userMessage: string;
|
|
57
|
+
assistantResponse: string;
|
|
58
|
+
timestamp: string;
|
|
59
|
+
importance?: number;
|
|
60
|
+
}
|
|
61
|
+
export interface RuntimeConfig {
|
|
62
|
+
agentId: string;
|
|
63
|
+
userId: string;
|
|
64
|
+
agentName?: string;
|
|
65
|
+
agentPurpose?: string;
|
|
66
|
+
apiUrl?: string;
|
|
67
|
+
apiKey?: string;
|
|
68
|
+
llmConfig?: LLMConfig;
|
|
69
|
+
tier?: RecallBricksTier;
|
|
70
|
+
autoSave?: boolean;
|
|
71
|
+
validateIdentity?: boolean;
|
|
72
|
+
cacheEnabled?: boolean;
|
|
73
|
+
cacheTTL?: number;
|
|
74
|
+
maxContextTokens?: number;
|
|
75
|
+
debug?: boolean;
|
|
76
|
+
mcpMode?: boolean;
|
|
77
|
+
registerAgent?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export interface RuntimeOptions {
|
|
80
|
+
agentId: string;
|
|
81
|
+
userId: string;
|
|
82
|
+
agentName?: string;
|
|
83
|
+
agentPurpose?: string;
|
|
84
|
+
apiUrl?: string;
|
|
85
|
+
apiKey?: string;
|
|
86
|
+
llmProvider?: LLMProvider;
|
|
87
|
+
llmApiKey?: string;
|
|
88
|
+
llmModel?: string;
|
|
89
|
+
tier?: RecallBricksTier;
|
|
90
|
+
autoSave?: boolean;
|
|
91
|
+
validateIdentity?: boolean;
|
|
92
|
+
cacheEnabled?: boolean;
|
|
93
|
+
cacheTTL?: number;
|
|
94
|
+
maxContextTokens?: number;
|
|
95
|
+
debug?: boolean;
|
|
96
|
+
mcpMode?: boolean;
|
|
97
|
+
registerAgent?: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface SaveConversationRequest {
|
|
100
|
+
agentId: string;
|
|
101
|
+
userId: string;
|
|
102
|
+
userMessage: string;
|
|
103
|
+
assistantResponse: string;
|
|
104
|
+
importance?: number;
|
|
105
|
+
metadata?: Record<string, unknown>;
|
|
106
|
+
}
|
|
107
|
+
export interface SaveConversationResponse {
|
|
108
|
+
success: boolean;
|
|
109
|
+
memoryId?: string;
|
|
110
|
+
importance?: number;
|
|
111
|
+
message?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface GetContextRequest {
|
|
114
|
+
agentId: string;
|
|
115
|
+
userId: string;
|
|
116
|
+
limit?: number;
|
|
117
|
+
includeRelevant?: boolean;
|
|
118
|
+
includePredicted?: boolean;
|
|
119
|
+
}
|
|
120
|
+
export interface GetContextResponse {
|
|
121
|
+
identity: AgentIdentity;
|
|
122
|
+
context: MemoryContext;
|
|
123
|
+
}
|
|
124
|
+
export interface GetIdentityRequest {
|
|
125
|
+
agentId: string;
|
|
126
|
+
}
|
|
127
|
+
export interface GetIdentityResponse {
|
|
128
|
+
identity: AgentIdentity;
|
|
129
|
+
}
|
|
130
|
+
export interface IdentityViolation {
|
|
131
|
+
type: 'base_model_reference' | 'inconsistent_behavior' | 'identity_leak';
|
|
132
|
+
detected: string;
|
|
133
|
+
suggestion: string;
|
|
134
|
+
severity: 'low' | 'medium' | 'high';
|
|
135
|
+
}
|
|
136
|
+
export interface ValidationResult {
|
|
137
|
+
isValid: boolean;
|
|
138
|
+
violations: IdentityViolation[];
|
|
139
|
+
correctedResponse?: string;
|
|
140
|
+
}
|
|
141
|
+
export interface ImportanceClassification {
|
|
142
|
+
importance: number;
|
|
143
|
+
reasoning: string;
|
|
144
|
+
model: string;
|
|
145
|
+
}
|
|
146
|
+
export interface SaveMetadata {
|
|
147
|
+
classified: boolean;
|
|
148
|
+
importance: number;
|
|
149
|
+
isDuplicate: boolean;
|
|
150
|
+
timestamp: string;
|
|
151
|
+
}
|
|
152
|
+
export interface ContextPrompt {
|
|
153
|
+
systemPrompt: string;
|
|
154
|
+
identitySection: string;
|
|
155
|
+
memorySection: string;
|
|
156
|
+
rulesSection: string;
|
|
157
|
+
}
|
|
158
|
+
export interface CacheEntry<T> {
|
|
159
|
+
data: T;
|
|
160
|
+
timestamp: number;
|
|
161
|
+
ttl: number;
|
|
162
|
+
}
|
|
163
|
+
export declare class RecallBricksError extends Error {
|
|
164
|
+
code: string;
|
|
165
|
+
statusCode?: number | undefined;
|
|
166
|
+
details?: unknown | undefined;
|
|
167
|
+
constructor(message: string, code: string, statusCode?: number | undefined, details?: unknown | undefined);
|
|
168
|
+
}
|
|
169
|
+
export declare class APIError extends RecallBricksError {
|
|
170
|
+
constructor(message: string, statusCode: number, details?: unknown);
|
|
171
|
+
}
|
|
172
|
+
export declare class ConfigurationError extends RecallBricksError {
|
|
173
|
+
constructor(message: string, details?: unknown);
|
|
174
|
+
}
|
|
175
|
+
export declare class LLMError extends RecallBricksError {
|
|
176
|
+
constructor(message: string, provider: LLMProvider, details?: unknown);
|
|
177
|
+
}
|
|
178
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
179
|
+
export interface Logger {
|
|
180
|
+
debug(message: string, meta?: unknown): void;
|
|
181
|
+
info(message: string, meta?: unknown): void;
|
|
182
|
+
warn(message: string, meta?: unknown): void;
|
|
183
|
+
error(message: string, meta?: unknown): void;
|
|
184
|
+
}
|
|
185
|
+
export interface ChatRequest {
|
|
186
|
+
message: string;
|
|
187
|
+
conversationHistory?: LLMMessage[];
|
|
188
|
+
streamResponse?: boolean;
|
|
189
|
+
}
|
|
190
|
+
export interface ChatResponse {
|
|
191
|
+
response: string;
|
|
192
|
+
metadata: {
|
|
193
|
+
provider: LLMProvider;
|
|
194
|
+
model: string;
|
|
195
|
+
contextLoaded: boolean;
|
|
196
|
+
identityValidated: boolean;
|
|
197
|
+
autoSaved: boolean;
|
|
198
|
+
tokensUsed?: number;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
export interface CircuitBreakerConfig {
|
|
202
|
+
failureThreshold: number;
|
|
203
|
+
resetTimeout: number;
|
|
204
|
+
monitorInterval: number;
|
|
205
|
+
}
|
|
206
|
+
export type CircuitState = 'closed' | 'open' | 'half-open';
|
|
207
|
+
export interface CircuitBreakerState {
|
|
208
|
+
state: CircuitState;
|
|
209
|
+
failures: number;
|
|
210
|
+
lastFailureTime?: number;
|
|
211
|
+
nextRetryTime?: number;
|
|
212
|
+
}
|
|
213
|
+
export interface SaveResponse {
|
|
214
|
+
id: string;
|
|
215
|
+
text: string;
|
|
216
|
+
user_id: string;
|
|
217
|
+
metadata?: {
|
|
218
|
+
tags?: string[];
|
|
219
|
+
category?: string;
|
|
220
|
+
importance?: number;
|
|
221
|
+
source?: string;
|
|
222
|
+
};
|
|
223
|
+
created_at: string;
|
|
224
|
+
}
|
|
225
|
+
export interface LearnResponse {
|
|
226
|
+
id: string;
|
|
227
|
+
text: string;
|
|
228
|
+
metadata: {
|
|
229
|
+
tags: string[];
|
|
230
|
+
category: string;
|
|
231
|
+
entities: string[];
|
|
232
|
+
importance: number;
|
|
233
|
+
summary: string;
|
|
234
|
+
};
|
|
235
|
+
created_at: string;
|
|
236
|
+
}
|
|
237
|
+
export interface RecallMemory {
|
|
238
|
+
id: string;
|
|
239
|
+
text: string;
|
|
240
|
+
score: number;
|
|
241
|
+
metadata: {
|
|
242
|
+
tags: string[];
|
|
243
|
+
category: string;
|
|
244
|
+
importance: number;
|
|
245
|
+
summary: string;
|
|
246
|
+
};
|
|
247
|
+
created_at: string;
|
|
248
|
+
}
|
|
249
|
+
export interface CategorySummary {
|
|
250
|
+
count: number;
|
|
251
|
+
avg_score: number;
|
|
252
|
+
summary: string;
|
|
253
|
+
}
|
|
254
|
+
export interface RecallResponse {
|
|
255
|
+
memories: RecallMemory[];
|
|
256
|
+
categories?: Record<string, CategorySummary>;
|
|
257
|
+
total: number;
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=index.d.ts.map
|