memento-mcp-server 1.14.0 → 1.15.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.
Files changed (77) hide show
  1. package/dist/domains/memory/tools/convert-episodic-to-semantic-tool.d.ts +18 -0
  2. package/dist/domains/memory/tools/convert-episodic-to-semantic-tool.d.ts.map +1 -0
  3. package/dist/domains/memory/tools/convert-episodic-to-semantic-tool.js +346 -0
  4. package/dist/domains/memory/tools/convert-episodic-to-semantic-tool.js.map +1 -0
  5. package/dist/domains/memory/tools/remember-tool.d.ts.map +1 -1
  6. package/dist/domains/memory/tools/remember-tool.js +182 -1
  7. package/dist/domains/memory/tools/remember-tool.js.map +1 -1
  8. package/dist/infrastructure/database/database/migration/migrations/005-relation-engine-schema.sql +7 -7
  9. package/dist/infrastructure/database/database/migration/migrations/008-arigraph-schema-expansion.d.ts +65 -0
  10. package/dist/infrastructure/database/database/migration/migrations/008-arigraph-schema-expansion.d.ts.map +1 -0
  11. package/dist/infrastructure/database/database/migration/migrations/008-arigraph-schema-expansion.js +250 -0
  12. package/dist/infrastructure/database/database/migration/migrations/008-arigraph-schema-expansion.js.map +1 -0
  13. package/dist/infrastructure/database/database/migration/migrations/008-arigraph-schema-expansion.sql +86 -0
  14. package/dist/infrastructure/logging/triple-extraction-logger.d.ts +92 -0
  15. package/dist/infrastructure/logging/triple-extraction-logger.d.ts.map +1 -0
  16. package/dist/infrastructure/logging/triple-extraction-logger.js +194 -0
  17. package/dist/infrastructure/logging/triple-extraction-logger.js.map +1 -0
  18. package/dist/infrastructure/scheduler/batch-scheduler.d.ts +57 -0
  19. package/dist/infrastructure/scheduler/batch-scheduler.d.ts.map +1 -1
  20. package/dist/infrastructure/scheduler/batch-scheduler.js +220 -0
  21. package/dist/infrastructure/scheduler/batch-scheduler.js.map +1 -1
  22. package/dist/infrastructure/scheduler/jobs/triple-extraction-batch-job.d.ts +194 -0
  23. package/dist/infrastructure/scheduler/jobs/triple-extraction-batch-job.d.ts.map +1 -0
  24. package/dist/infrastructure/scheduler/jobs/triple-extraction-batch-job.js +639 -0
  25. package/dist/infrastructure/scheduler/jobs/triple-extraction-batch-job.js.map +1 -0
  26. package/dist/services/semantic-memory/semantic-memory-statistics.d.ts +64 -0
  27. package/dist/services/semantic-memory/semantic-memory-statistics.d.ts.map +1 -0
  28. package/dist/services/semantic-memory/semantic-memory-statistics.js +113 -0
  29. package/dist/services/semantic-memory/semantic-memory-statistics.js.map +1 -0
  30. package/dist/services/semantic-memory/semantic-memory-update-service.d.ts +257 -0
  31. package/dist/services/semantic-memory/semantic-memory-update-service.d.ts.map +1 -0
  32. package/dist/services/semantic-memory/semantic-memory-update-service.js +696 -0
  33. package/dist/services/semantic-memory/semantic-memory-update-service.js.map +1 -0
  34. package/dist/services/triple-extraction/entity-linker.d.ts +55 -0
  35. package/dist/services/triple-extraction/entity-linker.d.ts.map +1 -0
  36. package/dist/services/triple-extraction/entity-linker.js +154 -0
  37. package/dist/services/triple-extraction/entity-linker.js.map +1 -0
  38. package/dist/services/triple-extraction/predicate-canonicalizer.d.ts +63 -0
  39. package/dist/services/triple-extraction/predicate-canonicalizer.d.ts.map +1 -0
  40. package/dist/services/triple-extraction/predicate-canonicalizer.js +166 -0
  41. package/dist/services/triple-extraction/predicate-canonicalizer.js.map +1 -0
  42. package/dist/services/triple-extraction/triple-extraction-service.d.ts +181 -0
  43. package/dist/services/triple-extraction/triple-extraction-service.d.ts.map +1 -0
  44. package/dist/services/triple-extraction/triple-extraction-service.js +907 -0
  45. package/dist/services/triple-extraction/triple-extraction-service.js.map +1 -0
  46. package/dist/services/triple-extraction/triple-extraction-statistics.d.ts +74 -0
  47. package/dist/services/triple-extraction/triple-extraction-statistics.d.ts.map +1 -0
  48. package/dist/services/triple-extraction/triple-extraction-statistics.js +146 -0
  49. package/dist/services/triple-extraction/triple-extraction-statistics.js.map +1 -0
  50. package/dist/shared/types/index.d.ts +1 -0
  51. package/dist/shared/types/index.d.ts.map +1 -1
  52. package/dist/shared/types/index.js.map +1 -1
  53. package/dist/shared/types/triple-extraction.d.ts +99 -0
  54. package/dist/shared/types/triple-extraction.d.ts.map +1 -0
  55. package/dist/shared/types/triple-extraction.js +6 -0
  56. package/dist/shared/types/triple-extraction.js.map +1 -0
  57. package/dist/shared/utils/pii-masker.d.ts +67 -0
  58. package/dist/shared/utils/pii-masker.d.ts.map +1 -0
  59. package/dist/shared/utils/pii-masker.js +205 -0
  60. package/dist/shared/utils/pii-masker.js.map +1 -0
  61. package/dist/shared/utils/prompt-template-loader.d.ts +42 -0
  62. package/dist/shared/utils/prompt-template-loader.d.ts.map +1 -0
  63. package/dist/shared/utils/prompt-template-loader.js +92 -0
  64. package/dist/shared/utils/prompt-template-loader.js.map +1 -0
  65. package/dist/shared/utils/triple-cache.d.ts +90 -0
  66. package/dist/shared/utils/triple-cache.d.ts.map +1 -0
  67. package/dist/shared/utils/triple-cache.js +124 -0
  68. package/dist/shared/utils/triple-cache.js.map +1 -0
  69. package/dist/tools/index.d.ts +2 -1
  70. package/dist/tools/index.d.ts.map +1 -1
  71. package/dist/tools/index.js +3 -1
  72. package/dist/tools/index.js.map +1 -1
  73. package/dist/tools/types.d.ts +1 -0
  74. package/dist/tools/types.d.ts.map +1 -1
  75. package/dist/tools/types.js +2 -0
  76. package/dist/tools/types.js.map +1 -1
  77. package/package.json +1 -1
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Convert Episodic to Semantic Tool - Episodic Memory를 Semantic Memory로 변환하는 도구
3
+ *
4
+ * AriGraph Pipeline의 수동 변환 기능을 제공합니다.
5
+ * 기존 Episodic Memory에 대해 Triple 추출 및 Semantic Memory 생성을 수행합니다.
6
+ */
7
+ import { BaseTool } from '../../../tools/base-tool.js';
8
+ import type { ToolContext, ToolResult } from '../../../tools/types.js';
9
+ export declare class ConvertEpisodicToSemanticTool extends BaseTool {
10
+ constructor();
11
+ /**
12
+ * Given: memory_id 또는 필터 조건
13
+ * When: convert_episodic_to_semantic 호출
14
+ * Then: Triple 추출 및 Semantic Memory 생성 결과 반환
15
+ */
16
+ handle(params: any, context: ToolContext): Promise<ToolResult>;
17
+ }
18
+ //# sourceMappingURL=convert-episodic-to-semantic-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-episodic-to-semantic-tool.d.ts","sourceRoot":"","sources":["../../../../src/domains/memory/tools/convert-episodic-to-semantic-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAkBvE,qBAAa,6BAA8B,SAAQ,QAAQ;;IAmCzD;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CAuVrE"}
@@ -0,0 +1,346 @@
1
+ /**
2
+ * Convert Episodic to Semantic Tool - Episodic Memory를 Semantic Memory로 변환하는 도구
3
+ *
4
+ * AriGraph Pipeline의 수동 변환 기능을 제공합니다.
5
+ * 기존 Episodic Memory에 대해 Triple 추출 및 Semantic Memory 생성을 수행합니다.
6
+ */
7
+ import { z } from 'zod';
8
+ import { BaseTool } from '../../../tools/base-tool.js';
9
+ import { DatabaseUtils } from '../../../shared/utils/database.js';
10
+ import { TripleExtractionService } from '../../../services/triple-extraction/triple-extraction-service.js';
11
+ import { SemanticMemoryUpdateService } from '../../../services/semantic-memory/semantic-memory-update-service.js';
12
+ import { logger } from '../../../shared/utils/logger.js';
13
+ import { UnifiedEmbeddingService } from '../../../domains/embedding/services/unified-embedding-service.js';
14
+ /**
15
+ * Convert Episodic to Semantic 스키마
16
+ */
17
+ const ConvertEpisodicToSemanticSchema = z.object({
18
+ memory_id: z.string().optional(), // 단일 Episodic Memory ID (선택)
19
+ // 필터 조건 (memory_id가 없을 때 사용)
20
+ skip_converted: z.boolean().default(true).optional(), // 이미 변환된 항목 건너뛰기 (기본값: true)
21
+ retry_failed: z.boolean().default(false).optional(), // 실패한 항목 재시도 (기본값: false)
22
+ limit: z.number().min(1).max(100).default(10).optional(), // 배치 처리 시 최대 개수 (기본값: 10)
23
+ });
24
+ export class ConvertEpisodicToSemanticTool extends BaseTool {
25
+ constructor() {
26
+ super('convert_episodic_to_semantic', '기존 Episodic Memory를 Semantic Memory로 변환합니다. Triple 추출 및 Semantic Memory 생성을 수행합니다.', {
27
+ type: 'object',
28
+ properties: {
29
+ memory_id: {
30
+ type: 'string',
31
+ description: '변환할 Episodic Memory ID (단일 변환 시 사용, 선택)'
32
+ },
33
+ skip_converted: {
34
+ type: 'boolean',
35
+ description: '이미 변환된 항목 건너뛰기 여부 (기본값: true)',
36
+ default: true
37
+ },
38
+ retry_failed: {
39
+ type: 'boolean',
40
+ description: '실패한 항목 재시도 여부 (기본값: false)',
41
+ default: false
42
+ },
43
+ limit: {
44
+ type: 'number',
45
+ minimum: 1,
46
+ maximum: 100,
47
+ description: '배치 처리 시 최대 개수 (기본값: 10)',
48
+ default: 10
49
+ }
50
+ },
51
+ required: [] // memory_id 또는 필터 조건 중 하나는 필수
52
+ });
53
+ }
54
+ /**
55
+ * Given: memory_id 또는 필터 조건
56
+ * When: convert_episodic_to_semantic 호출
57
+ * Then: Triple 추출 및 Semantic Memory 생성 결과 반환
58
+ */
59
+ async handle(params, context) {
60
+ try {
61
+ const { memory_id, skip_converted = true, retry_failed = false, limit = 10 } = ConvertEpisodicToSemanticSchema.parse(params);
62
+ const db = context.db;
63
+ if (!db) {
64
+ return this.createErrorResult('DATABASE_NOT_AVAILABLE', '데이터베이스가 사용 가능하지 않습니다');
65
+ }
66
+ // PRD 5.9: 수동 변환 로직 구현
67
+ // 선택된 Episodic Memory에 대해 Triple 추출 및 Semantic Memory 생성
68
+ let episodicMemories = [];
69
+ if (memory_id) {
70
+ // 단일 Episodic Memory 변환
71
+ // skip_converted 옵션 확인
72
+ let memory;
73
+ // 먼저 메모리 존재 여부 확인
74
+ const memoryExists = DatabaseUtils.get(db, `
75
+ SELECT id, triple_extracted, triple_extracted_status FROM memory_item
76
+ WHERE id = ? AND type = 'episodic'
77
+ `, [memory_id]);
78
+ if (!memoryExists) {
79
+ // 메모리가 존재하지 않는 경우
80
+ return this.createErrorResult('MEMORY_NOT_FOUND', `Episodic Memory를 찾을 수 없습니다: ${memory_id}`);
81
+ }
82
+ // skip_converted=true이고 이미 변환된 경우 skipped로 처리
83
+ if (skip_converted && memoryExists.triple_extracted === 1 && memoryExists.triple_extracted_status === 'success') {
84
+ return this.createSuccessResult({
85
+ total: 1,
86
+ success: 0,
87
+ failed: 0,
88
+ skipped: 1,
89
+ semantic_memory_ids: []
90
+ });
91
+ }
92
+ // skip_converted=true인 경우: 이미 변환된 항목은 조회하지 않음
93
+ if (skip_converted) {
94
+ memory = DatabaseUtils.get(db, `
95
+ SELECT id, content, importance, triple_extracted, triple_extracted_status FROM memory_item
96
+ WHERE id = ? AND type = 'episodic'
97
+ AND (triple_extracted IS NULL OR triple_extracted = 0)
98
+ `, [memory_id]);
99
+ }
100
+ else {
101
+ memory = DatabaseUtils.get(db, `
102
+ SELECT id, content, importance, triple_extracted, triple_extracted_status FROM memory_item
103
+ WHERE id = ? AND type = 'episodic'
104
+ `, [memory_id]);
105
+ }
106
+ if (!memory) {
107
+ // skip_converted=true이고 이미 변환된 경우 (위에서 처리했지만 이중 검증)
108
+ if (skip_converted) {
109
+ return this.createSuccessResult({
110
+ total: 1,
111
+ success: 0,
112
+ failed: 0,
113
+ skipped: 1,
114
+ semantic_memory_ids: []
115
+ });
116
+ }
117
+ // 이 경우는 발생하지 않아야 하지만 안전을 위해
118
+ return this.createErrorResult('MEMORY_NOT_FOUND', `Episodic Memory를 찾을 수 없습니다: ${memory_id}`);
119
+ }
120
+ episodicMemories = [{ id: memory.id, content: memory.content, importance: memory.importance }];
121
+ }
122
+ else {
123
+ // PRD 5.10: 배치 처리 지원 - 필터 조건에 따라 Episodic Memory 조회
124
+ // PRD 5.11: 변환 상태 추적 로직 (이미 변환된 항목 건너뛰기, 실패한 항목 재시도 옵션)
125
+ // WHERE 조건 구성
126
+ const conditions = ["type = 'episodic'"];
127
+ const params = [];
128
+ // skip_converted=true인 경우: 이미 변환된 항목 건너뛰기
129
+ // triple_extracted IS NULL (미처리) 또는 triple_extracted = 0 (실패)
130
+ if (skip_converted) {
131
+ conditions.push("(triple_extracted IS NULL OR triple_extracted = 0)");
132
+ }
133
+ // retry_failed 옵션에 따른 조건 추가
134
+ if (retry_failed) {
135
+ // 실패한 항목 재시도: triple_extracted_status='failed' 포함
136
+ // skip_converted와 함께 사용 시 실패한 항목만 재시도
137
+ if (skip_converted) {
138
+ conditions.push("triple_extracted_status = 'failed'");
139
+ }
140
+ }
141
+ else {
142
+ // retry_failed=false인 경우: 실패한 항목 제외
143
+ conditions.push("(triple_extracted_status IS NULL OR triple_extracted_status != 'failed')");
144
+ }
145
+ // 포기된 항목은 제외 (수동 재시도 필요)
146
+ conditions.push("(triple_extracted_status IS NULL OR triple_extracted_status != 'abandoned')");
147
+ // 쿼리 실행
148
+ const query = `
149
+ SELECT id, content, importance FROM memory_item
150
+ WHERE ${conditions.join(' AND ')}
151
+ ORDER BY created_at ASC
152
+ LIMIT ?
153
+ `;
154
+ params.push(limit);
155
+ episodicMemories = DatabaseUtils.all(db, query, params);
156
+ if (episodicMemories.length === 0) {
157
+ return this.createSuccessResult({
158
+ total: 0,
159
+ success: 0,
160
+ failed: 0,
161
+ skipped: 0,
162
+ semantic_memory_ids: [],
163
+ message: '변환할 Episodic Memory가 없습니다.'
164
+ });
165
+ }
166
+ }
167
+ // 변환 결과 추적
168
+ const results = {
169
+ total: episodicMemories.length,
170
+ success: 0,
171
+ failed: 0,
172
+ skipped: 0,
173
+ semantic_memory_ids: []
174
+ };
175
+ // 각 Episodic Memory에 대해 Triple 추출 및 Semantic Memory 생성
176
+ for (const episodicMemory of episodicMemories) {
177
+ try {
178
+ // PRD 5.11: 변환 상태 추적 로직
179
+ // 이미 변환된 항목 건너뛰기 (skip_converted=true인 경우 쿼리에서 이미 필터링됨)
180
+ // 하지만 안전을 위해 한 번 더 확인
181
+ if (skip_converted) {
182
+ const existing = DatabaseUtils.get(db, `
183
+ SELECT triple_extracted, triple_extracted_status FROM memory_item WHERE id = ?
184
+ `, [episodicMemory.id]);
185
+ if (existing?.triple_extracted === true && existing?.triple_extracted_status === 'success') {
186
+ results.skipped++;
187
+ logger.info('이미 변환된 Episodic Memory 건너뛰기', {
188
+ episodic_memory_id: episodicMemory.id
189
+ });
190
+ continue;
191
+ }
192
+ }
193
+ // Triple 추출 서비스 초기화
194
+ const tripleExtractionService = new TripleExtractionService();
195
+ // Triple 추출
196
+ const extractionResult = await tripleExtractionService.extractTriples(episodicMemory.content, {}, episodicMemory.id);
197
+ // Triple이 추출된 경우 Semantic Memory 생성/업데이트
198
+ if (extractionResult.triples.length > 0) {
199
+ const embeddingService = context.services.embeddingService || new UnifiedEmbeddingService();
200
+ const semanticMemoryUpdateService = new SemanticMemoryUpdateService(db, embeddingService, context.services.relationGraph);
201
+ const updateResult = await semanticMemoryUpdateService.updateSemanticMemory(extractionResult, {
202
+ episodicMemoryId: episodicMemory.id,
203
+ episodicImportance: episodicMemory.importance || 0.5
204
+ });
205
+ // PRD 5.5, 5.5a, 5.6: Triple 추출 성공 시 상태 업데이트
206
+ const confidenceValues = [];
207
+ try {
208
+ const relations = DatabaseUtils.all(db, `
209
+ SELECT confidence FROM memory_relation
210
+ WHERE source_id = ? AND relation_type = 'extracted_from'
211
+ `, [episodicMemory.id]);
212
+ for (const rel of relations) {
213
+ if (rel.confidence !== null && rel.confidence !== undefined) {
214
+ confidenceValues.push(rel.confidence);
215
+ }
216
+ }
217
+ }
218
+ catch (err) {
219
+ logger.warn('Confidence 수집 실패', {
220
+ memory_id: episodicMemory.id,
221
+ error: err instanceof Error ? err.message : String(err)
222
+ });
223
+ }
224
+ const confidenceAvg = confidenceValues.length > 0
225
+ ? confidenceValues.reduce((sum, c) => sum + c, 0) / confidenceValues.length
226
+ : null;
227
+ const metadata = {
228
+ triple_count: extractionResult.triples.length,
229
+ ...(confidenceAvg !== null && { confidence_avg: confidenceAvg }),
230
+ extracted_at: new Date().toISOString()
231
+ };
232
+ await DatabaseUtils.run(db, `
233
+ UPDATE memory_item SET
234
+ triple_extracted = ?,
235
+ triple_extracted_status = ?,
236
+ triple_extraction_metadata = ?
237
+ WHERE id = ?
238
+ `, [
239
+ 1, // SQLite에서는 boolean을 INTEGER로 변환
240
+ 'success',
241
+ JSON.stringify(metadata),
242
+ episodicMemory.id
243
+ ]);
244
+ results.success++;
245
+ results.semantic_memory_ids.push(...updateResult.semanticMemoryIds);
246
+ logger.info('Episodic Memory 변환 성공', {
247
+ episodic_memory_id: episodicMemory.id,
248
+ triple_count: extractionResult.triples.length,
249
+ semantic_memory_count: updateResult.semanticMemoryIds.length,
250
+ confidence_avg: confidenceAvg
251
+ });
252
+ }
253
+ else {
254
+ // Triple 추출 실패 시 상태 업데이트
255
+ const failureReason = extractionResult.extractionInfo.failureReason || 'no_triple';
256
+ let retryCount = 0;
257
+ try {
258
+ const existing = DatabaseUtils.get(db, `
259
+ SELECT triple_extraction_metadata FROM memory_item WHERE id = ?
260
+ `, [episodicMemory.id]);
261
+ if (existing?.triple_extraction_metadata) {
262
+ const existingMeta = JSON.parse(existing.triple_extraction_metadata);
263
+ retryCount = (existingMeta.retry_count || 0) + 1;
264
+ }
265
+ else {
266
+ retryCount = 1;
267
+ }
268
+ }
269
+ catch (err) {
270
+ retryCount = 1;
271
+ }
272
+ const metadata = {
273
+ failureReason,
274
+ retry_count: retryCount,
275
+ last_attempt: new Date().toISOString()
276
+ };
277
+ await DatabaseUtils.run(db, `
278
+ UPDATE memory_item SET
279
+ triple_extracted = ?,
280
+ triple_extracted_status = ?,
281
+ triple_extraction_metadata = ?
282
+ WHERE id = ?
283
+ `, [
284
+ 0, // SQLite에서는 boolean을 INTEGER로 변환
285
+ 'failed',
286
+ JSON.stringify(metadata),
287
+ episodicMemory.id
288
+ ]);
289
+ results.failed++;
290
+ logger.warn('Episodic Memory 변환 실패', {
291
+ episodic_memory_id: episodicMemory.id,
292
+ failure_reason: failureReason,
293
+ retry_count: retryCount
294
+ });
295
+ }
296
+ }
297
+ catch (error) {
298
+ results.failed++;
299
+ // 에러 발생 시에도 상태 업데이트 (PRD 5.5, 5.5a, 5.6)
300
+ try {
301
+ await DatabaseUtils.run(db, `
302
+ UPDATE memory_item SET
303
+ triple_extracted = ?,
304
+ triple_extracted_status = ?,
305
+ triple_extraction_metadata = ?
306
+ WHERE id = ?
307
+ `, [
308
+ 0, // SQLite에서는 boolean을 INTEGER로 변환
309
+ 'failed',
310
+ JSON.stringify({
311
+ failureReason: 'conversion_error',
312
+ error: error instanceof Error ? error.message : String(error),
313
+ last_attempt: new Date().toISOString()
314
+ }),
315
+ episodicMemory.id
316
+ ]);
317
+ }
318
+ catch (updateError) {
319
+ logger.warn('상태 업데이트 실패', {
320
+ episodic_memory_id: episodicMemory.id,
321
+ error: updateError instanceof Error ? updateError.message : String(updateError)
322
+ });
323
+ }
324
+ logger.error('Episodic Memory 변환 중 에러 발생', {
325
+ episodic_memory_id: episodicMemory.id,
326
+ error: error instanceof Error ? error.message : String(error)
327
+ });
328
+ }
329
+ }
330
+ return this.createSuccessResult({
331
+ total: results.total,
332
+ success: results.success,
333
+ failed: results.failed,
334
+ skipped: results.skipped,
335
+ semantic_memory_ids: results.semantic_memory_ids
336
+ });
337
+ }
338
+ catch (error) {
339
+ logger.error('ConvertEpisodicToSemanticTool: 에러 발생', {
340
+ error: error instanceof Error ? error.message : String(error)
341
+ });
342
+ return this.createErrorResult('CONVERSION_ERROR', error instanceof Error ? error.message : String(error));
343
+ }
344
+ }
345
+ }
346
+ //# sourceMappingURL=convert-episodic-to-semantic-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-episodic-to-semantic-tool.js","sourceRoot":"","sources":["../../../../src/domains/memory/tools/convert-episodic-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;;;;;;OAMG;IACH,OAAO,CAAC,2BAA2B;IASnC;;;;;;OAMG;YACW,0BAA0B;IA+CxC;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAkDtB,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IA+mBpE;;;;;;;;OAQG;YACW,4BAA4B;IA8D1C;;;;;;;OAOG;YACW,wCAAwC;IAqCtD;;;;;;OAMG;YACW,aAAa;CAmC5B"}
1
+ {"version":3,"file":"remember-tool.d.ts","sourceRoot":"","sources":["../../../../src/domains/memory/tools/remember-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AA8EvE,qBAAa,YAAa,SAAQ,QAAQ;;IAoGxC;;;;;;OAMG;IACH,OAAO,CAAC,2BAA2B;IASnC;;;;;;OAMG;YACW,0BAA0B;IA+CxC;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAkDtB,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IA2yBpE;;;;;;;;OAQG;YACW,4BAA4B;IA8D1C;;;;;;;OAOG;YACW,wCAAwC;IAqCtD;;;;;;OAMG;YACW,aAAa;CAmC5B"}
@@ -21,6 +21,10 @@ import { validateReflectionNotes, formatValidationErrors } from '../../../shared
21
21
  import { mergeReflectionNotes, serializeReflectionNotes } from '../../../shared/utils/reflection-notes-merge.js';
22
22
  import { validateProceduralMemoryFields } from '../../../shared/utils/type-param-validator.js';
23
23
  import { toDbRelationType } from '../../../shared/utils/relation-type-converter.js';
24
+ // AriGraph Pipeline
25
+ import { TripleExtractionService } from '../../../services/triple-extraction/triple-extraction-service.js';
26
+ import { SemanticMemoryUpdateService } from '../../../services/semantic-memory/semantic-memory-update-service.js';
27
+ import { getBatchScheduler } from '../../../infrastructure/scheduler/batch-scheduler.js';
24
28
  const RememberSchema = z.object({
25
29
  content: CommonSchemas.Content,
26
30
  type: CommonSchemas.MemoryType.optional(), // optional - validateTypeParam에서 기본값 처리
@@ -38,6 +42,8 @@ const RememberSchema = z.object({
38
42
  skill_name: CommonSchemas.SkillName,
39
43
  trigger_conditions: CommonSchemas.TriggerConditions,
40
44
  update_mode: CommonSchemas.UpdateMode,
45
+ // AriGraph Pipeline 필드
46
+ enable_triple_extraction: CommonSchemas.EnableTripleExtraction,
41
47
  // 기존 필드 유지
42
48
  tags: CommonSchemas.Tags,
43
49
  importance: CommonSchemas.Importance.default(0.5),
@@ -126,6 +132,12 @@ export class RememberTool extends BaseTool {
126
132
  enum: ['replace', 'incremental', 'versioned'],
127
133
  description: '업데이트 모드: replace (교체), incremental (증분), versioned (버전 관리)'
128
134
  },
135
+ // AriGraph Pipeline 필드
136
+ enable_triple_extraction: {
137
+ type: 'boolean',
138
+ description: 'Triple 추출 활성화 여부 (기본값: true). type="episodic"일 때만 적용됩니다.',
139
+ default: true
140
+ },
129
141
  // 기존 필드 유지
130
142
  tags: {
131
143
  type: 'array',
@@ -264,7 +276,7 @@ export class RememberTool extends BaseTool {
264
276
  async handle(params, context) {
265
277
  const startTime = Date.now();
266
278
  try {
267
- const { content, type: rawType, key, value, always_load, immutable, task_goal, steps, reflection_notes, workflow_name, skill_name, trigger_conditions, update_mode, tags, importance, source, privacy_scope } = RememberSchema.parse(params);
279
+ const { content, type: rawType, key, value, always_load, immutable, task_goal, steps, reflection_notes, workflow_name, skill_name, trigger_conditions, update_mode, enable_triple_extraction, tags, importance, source, privacy_scope } = RememberSchema.parse(params);
268
280
  // type 파라미터 롤아웃 모드 검증
269
281
  const typeParamMode = mementoConfig.typeParamMode;
270
282
  const typeValidation = validateTypeParam(rawType, typeParamMode, 'remember');
@@ -757,6 +769,175 @@ export class RememberTool extends BaseTool {
757
769
  error: error instanceof Error ? error.message : String(error)
758
770
  });
759
771
  }
772
+ // PRD 4.1, 5.3: AriGraph Pipeline - Triple 추출 및 Semantic Memory 생성
773
+ // type='episodic'이고 enable_triple_extraction=true일 때만 실행
774
+ // JobQueue를 통해 비동기로 실행 (Episodic Memory 저장은 블로킹하지 않음)
775
+ if (savedMemoryType === 'episodic' && enable_triple_extraction !== false) {
776
+ try {
777
+ // BatchScheduler의 JobQueue에 Triple 추출 작업 등록
778
+ const batchScheduler = getBatchScheduler();
779
+ const jobName = `triple_extraction_${savedMemoryId}`;
780
+ // Triple 추출 작업 함수 정의
781
+ const tripleExtractionJob = async () => {
782
+ try {
783
+ // 데이터베이스 연결 재확인
784
+ let dbValid = false;
785
+ try {
786
+ await new Promise((resolve, reject) => {
787
+ try {
788
+ DatabaseUtils.get(dbRef, 'SELECT 1');
789
+ resolve();
790
+ }
791
+ catch (error) {
792
+ reject(error);
793
+ }
794
+ });
795
+ dbValid = true;
796
+ }
797
+ catch (dbError) {
798
+ this.logWarning('데이터베이스 연결이 유효하지 않아 Triple 추출을 건너뜁니다', {
799
+ memory_id: savedMemoryId,
800
+ error: dbError instanceof Error ? dbError.message : String(dbError)
801
+ });
802
+ return;
803
+ }
804
+ if (dbValid) {
805
+ // Triple 추출 서비스 초기화
806
+ const tripleExtractionService = new TripleExtractionService();
807
+ // Triple 추출 (비동기, 실패해도 메모리 저장은 성공)
808
+ const extractionResult = await tripleExtractionService.extractTriples(content, {}, savedMemoryId);
809
+ // Triple이 추출된 경우 Semantic Memory 생성/업데이트
810
+ if (extractionResult.triples.length > 0) {
811
+ const semanticMemoryUpdateService = new SemanticMemoryUpdateService(dbRef, embeddingServiceRef, context.services.relationGraph);
812
+ const updateResult = await semanticMemoryUpdateService.updateSemanticMemory(extractionResult, {
813
+ episodicMemoryId: savedMemoryId,
814
+ episodicImportance: importance || 0.5
815
+ });
816
+ // PRD 5.5, 5.5a, 5.6: Triple 추출 성공 시 상태 업데이트
817
+ // 성공 시: triple_extracted=true, triple_extracted_status='success'
818
+ // 이전 실패 기록 초기화 후 성공 정보로 갱신
819
+ const confidenceValues = [];
820
+ // memory_relation에서 confidence 값 수집 (각 triple별로 저장됨)
821
+ try {
822
+ const relations = DatabaseUtils.all(dbRef, `
823
+ SELECT confidence FROM memory_relation
824
+ WHERE source_id = ? AND relation_type = 'extracted_from'
825
+ `, [savedMemoryId]);
826
+ for (const rel of relations) {
827
+ if (rel.confidence !== null && rel.confidence !== undefined) {
828
+ confidenceValues.push(rel.confidence);
829
+ }
830
+ }
831
+ }
832
+ catch (err) {
833
+ // confidence 수집 실패해도 계속 진행
834
+ this.logWarning('Confidence 수집 실패', {
835
+ memory_id: savedMemoryId,
836
+ error: err instanceof Error ? err.message : String(err)
837
+ });
838
+ }
839
+ const confidenceAvg = confidenceValues.length > 0
840
+ ? confidenceValues.reduce((sum, c) => sum + c, 0) / confidenceValues.length
841
+ : null;
842
+ const metadata = {
843
+ triple_count: extractionResult.triples.length,
844
+ ...(confidenceAvg !== null && { confidence_avg: confidenceAvg }),
845
+ extracted_at: new Date().toISOString()
846
+ };
847
+ await DatabaseUtils.run(dbRef, `
848
+ UPDATE memory_item SET
849
+ triple_extracted = ?,
850
+ triple_extracted_status = ?,
851
+ triple_extraction_metadata = ?
852
+ WHERE id = ?
853
+ `, [
854
+ 1, // triple_extracted=true (SQLite에서는 INTEGER로 저장)
855
+ 'success', // triple_extracted_status='success'
856
+ JSON.stringify(metadata), // 성공 정보로 갱신 (이전 실패 기록 초기화)
857
+ savedMemoryId
858
+ ]);
859
+ this.logInfo('Triple 추출 및 Semantic Memory 생성 완료', {
860
+ memory_id: savedMemoryId,
861
+ triple_count: extractionResult.triples.length,
862
+ confidence_avg: confidenceAvg
863
+ });
864
+ }
865
+ else {
866
+ // PRD 5.5, 5.5a, 5.6: Triple 추출 실패 시 상태 업데이트
867
+ // 실패 시: triple_extracted=false, triple_extracted_status='failed'
868
+ // 실패 정보 저장 (failureReason, retry_count, last_attempt)
869
+ const failureReason = extractionResult.extractionInfo.failureReason || 'no_triple';
870
+ // 기존 metadata에서 retry_count 가져오기 (있는 경우)
871
+ let retryCount = 0;
872
+ try {
873
+ const existing = DatabaseUtils.get(dbRef, `
874
+ SELECT triple_extraction_metadata FROM memory_item WHERE id = ?
875
+ `, [savedMemoryId]);
876
+ if (existing?.triple_extraction_metadata) {
877
+ const existingMeta = JSON.parse(existing.triple_extraction_metadata);
878
+ retryCount = (existingMeta.retry_count || 0) + 1;
879
+ }
880
+ else {
881
+ retryCount = 1;
882
+ }
883
+ }
884
+ catch (err) {
885
+ retryCount = 1;
886
+ }
887
+ const metadata = {
888
+ failureReason,
889
+ retry_count: retryCount,
890
+ last_attempt: new Date().toISOString()
891
+ };
892
+ await DatabaseUtils.run(dbRef, `
893
+ UPDATE memory_item SET
894
+ triple_extracted = ?,
895
+ triple_extracted_status = ?,
896
+ triple_extraction_metadata = ?
897
+ WHERE id = ?
898
+ `, [
899
+ 0, // triple_extracted=false (SQLite에서는 INTEGER로 저장)
900
+ 'failed', // triple_extracted_status='failed'
901
+ JSON.stringify(metadata), // 실패 정보 저장
902
+ savedMemoryId
903
+ ]);
904
+ this.logInfo('Triple 추출 완료 (Triple 없음)', {
905
+ memory_id: savedMemoryId,
906
+ failure_reason: failureReason,
907
+ retry_count: retryCount
908
+ });
909
+ }
910
+ }
911
+ }
912
+ catch (error) {
913
+ // Triple 추출 실패해도 메모리 저장은 성공했으므로 경고만 출력
914
+ this.logWarning(`Triple 추출 실패 (${savedMemoryId})`, {
915
+ error: error instanceof Error ? error.message : String(error)
916
+ });
917
+ }
918
+ };
919
+ // JobQueue에 작업 등록 (우선순위: 5, 중간 우선순위)
920
+ const added = batchScheduler.addJob(jobName, tripleExtractionJob, 5, 0);
921
+ if (added) {
922
+ this.logInfo('Triple 추출 작업이 JobQueue에 등록되었습니다', {
923
+ memory_id: savedMemoryId,
924
+ job_name: jobName
925
+ });
926
+ }
927
+ else {
928
+ this.logWarning('Triple 추출 작업이 JobQueue에 등록되지 않았습니다 (중복 또는 큐 가득참)', {
929
+ memory_id: savedMemoryId,
930
+ job_name: jobName
931
+ });
932
+ }
933
+ }
934
+ catch (error) {
935
+ // JobQueue 등록 실패해도 메모리 저장은 성공했으므로 경고만 출력
936
+ this.logWarning(`Triple 추출 작업 등록 실패 (${savedMemoryId})`, {
937
+ error: error instanceof Error ? error.message : String(error)
938
+ });
939
+ }
940
+ }
760
941
  }
761
942
  catch (error) {
762
943
  // 백그라운드 작업 실패해도 메모리 저장은 성공했으므로 경고만 출력