a2a-memory 0.11.5 → 0.11.6
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 +7 -19
- package/README.md +1 -1
- package/dist/a2a/client.js +1 -252
- package/dist/a2a/discovery.js +1 -115
- package/dist/a2a/index.js +1 -8
- package/dist/a2a/types.js +1 -42
- package/dist/adapters/anthropic.js +1 -117
- package/dist/chunking/chunker.js +1 -163
- package/dist/claude/sync.js +1 -298
- package/dist/cli/commands/add.js +1 -80
- package/dist/cli/commands/claude-sync.js +1 -70
- package/dist/cli/commands/cleanup.js +1 -83
- package/dist/cli/commands/config.js +1 -79
- package/dist/cli/commands/edit.js +1 -69
- package/dist/cli/commands/embed.js +1 -92
- package/dist/cli/commands/extract.js +1 -103
- package/dist/cli/commands/health.js +1 -105
- package/dist/cli/commands/list.js +1 -46
- package/dist/cli/commands/migrate-chunks.js +1 -205
- package/dist/cli/commands/migrate-file-refs.js +1 -183
- package/dist/cli/commands/proficiency.js +1 -146
- package/dist/cli/commands/rm.js +1 -64
- package/dist/cli/commands/search.js +1 -90
- package/dist/cli/commands/setup-wizard.js +1 -387
- package/dist/cli/commands/setup.js +1 -170
- package/dist/cli/commands/skill.js +1 -151
- package/dist/cli/commands/status.js +1 -70
- package/dist/cli/commands/sync.js +1 -202
- package/dist/cli/commands/team.js +1 -142
- package/dist/cli/index.js +1 -87
- package/dist/config/manager.js +1 -372
- package/dist/db/database.js +1 -1400
- package/dist/embedding/e5-provider.js +1 -147
- package/dist/embedding/index.js +1 -34
- package/dist/embedding/local-provider.js +1 -157
- package/dist/embedding/openai-provider.js +1 -92
- package/dist/embedding/quantization.js +1 -89
- package/dist/extraction/dedup-manager.js +1 -161
- package/dist/extraction/emotion-filter.js +1 -33
- package/dist/extraction/extractor.js +1 -648
- package/dist/extraction/file-reference.js +1 -77
- package/dist/extraction/filter.js +1 -86
- package/dist/extraction/scorer.js +1 -142
- package/dist/extraction/similarity.js +1 -85
- package/dist/hooks/client-factory.js +1 -44
- package/dist/hooks/post-tool-use.js +1 -518
- package/dist/hooks/pre-compact.js +1 -209
- package/dist/hooks/session-end.js +1 -633
- package/dist/hooks/session-start.js +1 -549
- package/dist/hooks/shared.js +1 -110
- package/dist/hooks/user-prompt-submit.js +1 -316
- package/dist/i18n/index.js +1 -2
- package/dist/i18n/messages.js +1 -150
- package/dist/index.js +1 -43
- package/dist/lifecycle/cleanup-scheduler.js +1 -137
- package/dist/lifecycle/cleanup.js +1 -116
- package/dist/lifecycle/index.js +1 -13
- package/dist/lifecycle/quality-scorer.js +1 -46
- package/dist/lifecycle/tiering.js +1 -246
- package/dist/llm/client.js +1 -226
- package/dist/llm/index.js +1 -5
- package/dist/proficiency/actr-engine.js +1 -106
- package/dist/proficiency/detection.js +1 -77
- package/dist/proficiency/index.js +1 -9
- package/dist/proficiency/tracker.js +1 -173
- package/dist/proficiency/types.js +1 -8
- package/dist/providers/adapters.js +1 -140
- package/dist/providers/detector.js +1 -57
- package/dist/search/adaptive-router.js +1 -93
- package/dist/search/index.js +1 -9
- package/dist/search/ranker.js +1 -171
- package/dist/search/reranker.js +1 -155
- package/dist/session/parser.js +1 -130
- package/dist/skill/evaluator.js +1 -509
- package/dist/skill/index.js +1 -7
- package/dist/skill/types.js +1 -7
- package/dist/sync/client.js +1 -597
- package/dist/sync/encryption.js +1 -203
- package/dist/sync/index.js +1 -12
- package/dist/sync/queue.js +1 -214
- package/dist/sync/scheduler.js +1 -140
- package/dist/sync/synchronizer.js +1 -241
- package/dist/sync/team-synchronizer.js +1 -204
- package/dist/sync/vector-clock.js +1 -70
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -132
- package/dist/utils/keychain.js +1 -170
- package/dist/utils/logger.js +1 -128
- package/package.json +14 -10
- package/dist/a2a/client.d.ts.map +0 -1
- package/dist/a2a/client.js.map +0 -1
- package/dist/a2a/discovery.d.ts.map +0 -1
- package/dist/a2a/discovery.js.map +0 -1
- package/dist/a2a/index.d.ts.map +0 -1
- package/dist/a2a/index.js.map +0 -1
- package/dist/a2a/types.d.ts.map +0 -1
- package/dist/a2a/types.js.map +0 -1
- package/dist/adapters/anthropic.d.ts.map +0 -1
- package/dist/adapters/anthropic.js.map +0 -1
- package/dist/chunking/chunker.d.ts.map +0 -1
- package/dist/chunking/chunker.js.map +0 -1
- package/dist/claude/sync.d.ts.map +0 -1
- package/dist/claude/sync.js.map +0 -1
- package/dist/cli/commands/add.d.ts.map +0 -1
- package/dist/cli/commands/add.js.map +0 -1
- package/dist/cli/commands/claude-sync.d.ts.map +0 -1
- package/dist/cli/commands/claude-sync.js.map +0 -1
- package/dist/cli/commands/cleanup.d.ts.map +0 -1
- package/dist/cli/commands/cleanup.js.map +0 -1
- package/dist/cli/commands/config.d.ts.map +0 -1
- package/dist/cli/commands/config.js.map +0 -1
- package/dist/cli/commands/edit.d.ts.map +0 -1
- package/dist/cli/commands/edit.js.map +0 -1
- package/dist/cli/commands/embed.d.ts.map +0 -1
- package/dist/cli/commands/embed.js.map +0 -1
- package/dist/cli/commands/extract.d.ts.map +0 -1
- package/dist/cli/commands/extract.js.map +0 -1
- package/dist/cli/commands/health.d.ts.map +0 -1
- package/dist/cli/commands/health.js.map +0 -1
- package/dist/cli/commands/list.d.ts.map +0 -1
- package/dist/cli/commands/list.js.map +0 -1
- package/dist/cli/commands/migrate-chunks.d.ts.map +0 -1
- package/dist/cli/commands/migrate-chunks.js.map +0 -1
- package/dist/cli/commands/migrate-file-refs.d.ts.map +0 -1
- package/dist/cli/commands/migrate-file-refs.js.map +0 -1
- package/dist/cli/commands/proficiency.d.ts.map +0 -1
- package/dist/cli/commands/proficiency.js.map +0 -1
- package/dist/cli/commands/rm.d.ts.map +0 -1
- package/dist/cli/commands/rm.js.map +0 -1
- package/dist/cli/commands/search.d.ts.map +0 -1
- package/dist/cli/commands/search.js.map +0 -1
- package/dist/cli/commands/setup-wizard.d.ts.map +0 -1
- package/dist/cli/commands/setup-wizard.js.map +0 -1
- package/dist/cli/commands/setup.d.ts.map +0 -1
- package/dist/cli/commands/setup.js.map +0 -1
- package/dist/cli/commands/skill.d.ts.map +0 -1
- package/dist/cli/commands/skill.js.map +0 -1
- package/dist/cli/commands/status.d.ts.map +0 -1
- package/dist/cli/commands/status.js.map +0 -1
- package/dist/cli/commands/sync.d.ts.map +0 -1
- package/dist/cli/commands/sync.js.map +0 -1
- package/dist/cli/commands/team.d.ts.map +0 -1
- package/dist/cli/commands/team.js.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/config/manager.d.ts.map +0 -1
- package/dist/config/manager.js.map +0 -1
- package/dist/db/database.d.ts.map +0 -1
- package/dist/db/database.js.map +0 -1
- package/dist/embedding/e5-provider.d.ts.map +0 -1
- package/dist/embedding/e5-provider.js.map +0 -1
- package/dist/embedding/index.d.ts.map +0 -1
- package/dist/embedding/index.js.map +0 -1
- package/dist/embedding/local-provider.d.ts.map +0 -1
- package/dist/embedding/local-provider.js.map +0 -1
- package/dist/embedding/openai-provider.d.ts.map +0 -1
- package/dist/embedding/openai-provider.js.map +0 -1
- package/dist/embedding/quantization.d.ts.map +0 -1
- package/dist/embedding/quantization.js.map +0 -1
- package/dist/extraction/dedup-manager.d.ts.map +0 -1
- package/dist/extraction/dedup-manager.js.map +0 -1
- package/dist/extraction/emotion-filter.d.ts.map +0 -1
- package/dist/extraction/emotion-filter.js.map +0 -1
- package/dist/extraction/extractor.d.ts.map +0 -1
- package/dist/extraction/extractor.js.map +0 -1
- package/dist/extraction/file-reference.d.ts.map +0 -1
- package/dist/extraction/file-reference.js.map +0 -1
- package/dist/extraction/filter.d.ts.map +0 -1
- package/dist/extraction/filter.js.map +0 -1
- package/dist/extraction/scorer.d.ts.map +0 -1
- package/dist/extraction/scorer.js.map +0 -1
- package/dist/extraction/similarity.d.ts.map +0 -1
- package/dist/extraction/similarity.js.map +0 -1
- package/dist/hooks/client-factory.d.ts.map +0 -1
- package/dist/hooks/client-factory.js.map +0 -1
- package/dist/hooks/post-tool-use.d.ts.map +0 -1
- package/dist/hooks/post-tool-use.js.map +0 -1
- package/dist/hooks/pre-compact.d.ts.map +0 -1
- package/dist/hooks/pre-compact.js.map +0 -1
- package/dist/hooks/session-end.d.ts.map +0 -1
- package/dist/hooks/session-end.js.map +0 -1
- package/dist/hooks/session-start.d.ts.map +0 -1
- package/dist/hooks/session-start.js.map +0 -1
- package/dist/hooks/shared.d.ts.map +0 -1
- package/dist/hooks/shared.js.map +0 -1
- package/dist/hooks/user-prompt-submit.d.ts.map +0 -1
- package/dist/hooks/user-prompt-submit.js.map +0 -1
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/i18n/index.js.map +0 -1
- package/dist/i18n/messages.d.ts.map +0 -1
- package/dist/i18n/messages.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lifecycle/cleanup-scheduler.d.ts.map +0 -1
- package/dist/lifecycle/cleanup-scheduler.js.map +0 -1
- package/dist/lifecycle/cleanup.d.ts.map +0 -1
- package/dist/lifecycle/cleanup.js.map +0 -1
- package/dist/lifecycle/index.d.ts.map +0 -1
- package/dist/lifecycle/index.js.map +0 -1
- package/dist/lifecycle/quality-scorer.d.ts.map +0 -1
- package/dist/lifecycle/quality-scorer.js.map +0 -1
- package/dist/lifecycle/tiering.d.ts.map +0 -1
- package/dist/lifecycle/tiering.js.map +0 -1
- package/dist/llm/client.d.ts.map +0 -1
- package/dist/llm/client.js.map +0 -1
- package/dist/llm/index.d.ts.map +0 -1
- package/dist/llm/index.js.map +0 -1
- package/dist/proficiency/actr-engine.d.ts.map +0 -1
- package/dist/proficiency/actr-engine.js.map +0 -1
- package/dist/proficiency/detection.d.ts.map +0 -1
- package/dist/proficiency/detection.js.map +0 -1
- package/dist/proficiency/index.d.ts.map +0 -1
- package/dist/proficiency/index.js.map +0 -1
- package/dist/proficiency/tracker.d.ts.map +0 -1
- package/dist/proficiency/tracker.js.map +0 -1
- package/dist/proficiency/types.d.ts.map +0 -1
- package/dist/proficiency/types.js.map +0 -1
- package/dist/providers/adapters.d.ts.map +0 -1
- package/dist/providers/adapters.js.map +0 -1
- package/dist/providers/detector.d.ts.map +0 -1
- package/dist/providers/detector.js.map +0 -1
- package/dist/search/adaptive-router.d.ts.map +0 -1
- package/dist/search/adaptive-router.js.map +0 -1
- package/dist/search/index.d.ts.map +0 -1
- package/dist/search/index.js.map +0 -1
- package/dist/search/ranker.d.ts.map +0 -1
- package/dist/search/ranker.js.map +0 -1
- package/dist/search/reranker.d.ts.map +0 -1
- package/dist/search/reranker.js.map +0 -1
- package/dist/session/parser.d.ts.map +0 -1
- package/dist/session/parser.js.map +0 -1
- package/dist/skill/evaluator.d.ts.map +0 -1
- package/dist/skill/evaluator.js.map +0 -1
- package/dist/skill/index.d.ts.map +0 -1
- package/dist/skill/index.js.map +0 -1
- package/dist/skill/types.d.ts.map +0 -1
- package/dist/skill/types.js.map +0 -1
- package/dist/sync/client.d.ts.map +0 -1
- package/dist/sync/client.js.map +0 -1
- package/dist/sync/encryption.d.ts.map +0 -1
- package/dist/sync/encryption.js.map +0 -1
- package/dist/sync/index.d.ts.map +0 -1
- package/dist/sync/index.js.map +0 -1
- package/dist/sync/queue.d.ts.map +0 -1
- package/dist/sync/queue.js.map +0 -1
- package/dist/sync/scheduler.d.ts.map +0 -1
- package/dist/sync/scheduler.js.map +0 -1
- package/dist/sync/synchronizer.d.ts.map +0 -1
- package/dist/sync/synchronizer.js.map +0 -1
- package/dist/sync/team-synchronizer.d.ts.map +0 -1
- package/dist/sync/team-synchronizer.js.map +0 -1
- package/dist/sync/vector-clock.d.ts.map +0 -1
- package/dist/sync/vector-clock.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/utils/keychain.d.ts.map +0 -1
- package/dist/utils/keychain.js.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js.map +0 -1
package/dist/hooks/shared.js
CHANGED
|
@@ -1,110 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Hook 공유 유틸리티
|
|
3
|
-
* 프로세스 내 DB 싱글톤으로 중복 초기화 방지
|
|
4
|
-
*/
|
|
5
|
-
import { MemoryDatabase } from '../db/database.js';
|
|
6
|
-
let _sharedDb = null;
|
|
7
|
-
let _sharedDbPath = null;
|
|
8
|
-
/**
|
|
9
|
-
* 프로세스 내 DB 싱글톤 조회/생성
|
|
10
|
-
*/
|
|
11
|
-
export function getSharedDb(dbPath) {
|
|
12
|
-
if (_sharedDb && _sharedDbPath === dbPath) {
|
|
13
|
-
return _sharedDb;
|
|
14
|
-
}
|
|
15
|
-
if (_sharedDb) {
|
|
16
|
-
try {
|
|
17
|
-
_sharedDb.close();
|
|
18
|
-
}
|
|
19
|
-
catch { /* ignore */ }
|
|
20
|
-
}
|
|
21
|
-
_sharedDb = new MemoryDatabase(dbPath);
|
|
22
|
-
_sharedDbPath = dbPath;
|
|
23
|
-
_sharedDb.initialize();
|
|
24
|
-
return _sharedDb;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* DB 종료 (프로세스 종료 시 호출)
|
|
28
|
-
*/
|
|
29
|
-
export function closeSharedDb() {
|
|
30
|
-
if (_sharedDb) {
|
|
31
|
-
try {
|
|
32
|
-
_sharedDb.close();
|
|
33
|
-
}
|
|
34
|
-
catch { /* ignore */ }
|
|
35
|
-
_sharedDb = null;
|
|
36
|
-
_sharedDbPath = null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* 테스트용 리셋
|
|
41
|
-
*/
|
|
42
|
-
export function resetSharedDb() {
|
|
43
|
-
_sharedDb = null;
|
|
44
|
-
_sharedDbPath = null;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Claude Code stdin 입력을 내부 camelCase 형식으로 변환
|
|
48
|
-
*
|
|
49
|
-
* Claude Code는 snake_case로 전송:
|
|
50
|
-
* session_id, hook_event_name, tool_name, tool_input, tool_response, cwd, transcript_path
|
|
51
|
-
* Plugin 내부는 camelCase 사용:
|
|
52
|
-
* sessionId, hookName, toolName, toolInput, toolResult, projectPath, cwd
|
|
53
|
-
*/
|
|
54
|
-
export function normalizeHookInput(raw) {
|
|
55
|
-
return {
|
|
56
|
-
// 공통 필드
|
|
57
|
-
hookName: raw.hook_event_name ?? raw.hookName,
|
|
58
|
-
sessionId: raw.session_id ?? raw.sessionId,
|
|
59
|
-
projectPath: raw.cwd ?? raw.projectPath,
|
|
60
|
-
cwd: raw.cwd ?? raw.projectPath,
|
|
61
|
-
transcriptPath: raw.transcript_path ?? raw.transcriptPath,
|
|
62
|
-
// PostToolUse 전용
|
|
63
|
-
toolName: raw.tool_name ?? raw.toolName,
|
|
64
|
-
toolInput: raw.tool_input ?? raw.toolInput ?? {},
|
|
65
|
-
toolResult: typeof (raw.tool_response ?? raw.toolResult) === 'object'
|
|
66
|
-
? JSON.stringify(raw.tool_response ?? raw.toolResult)
|
|
67
|
-
: String(raw.tool_response ?? raw.toolResult ?? ''),
|
|
68
|
-
// SessionEnd 전용
|
|
69
|
-
capturedMemoryIds: raw.capturedMemoryIds ?? [],
|
|
70
|
-
modifiedFiles: raw.modifiedFiles ?? [],
|
|
71
|
-
// UserPromptSubmit 전용
|
|
72
|
-
userPrompt: raw.user_prompt ?? raw.userPrompt ?? '',
|
|
73
|
-
// PreCompact 전용
|
|
74
|
-
transcript: raw.transcript ?? '',
|
|
75
|
-
// 원본 데이터 보존 (디버깅용)
|
|
76
|
-
_raw: raw,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* 프롬프트 텍스트에서 검색 키워드 추출
|
|
81
|
-
* - 불용어 제거
|
|
82
|
-
* - 의미 있는 토큰만 반환
|
|
83
|
-
* - 최대 8개 키워드
|
|
84
|
-
*/
|
|
85
|
-
const STOP_WORDS = new Set([
|
|
86
|
-
'the', 'a', 'an', 'is', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
87
|
-
'have', 'has', 'had', 'do', 'does', 'did', 'will', 'would', 'shall', 'should',
|
|
88
|
-
'may', 'might', 'must', 'can', 'could', 'to', 'of', 'in', 'for', 'on', 'with',
|
|
89
|
-
'at', 'by', 'from', 'as', 'into', 'through', 'during', 'before', 'after',
|
|
90
|
-
'and', 'but', 'or', 'nor', 'not', 'so', 'yet', 'both', 'either', 'neither',
|
|
91
|
-
'this', 'that', 'these', 'those', 'it', 'its', 'my', 'your', 'his', 'her',
|
|
92
|
-
'our', 'their', 'what', 'which', 'who', 'whom', 'whose',
|
|
93
|
-
'i', 'me', 'we', 'us', 'you', 'he', 'she', 'they', 'them',
|
|
94
|
-
// 한국어 불용어
|
|
95
|
-
'이', '그', '저', '것', '수', '등', '및', '중', '더', '때', '좀',
|
|
96
|
-
'해줘', '해주세요', '알려줘', '알려주세요', '해', '하고', '하는', '하면',
|
|
97
|
-
]);
|
|
98
|
-
export function extractSearchKeywords(prompt) {
|
|
99
|
-
// 코드 블록 제거
|
|
100
|
-
const cleaned = prompt.replace(/```[\s\S]*?```/g, '').replace(/`[^`]+`/g, '');
|
|
101
|
-
// 토큰 분리 (영문+한국어 혼합)
|
|
102
|
-
const tokens = cleaned
|
|
103
|
-
.split(/[\s,.!?;:()[\]{}"'<>]+/)
|
|
104
|
-
.map(t => t.trim())
|
|
105
|
-
.filter(t => t.length > 1 && !STOP_WORDS.has(t.toLowerCase()) && !/^\d+$/.test(t));
|
|
106
|
-
// 중복 제거 + 최대 8개
|
|
107
|
-
const unique = [...new Set(tokens)];
|
|
108
|
-
return unique.slice(0, 8).join(' ');
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=shared.js.map
|
|
1
|
+
(function(_0x40f842,_0x576d6b){const _0x27d301=_0x40f842();function _0xbfc74a(_0x5de284,_0x17b5bf){return _0x249a(_0x17b5bf-0x200,_0x5de284);}function _0x13df5f(_0x410e47,_0x55daf0){return _0x249a(_0x55daf0- -0xec,_0x410e47);}while(!![]){try{const _0x481c5b=parseInt(_0xbfc74a(0x329,0x33d))/0x1+-parseInt(_0xbfc74a(0x305,0x317))/0x2+parseInt(_0xbfc74a(0x34c,0x338))/0x3+parseInt(_0x13df5f(0x5d,0x54))/0x4*(parseInt(_0xbfc74a(0x318,0x30a))/0x5)+parseInt(_0xbfc74a(0x311,0x300))/0x6*(parseInt(_0x13df5f(0x5a,0x35))/0x7)+parseInt(_0xbfc74a(0x365,0x345))/0x8+-parseInt(_0x13df5f(0x28,0x10))/0x9;if(_0x481c5b===_0x576d6b)break;else _0x27d301['push'](_0x27d301['shift']());}catch(_0x2d826f){_0x27d301['push'](_0x27d301['shift']());}}}(_0xf356,0x36468));import{MemoryDatabase}from'../db/database.js';let _sharedDb=null;function _0x2ce654(_0x46c518,_0x2f0f5a){return _0x249a(_0x46c518-0x55,_0x2f0f5a);}let _sharedDbPath=null;export function getSharedDb(_0x4575ce){const _0x32817f={'pjVkq':function(_0x508c59,_0x3c8efc){return _0x508c59===_0x3c8efc;}};if(_sharedDb&&_0x32817f['pjVkq'](_sharedDbPath,_0x4575ce))return _sharedDb;if(_sharedDb)try{_sharedDb['close']();}catch{}_sharedDb=new MemoryDatabase(_0x4575ce),_sharedDbPath=_0x4575ce;function _0x9259b2(_0x44b0ee,_0x57a755){return _0x249a(_0x57a755-0x165,_0x44b0ee);}return _sharedDb[_0x9259b2(0x28e,0x2b2)](),_sharedDb;}export function closeSharedDb(){function _0x392cbf(_0x52df7d,_0x3957ca){return _0x249a(_0x52df7d- -0x1ce,_0x3957ca);}if(_sharedDb){try{_sharedDb[_0x392cbf(-0xcc,-0xeb)]();}catch{}_sharedDb=null,_sharedDbPath=null;}}function _0xf356(){const _0x174a7d=['DhjPBq','C2XPy2u','DgHVC2u','mZa3mda2t0PVBhDx','DgHLBq','ugf0Aa','y2fU','B2jQzwn0','7zw07ko87is47jQu','y3DK','DgHLEq','D2L0Aa','DgHYB3vNAa','yxjL','DxnLCLbYB21WDa','BwfW','Ew91CG','DgvZDa','Ag9VA05HBwu','Dg9VBf9YzxnWBW','yMvPBMC','7jwm66cK7ksy','Ew91','AgfZ','D2HV','Dg9VBf9PBNb1Da','nZeYndq5DMzozLv4','AxrZ','ywz0zxi','C2HVDwXK','BgvUz3rO','nty2mJbqBxbet3i','AgvY','Bwf5','mJG2ogX6CMrnCG','BM9Y','C2HL','C3bSAxq','x3bHDgG','mZqXmteZnNfIyNLrtW','C2HHBgW','DgHLAxi','zMLSDgvY','D2vYzq','C2vZC2LVBL9Pza','ChjVAMvJDfbHDa','Dg9VBfjLC3vSDa','Aw5PDgLHBgL6zq','Dg9mB3DLCKnHCW','zhvYAw5N','ntK3mJi2nwf2r0DVCa','B3vY','Aw50BW','zNjVBq','mJr1CM1ntuK','zM9Y','y2XVC2u','yM9dseW','DgHHDa','BwLNAhq','yNv0','BgvZ','CMvWBgfJzq','D291Bgq','mty5nujIrKf6sa','D2HVC2u','zg9LCW','y2fWDhvYzwrnzq','DhjHBNnJCMLWDa','AM9PBG','yM90Aa','DgHLC2u','Dg9VBf9Uyw1L','Bw9KAwzPzwrgAq','DxnLCL9WCM9TCa','D2HVBq','zwL0AgvY','nta2mtG2yvrXEKfy','AgfK','vLv6y2C','D2HHDa','7jwm66cK7ko87is47jQu','Agf2zq','BM90'];_0xf356=function(){return _0x174a7d;};return _0xf356();}function _0x208622(_0x4e3e8b,_0x57bfee){return _0x249a(_0x57bfee-0x382,_0x4e3e8b);}function _0x249a(_0x3a8f34,_0x440356){_0x3a8f34=_0x3a8f34-0xfb;const _0xf35624=_0xf356();let _0x249ac4=_0xf35624[_0x3a8f34];if(_0x249a['byGkFT']===undefined){var _0x5e5c1f=function(_0x2790db){const _0x1e5a41='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1dca0a='',_0x26fef2='';for(let _0x3625fc=0x0,_0x1d79a4,_0x174e3e,_0x9d4766=0x0;_0x174e3e=_0x2790db['charAt'](_0x9d4766++);~_0x174e3e&&(_0x1d79a4=_0x3625fc%0x4?_0x1d79a4*0x40+_0x174e3e:_0x174e3e,_0x3625fc++%0x4)?_0x1dca0a+=String['fromCharCode'](0xff&_0x1d79a4>>(-0x2*_0x3625fc&0x6)):0x0){_0x174e3e=_0x1e5a41['indexOf'](_0x174e3e);}for(let _0xdad99b=0x0,_0x5149c4=_0x1dca0a['length'];_0xdad99b<_0x5149c4;_0xdad99b++){_0x26fef2+='%'+('00'+_0x1dca0a['charCodeAt'](_0xdad99b)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x26fef2);};_0x249a['zkHbUV']=_0x5e5c1f,_0x249a['shKjJR']={},_0x249a['byGkFT']=!![];}const _0x15eb61=_0xf35624[0x0],_0x942f2e=_0x3a8f34+_0x15eb61,_0x410024=_0x249a['shKjJR'][_0x942f2e];return!_0x410024?(_0x249ac4=_0x249a['zkHbUV'](_0x249ac4),_0x249a['shKjJR'][_0x942f2e]=_0x249ac4):_0x249ac4=_0x410024,_0x249ac4;}export function resetSharedDb(){_sharedDb=null,_sharedDbPath=null;}export function normalizeHookInput(_0x1aa4ff){function _0x1f4a1e(_0x36e65b,_0x138da5){return _0x249a(_0x36e65b-0x1cd,_0x138da5);}function _0x42bffd(_0x4f5c3a,_0x375913){return _0x249a(_0x4f5c3a- -0xd8,_0x375913);}const _0x19924e={'VUzcg':_0x42bffd(0x4d,0x35),'boCHL':function(_0x5b4792,_0x27e559){return _0x5b4792(_0x27e559);}};return{'hookName':_0x1aa4ff['hook_event'+'_name']??_0x1aa4ff[_0x42bffd(0x58,0x50)],'sessionId':_0x1aa4ff[_0x1f4a1e(0x317,0x32e)]??_0x1aa4ff['sessionId'],'projectPath':_0x1aa4ff[_0x42bffd(0x4f,0x27)]??_0x1aa4ff[_0x42bffd(0x73,0x8d)+'h'],'cwd':_0x1aa4ff[_0x1f4a1e(0x2f4,0x2d0)]??_0x1aa4ff[_0x1f4a1e(0x318,0x30b)+'h'],'transcriptPath':_0x1aa4ff[_0x42bffd(0x36,0x16)+_0x42bffd(0x6c,0x80)]??_0x1aa4ff[_0x42bffd(0x36,0x59)+_0x42bffd(0x4b,0x34)],'toolName':_0x1aa4ff[_0x42bffd(0x3a,0x1d)]??_0x1aa4ff['toolName'],'toolInput':_0x1aa4ff[_0x42bffd(0x5f,0x81)]??_0x1aa4ff['toolInput']??{},'toolResult':typeof(_0x1aa4ff[_0x42bffd(0x59,0x6a)+'nse']??_0x1aa4ff[_0x1f4a1e(0x319,0x31c)])===_0x19924e[_0x42bffd(0x41,0x4a)]?JSON['stringify'](_0x1aa4ff[_0x42bffd(0x59,0x69)+'nse']??_0x1aa4ff['toolResult']):_0x19924e[_0x1f4a1e(0x2d0,0x2c0)](String,_0x1aa4ff[_0x42bffd(0x59,0x60)+'nse']??_0x1aa4ff[_0x42bffd(0x74,0x51)]??''),'capturedMemoryIds':_0x1aa4ff[_0x1f4a1e(0x2da,0x2c7)+'moryIds']??[],'modifiedFiles':_0x1aa4ff[_0x42bffd(0x3b,0x27)+_0x42bffd(0x2f,0x25)]??[],'userPrompt':_0x1aa4ff[_0x1f4a1e(0x2e1,0x2e8)+'t']??_0x1aa4ff[_0x1f4a1e(0x2f9,0x2d2)]??'','transcript':_0x1aa4ff[_0x1f4a1e(0x2db,0x2c3)]??'','_raw':_0x1aa4ff};}const STOP_WORDS=new Set(['the','a','an','is',_0x2ce654(0x180,0x173),'was',_0x2ce654(0x19e,0x18a),'be','been',_0x208622(0x499,0x4b4),_0x208622(0x481,0x49e),_0x208622(0x48f,0x4b7),_0x2ce654(0x16d,0x16e),'do',_0x2ce654(0x161,0x139),'did','will',_0x2ce654(0x15e,0x148),_0x208622(0x4e6,0x4c8),_0x208622(0x4a8,0x4bd),_0x208622(0x4c4,0x4c1),_0x208622(0x4ae,0x487),'must',_0x2ce654(0x179,0x19c),'could','to','of','in',_0x208622(0x493,0x483),'on',_0x208622(0x49a,0x4ab),'at','by',_0x2ce654(0x154,0x148),'as',_0x2ce654(0x153,0x13e),_0x208622(0x48c,0x4ac),_0x208622(0x48c,0x47d),'before',_0x208622(0x49c,0x4bc),'and',_0x2ce654(0x15b,0x175),'or',_0x2ce654(0x196,0x196),_0x208622(0x4c9,0x49f),'so','yet',_0x208622(0x48d,0x492),_0x2ce654(0x16b,0x14f),'neither','this',_0x208622(0x494,0x486),_0x2ce654(0x166,0x146),_0x208622(0x494,0x4a2),'it',_0x2ce654(0x18e,0x1a3),'my',_0x2ce654(0x183,0x16e),'his',_0x2ce654(0x193,0x170),_0x208622(0x47e,0x47f),_0x208622(0x4ca,0x4c9),_0x208622(0x4a2,0x49c),'which',_0x2ce654(0x18b,0x183),_0x208622(0x4b3,0x497),_0x208622(0x47b,0x48d),'i','me','we','us',_0x2ce654(0x189,0x165),'he',_0x208622(0x4ee,0x4c4),_0x2ce654(0x17d,0x177),_0x2ce654(0x177,0x161),'이','그','저','것','수','등','및','중','더','때','좀','해줘',_0x2ce654(0x17b,0x17f),_0x208622(0x4c2,0x4b5),_0x208622(0x4bc,0x49d),'해','하고','하는','하면']);export function extractSearchKeywords(_0x140c5f){function _0x25e674(_0x3672b4,_0x3d1b8d){return _0x2ce654(_0x3672b4-0x172,_0x3d1b8d);}const _0x1f1fbd=_0x140c5f[_0x25e674(0x2cf,0x2cf)](/```[\s\S]*?```/g,'')['replace'](/`[^`]+`/g,'');function _0x414fdf(_0x3a2463,_0x89e8ee){return _0x2ce654(_0x3a2463- -0x39f,_0x89e8ee);}const _0x2ed6dc=_0x1f1fbd[_0x414fdf(-0x207,-0x208)](/[\s,.!?;:()[\]{}"'<>]+/)[_0x25e674(0x2f4,0x2ea)](_0x4ab552=>_0x4ab552[_0x414fdf(-0x22c,-0x215)]())[_0x414fdf(-0x202,-0x1f5)](_0x1d24b0=>_0x1d24b0[_0x25e674(0x303,0x319)]>0x1&&!STOP_WORDS[_0x414fdf(-0x215,-0x20f)](_0x1d24b0[_0x414fdf(-0x1fc,-0x216)+'e']())&&!/^\d+$/[_0x25e674(0x2f6,0x313)](_0x1d24b0)),_0x374f0a=[...new Set(_0x2ed6dc)];return _0x374f0a[_0x25e674(0x2e6,0x2c8)](0x0,0x8)[_0x25e674(0x2d6,0x2fd)]('\x20');}
|
|
@@ -1,316 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UserPromptSubmit Hook
|
|
3
|
-
*
|
|
4
|
-
* 사용자가 프롬프트를 제출할 때마다 실행됩니다.
|
|
5
|
-
* 프롬프트 기반 실시간 메모리 검색 + 주입으로
|
|
6
|
-
* 세션 중 축적된 메모리를 즉시 활용합니다.
|
|
7
|
-
*
|
|
8
|
-
* 성능 타겟: p50 < 30ms, p99 < 100ms
|
|
9
|
-
*/
|
|
10
|
-
import { getSharedDb, closeSharedDb, normalizeHookInput, extractSearchKeywords } from './shared.js';
|
|
11
|
-
import { ConfigManager } from '../config/manager.js';
|
|
12
|
-
import { createLogger } from '../utils/logger.js';
|
|
13
|
-
import { hasEmotionalContent } from '../extraction/emotion-filter.js';
|
|
14
|
-
import { AdaptiveRouter } from '../search/adaptive-router.js';
|
|
15
|
-
import { HybridRanker } from '../search/ranker.js';
|
|
16
|
-
class QueryCache {
|
|
17
|
-
cache = new Map();
|
|
18
|
-
maxSize;
|
|
19
|
-
ttlMs;
|
|
20
|
-
constructor(maxSize, ttlSeconds) {
|
|
21
|
-
this.maxSize = maxSize;
|
|
22
|
-
this.ttlMs = ttlSeconds * 1000;
|
|
23
|
-
}
|
|
24
|
-
get(key) {
|
|
25
|
-
const entry = this.cache.get(key);
|
|
26
|
-
if (!entry)
|
|
27
|
-
return null;
|
|
28
|
-
if (Date.now() - entry.timestamp > this.ttlMs) {
|
|
29
|
-
this.cache.delete(key);
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
// LRU: 재삽입으로 순서 갱신
|
|
33
|
-
this.cache.delete(key);
|
|
34
|
-
this.cache.set(key, entry);
|
|
35
|
-
return entry.result;
|
|
36
|
-
}
|
|
37
|
-
set(key, result) {
|
|
38
|
-
// 용량 초과 시 가장 오래된 항목 제거
|
|
39
|
-
if (this.cache.size >= this.maxSize) {
|
|
40
|
-
const oldest = this.cache.keys().next().value;
|
|
41
|
-
if (oldest !== undefined) {
|
|
42
|
-
this.cache.delete(oldest);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
this.cache.set(key, { result, timestamp: Date.now() });
|
|
46
|
-
}
|
|
47
|
-
clear() {
|
|
48
|
-
this.cache.clear();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// 프로세스 내 싱글톤 캐시 (Hook 프로세스 수명 = 1회 실행이지만, 테스트에서 재사용)
|
|
52
|
-
let _queryCache = null;
|
|
53
|
-
function getQueryCache(config) {
|
|
54
|
-
if (!_queryCache) {
|
|
55
|
-
_queryCache = new QueryCache(config.cacheSize, config.cacheTTLSeconds);
|
|
56
|
-
}
|
|
57
|
-
return _queryCache;
|
|
58
|
-
}
|
|
59
|
-
/** 테스트용 캐시 리셋 */
|
|
60
|
-
export function resetQueryCache() {
|
|
61
|
-
_queryCache = null;
|
|
62
|
-
}
|
|
63
|
-
// ============================================================
|
|
64
|
-
// Memory Formatting
|
|
65
|
-
// ============================================================
|
|
66
|
-
/** 카테고리 축약 레이블 */
|
|
67
|
-
const CATEGORY_SHORT = {
|
|
68
|
-
error_solution: 'error_solution',
|
|
69
|
-
code_pattern: 'code_pattern',
|
|
70
|
-
decision: 'decision',
|
|
71
|
-
context: 'context',
|
|
72
|
-
convention: 'convention',
|
|
73
|
-
skill: 'skill',
|
|
74
|
-
learning: 'learning',
|
|
75
|
-
project_knowledge: 'project_knowledge',
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* 메모리를 compact 형식으로 포맷
|
|
79
|
-
* 토큰 예산 내에서 최대한 많은 메모리 포함
|
|
80
|
-
*/
|
|
81
|
-
function formatRealtimeOutput(memories, maxTokens) {
|
|
82
|
-
if (memories.length === 0)
|
|
83
|
-
return '';
|
|
84
|
-
const lines = ['<!-- A2A Realtime Context -->'];
|
|
85
|
-
let estimatedTokens = 10; // 헤더/푸터 오버헤드
|
|
86
|
-
for (const { memory } of memories) {
|
|
87
|
-
const cat = CATEGORY_SHORT[memory.category] || memory.category;
|
|
88
|
-
// 한 줄 요약 (최대 200자)
|
|
89
|
-
const content = memory.content.split('\n').filter(l => l.trim()).join(' ').slice(0, 200);
|
|
90
|
-
const line = `- [${cat}] ${content}`;
|
|
91
|
-
// 토큰 추정: ~4 chars per token
|
|
92
|
-
const lineTokens = Math.ceil(line.length / 4);
|
|
93
|
-
if (estimatedTokens + lineTokens > maxTokens)
|
|
94
|
-
break;
|
|
95
|
-
lines.push(line);
|
|
96
|
-
estimatedTokens += lineTokens;
|
|
97
|
-
}
|
|
98
|
-
if (lines.length <= 1)
|
|
99
|
-
return ''; // 헤더만 있으면 빈 문자열
|
|
100
|
-
lines.push('');
|
|
101
|
-
lines.push('\u{1F4A1} `a2a-memory search <query>` for details.');
|
|
102
|
-
lines.push('<!-- /A2A Realtime Context -->');
|
|
103
|
-
return lines.join('\n');
|
|
104
|
-
}
|
|
105
|
-
// ============================================================
|
|
106
|
-
// Core Logic
|
|
107
|
-
// ============================================================
|
|
108
|
-
export async function handleUserPromptSubmit(context) {
|
|
109
|
-
const config = new ConfigManager().load();
|
|
110
|
-
const logger = createLogger('UserPromptSubmit', config.logging);
|
|
111
|
-
const startTime = performance.now();
|
|
112
|
-
const realtimeConfig = config.realtimeInject ?? {
|
|
113
|
-
enabled: true,
|
|
114
|
-
maxMemories: 3,
|
|
115
|
-
maxTokens: 1000,
|
|
116
|
-
cacheSize: 20,
|
|
117
|
-
cacheTTLSeconds: 60,
|
|
118
|
-
timeoutMs: 100,
|
|
119
|
-
};
|
|
120
|
-
if (!realtimeConfig.enabled) {
|
|
121
|
-
logger.info('Realtime inject disabled');
|
|
122
|
-
logger.flush();
|
|
123
|
-
return '';
|
|
124
|
-
}
|
|
125
|
-
// 짧은 프롬프트는 스킵 (인사, 단답 등)
|
|
126
|
-
const prompt = context.userPrompt?.trim() || '';
|
|
127
|
-
if (prompt.length < 5) {
|
|
128
|
-
logger.debug('Prompt too short, skipping');
|
|
129
|
-
logger.flush();
|
|
130
|
-
return '';
|
|
131
|
-
}
|
|
132
|
-
// 키워드 추출
|
|
133
|
-
const rawKeywords = extractSearchKeywords(prompt);
|
|
134
|
-
if (!rawKeywords || rawKeywords.trim().length < 2) {
|
|
135
|
-
logger.debug('No meaningful keywords extracted');
|
|
136
|
-
logger.flush();
|
|
137
|
-
return '';
|
|
138
|
-
}
|
|
139
|
-
// FTS5 OR 쿼리로 변환 (implicit AND 대신)
|
|
140
|
-
// "SQLite bind error" → "SQLite OR bind OR error"
|
|
141
|
-
const keywords = rawKeywords.split(/\s+/).filter(k => k.length > 1).join(' OR ');
|
|
142
|
-
// AdaptiveRouter로 쿼리 복잡도 분류 (<1ms, 규칙 기반)
|
|
143
|
-
const router = new AdaptiveRouter();
|
|
144
|
-
const routing = router.classify(prompt);
|
|
145
|
-
// 캐시 확인 (routing complexity 포함)
|
|
146
|
-
const cache = getQueryCache(realtimeConfig);
|
|
147
|
-
const cacheKey = `${routing.complexity}:${keywords}`;
|
|
148
|
-
const cached = cache.get(cacheKey);
|
|
149
|
-
if (cached !== null) {
|
|
150
|
-
logger.info('Cache hit', { keywords, durationMs: Math.round(performance.now() - startTime) });
|
|
151
|
-
logger.flush();
|
|
152
|
-
return cached;
|
|
153
|
-
}
|
|
154
|
-
try {
|
|
155
|
-
const db = getSharedDb(config.db.path);
|
|
156
|
-
const limit = realtimeConfig.maxMemories;
|
|
157
|
-
// FTS 전용 빠른 경로 (임베딩 계산 없이)
|
|
158
|
-
let ftsResults = [];
|
|
159
|
-
try {
|
|
160
|
-
ftsResults = db.searchByFTS(keywords, limit * 2); // 오버페치 → 필터링
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
// FTS 쿼리 실패 시 (특수문자 등)
|
|
164
|
-
ftsResults = [];
|
|
165
|
-
}
|
|
166
|
-
// semantic/complex 쿼리 + 임베딩 활성 시 벡터 검색 추가 (p50 < 30ms 유지 우선)
|
|
167
|
-
let results;
|
|
168
|
-
if (routing.useVector && config.embedding?.enabled) {
|
|
169
|
-
try {
|
|
170
|
-
const { createEmbeddingProvider } = await import('../embedding/index.js');
|
|
171
|
-
const provider = createEmbeddingProvider(config.embedding, config.llm);
|
|
172
|
-
const queryEmbedding = await Promise.resolve(provider.embed(prompt));
|
|
173
|
-
const vectorResults = db.searchByVector(queryEmbedding, limit * 2);
|
|
174
|
-
// HybridRanker로 FTS + Vector 결합 (Reranker는 성능 제약으로 사용 안 함)
|
|
175
|
-
const ranker = new HybridRanker({ categoryBoost: true, tierBoost: true });
|
|
176
|
-
const ranked = ranker.rank(ftsResults, vectorResults);
|
|
177
|
-
results = ranked.slice(0, limit * 2).map(r => ({
|
|
178
|
-
memory: r.memory,
|
|
179
|
-
score: r.score,
|
|
180
|
-
matchType: 'hybrid',
|
|
181
|
-
}));
|
|
182
|
-
logger.debug('Hybrid search in UserPromptSubmit', { count: results.length });
|
|
183
|
-
}
|
|
184
|
-
catch {
|
|
185
|
-
// 임베딩 실패 시 FTS 결과로 폴백
|
|
186
|
-
results = ftsResults;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
results = ftsResults;
|
|
191
|
-
}
|
|
192
|
-
// 프로젝트 경로 필터링 (같은 프로젝트 우선)
|
|
193
|
-
const projectResults = results.filter(r => r.memory.projectPath === context.projectPath);
|
|
194
|
-
const otherResults = results.filter(r => r.memory.projectPath !== context.projectPath);
|
|
195
|
-
// 같은 프로젝트 우선, 부족하면 타 프로젝트 보충
|
|
196
|
-
const rawCombined = [...projectResults, ...otherResults];
|
|
197
|
-
// Parent 중복 제거: 같은 Parent의 Children은 최고 점수 1개만 유지 (2-pass)
|
|
198
|
-
const bestByParent = new Map();
|
|
199
|
-
const deduped = [];
|
|
200
|
-
for (const item of rawCombined) {
|
|
201
|
-
if (!item.memory.parentId) {
|
|
202
|
-
deduped.push(item);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
const existing = bestByParent.get(item.memory.parentId);
|
|
206
|
-
if (!existing || item.score > existing.score) {
|
|
207
|
-
bestByParent.set(item.memory.parentId, item);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
deduped.push(...bestByParent.values());
|
|
212
|
-
// 점수 내림차순 재정렬
|
|
213
|
-
deduped.sort((a, b) => b.score - a.score);
|
|
214
|
-
const combined = deduped.slice(0, limit);
|
|
215
|
-
if (combined.length === 0) {
|
|
216
|
-
const output = '';
|
|
217
|
-
cache.set(cacheKey, output);
|
|
218
|
-
logger.info('No results', { keywords, durationMs: Math.round(performance.now() - startTime) });
|
|
219
|
-
logger.flush();
|
|
220
|
-
return output;
|
|
221
|
-
}
|
|
222
|
-
// 접근 추적
|
|
223
|
-
for (const { memory } of combined) {
|
|
224
|
-
try {
|
|
225
|
-
db.recordAccess(memory.id);
|
|
226
|
-
}
|
|
227
|
-
catch {
|
|
228
|
-
// 접근 추적 실패 무시
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
const output = formatRealtimeOutput(combined, realtimeConfig.maxTokens);
|
|
232
|
-
cache.set(cacheKey, output);
|
|
233
|
-
// 주입 효과 기록 (fire-and-forget, < 5ms)
|
|
234
|
-
if (combined.length > 0) {
|
|
235
|
-
try {
|
|
236
|
-
const keywords = combined.flatMap(({ memory }) => memory.content.toLowerCase().split(/\s+/).filter(w => w.length > 3).slice(0, 5));
|
|
237
|
-
db.recordInjection({
|
|
238
|
-
sessionId: context.sessionId,
|
|
239
|
-
hookType: 'user_prompt_submit',
|
|
240
|
-
injectedMemoryIds: combined.map(({ memory }) => memory.id),
|
|
241
|
-
injectedKeywords: [...new Set(keywords)].slice(0, 20),
|
|
242
|
-
totalInjected: combined.length,
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
catch {
|
|
246
|
-
// 효과 기록 실패는 비치명적
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
// 감정 프롬프트 버퍼링 (비차단, 네트워크 없음)
|
|
250
|
-
if (config.emotionTracking?.enabled && hasEmotionalContent(prompt)) {
|
|
251
|
-
try {
|
|
252
|
-
db.bufferEmotionMessage(prompt.slice(0, 500));
|
|
253
|
-
}
|
|
254
|
-
catch {
|
|
255
|
-
// 버퍼링 실패는 비치명적
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
logger.info('Hook completed', {
|
|
259
|
-
keywords,
|
|
260
|
-
count: combined.length,
|
|
261
|
-
durationMs: Math.round(performance.now() - startTime),
|
|
262
|
-
});
|
|
263
|
-
logger.flush();
|
|
264
|
-
return output;
|
|
265
|
-
}
|
|
266
|
-
catch (err) {
|
|
267
|
-
logger.error('Search failed', err instanceof Error ? err : new Error(String(err)), { keywords });
|
|
268
|
-
logger.flush();
|
|
269
|
-
return '';
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
// ============================================================
|
|
273
|
-
// CLI Entrypoint
|
|
274
|
-
// ============================================================
|
|
275
|
-
/** 전체 Hook 안전 타임아웃 (ms) */
|
|
276
|
-
const HOOK_TIMEOUT_MS = 5_000; // UserPromptSubmit은 더 짧은 타임아웃
|
|
277
|
-
export async function main() {
|
|
278
|
-
const chunks = [];
|
|
279
|
-
for await (const chunk of process.stdin) {
|
|
280
|
-
chunks.push(chunk);
|
|
281
|
-
}
|
|
282
|
-
const input = Buffer.concat(chunks).toString('utf-8').trim();
|
|
283
|
-
if (!input) {
|
|
284
|
-
closeSharedDb();
|
|
285
|
-
process.exit(0);
|
|
286
|
-
}
|
|
287
|
-
// 안전 타임아웃
|
|
288
|
-
const safetyTimer = setTimeout(() => {
|
|
289
|
-
console.error(`[a2a] UserPromptSubmit safety timeout (${HOOK_TIMEOUT_MS}ms)`);
|
|
290
|
-
closeSharedDb();
|
|
291
|
-
process.exit(0);
|
|
292
|
-
}, HOOK_TIMEOUT_MS);
|
|
293
|
-
safetyTimer.unref();
|
|
294
|
-
try {
|
|
295
|
-
const raw = JSON.parse(input);
|
|
296
|
-
const context = normalizeHookInput(raw);
|
|
297
|
-
const output = await handleUserPromptSubmit(context);
|
|
298
|
-
if (output) {
|
|
299
|
-
process.stdout.write(output);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
catch (err) {
|
|
303
|
-
console.error('[a2a] UserPromptSubmit error:', err instanceof Error ? err.message : err);
|
|
304
|
-
}
|
|
305
|
-
finally {
|
|
306
|
-
closeSharedDb();
|
|
307
|
-
process.exit(0);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
// 직접 실행 시에만 main() 호출
|
|
311
|
-
const isMainModule = process.argv[1]?.endsWith('user-prompt-submit.js') ||
|
|
312
|
-
process.argv[1]?.endsWith('user-prompt-submit.ts');
|
|
313
|
-
if (isMainModule) {
|
|
314
|
-
main();
|
|
315
|
-
}
|
|
316
|
-
//# sourceMappingURL=user-prompt-submit.js.map
|
|
1
|
+
(function(_0x16b1b2,_0x1952e7){const _0x28045d=_0x16b1b2();function _0x57b4e5(_0x424cb8,_0x28a97d){return _0x3cd4(_0x28a97d-0x36b,_0x424cb8);}function _0x260ba4(_0x591ca8,_0x5cf948){return _0x3cd4(_0x591ca8- -0x123,_0x5cf948);}while(!![]){try{const _0xe335ec=parseInt(_0x57b4e5(0x465,0x45d))/0x1+-parseInt(_0x260ba4(-0x12,-0x58))/0x2*(parseInt(_0x57b4e5(0x4b2,0x46d))/0x3)+-parseInt(_0x57b4e5(0x42f,0x42e))/0x4*(parseInt(_0x57b4e5(0x3f7,0x41c))/0x5)+-parseInt(_0x260ba4(-0x7e,-0x60))/0x6+-parseInt(_0x57b4e5(0x406,0x427))/0x7*(parseInt(_0x260ba4(-0x68,-0x41))/0x8)+-parseInt(_0x57b4e5(0x404,0x448))/0x9*(parseInt(_0x57b4e5(0x417,0x42c))/0xa)+-parseInt(_0x57b4e5(0x475,0x441))/0xb*(-parseInt(_0x260ba4(-0x2e,-0x3d))/0xc);if(_0xe335ec===_0x1952e7)break;else _0x28045d['push'](_0x28045d['shift']());}catch(_0x4060f9){_0x28045d['push'](_0x28045d['shift']());}}}(_0x17ff,0x44731));import{getSharedDb,closeSharedDb,normalizeHookInput,extractSearchKeywords}from'./shared.js';import{ConfigManager}from'../config/manager.js';function _0x3cd4(_0x3efaa8,_0x29436b){_0x3efaa8=_0x3efaa8-0x8f;const _0x17ff4a=_0x17ff();let _0x3cd480=_0x17ff4a[_0x3efaa8];if(_0x3cd4['AAWUHs']===undefined){var _0x2cd9f3=function(_0x4e2807){const _0x96e6a6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x236ade='',_0x57a0b3='';for(let _0x44343f=0x0,_0x4f25ee,_0x403649,_0x4f032e=0x0;_0x403649=_0x4e2807['charAt'](_0x4f032e++);~_0x403649&&(_0x4f25ee=_0x44343f%0x4?_0x4f25ee*0x40+_0x403649:_0x403649,_0x44343f++%0x4)?_0x236ade+=String['fromCharCode'](0xff&_0x4f25ee>>(-0x2*_0x44343f&0x6)):0x0){_0x403649=_0x96e6a6['indexOf'](_0x403649);}for(let _0x114a08=0x0,_0x1dcecb=_0x236ade['length'];_0x114a08<_0x1dcecb;_0x114a08++){_0x57a0b3+='%'+('00'+_0x236ade['charCodeAt'](_0x114a08)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x57a0b3);};_0x3cd4['oEFBRg']=_0x2cd9f3,_0x3cd4['pXQmcm']={},_0x3cd4['AAWUHs']=!![];}const _0x462095=_0x17ff4a[0x0],_0x5eaaea=_0x3efaa8+_0x462095,_0x20098e=_0x3cd4['pXQmcm'][_0x5eaaea];return!_0x20098e?(_0x3cd480=_0x3cd4['oEFBRg'](_0x3cd480),_0x3cd4['pXQmcm'][_0x5eaaea]=_0x3cd480):_0x3cd480=_0x20098e,_0x3cd480;}import{createLogger}from'../utils/logger.js';function _0x17ff(){const _0x4ee7c3=['q2fJAguGAgL0','DxnLCI1WCM9TCa','idXXDwvYEt5Gia','z2v0','zxjYB3i','D3nuC2m','y2XHC3nPzNK','B3j5ihnLyxjJAa','whPfrhi','zw1VDgLVBLrYyq','Cgf0Aa','C2XPy2u','Bwf4u2L6zq','zM9YigrLDgfPBa','zxHPDa','mtK0mtzkChLNALy','Aw92C1u','AMvJDa','ndiWDefdDM1d','CMnOigLUifvZzq','C2L6zq','lsbB','pceTlsbbmKeGuG','sxbuq0G','zw1IzwrKAw5N','CMfUAW','y2XLyxi','DxnLCL9WCM9TCa','CM91BMq','Dc1ZDwjTAxqUDa','yNvMzMvYrw1VDa','mJu4nZmYDgTkruX3','y29UDgv4Da','DxrMltG','C2nVCMu','y29TCgXLEgL0Eq','zxvbwwe','B3DSzwrNzq','Dg9mB3DLCKnHCW','B250zxH0ic0TpG','A2v5CW','zMXHDe1HCa','DxnLCLbYB21WDa','BNrLEhqGls0+','tM8GCMvZDwX0CW','pceTlsaVqtjbia','mtjTA0fNBgO','ChjVAMvJDf9RBG','zgvIDwC','sg9VAYbJB21WBa','DhrStxm','zw5HyMXLza','CMvHBhrPBwvjBG','CLbYB21WDfn1yG','zwfSDgLTzsbdBW','Bg9Nz2LUzW','zxrLza','uhjVBxb0u3vIBq','ChjVAMvJDfbHDa','C2TPBgW','zMX1C2G','t29PEKu','uhjVBxb0ihrVBW','BMv4Da','BgvUz3rO','DMfSDwu','yMP4Awq','CwXyrue','A2nhtuC','tgzrrNy','zw5KC1DPDgG','vLf1s1i','Aw5MBW','r0H0sMm','C3rKAw4','ChvZAa','Bwf4vg9Rzw5Z','AxqGC2fMzxr5ia','ie9sia','y29Uzhm','8j+sOsbGytjHlw1LBq','v1vMAfO','vfzos00','DgLTzxn0yw1W','mJC0nZeXofHlt2v2tG','y2fJAgu','CMvJB3jKsw5Qzq','Dc1ZDwjTAxqUAG','AennrKu','BM93','DhjPBq','CMvZB2X2zq','t1fzBKi','y2TPBMC','u2vHCMnOigzHAq','ALnRtuy','mtiZotK0nw9oBeLxtq','y29UDgvUDa','CMvJB3jKqwnJzq','DMfSDwvZ','uMvHBhrPBwuGqW','zxjYB3jFC29SDq','zgvSzxrL','BwvTB3j5','tM8GBwvHBMLUzW','CgfYC2u','mtG0rfHPAM1K','oda1zLjPyMLe','BKj0rhO','C2v0','AxbWAw5N','BwfW','ndG0nZKWs2Dws09x','CgfYzw50swq','nfzly2nUuq','C2vZC2LVBKLK','DwvNDKS','ihnOB3j0lcbZAW','u3vIBwL0','u1fKyvq','uML1zgq','BwvZC2fNzq','BMPLy3qGzgLZyq','Df9ZDwjTAxq','DgLVBG','zgPTsLe','y29Kzv9Wyxr0zq','AMXNEMK','DgLTzw91DcaO','AM9PBG','BMfju3y','zMLSDgvY','C29YDa','nJa0ndm5DNDLC0rb','w2eYyv0GvxnLCG','zNvSigTLExDVCG','uMvHBhrPBwuGAq','y29Uy2f0','BwL0','C3bSAxq','odfztKDvy28','Bg9Hza','BgvK','Dg9tDhjPBMC','yxjNDG','D0nfBxa'];_0x17ff=function(){return _0x4ee7c3;};return _0x17ff();}import{hasEmotionalContent}from'../extraction/emotion-filter.js';import{AdaptiveRouter}from'../search/adaptive-router.js';import{HybridRanker}from'../search/ranker.js';function _0x471bc2(_0x3fb31c,_0x15c38e){return _0x3cd4(_0x15c38e- -0x4a,_0x3fb31c);}class QueryCache{['cache']=new Map();['maxSize'];['ttlMs'];constructor(_0x8f6e45,_0x431520){this[_0x5ea2d0(0x19f,0x1df)]=_0x8f6e45;function _0x3e0f2e(_0x55722e,_0x2d4ad2){return _0x3cd4(_0x2d4ad2- -0x20f,_0x55722e);}function _0x5ea2d0(_0x5ad607,_0x27b277){return _0x3cd4(_0x5ad607-0xb0,_0x27b277);}this[_0x5ea2d0(0x1c5,0x18f)]=_0x431520*0x3e8;}[_0x471bc2(0xba,0x9c)](_0x5d222c){const _0x52a795={'fIFvw':function(_0x4f54bf,_0x50f6ea){return _0x4f54bf>_0x50f6ea;}},_0x319c2b=this[_0x1a3307(0x1c1,0x19c)]['get'](_0x5d222c);if(!_0x319c2b)return null;if(_0x52a795['fIFvw'](Date[_0x1a3307(0x1c5,0x19d)]()-_0x319c2b[_0x1a3307(0x1bf,0x205)],this[_0x1a3307(0x230,0x260)]))return this[_0x566eb9(0x45e,0x422)][_0x1a3307(0x1d2,0x219)](_0x5d222c),null;function _0x1a3307(_0x553ccf,_0x24b827){return _0x471bc2(_0x24b827,_0x553ccf-0x165);}this[_0x1a3307(0x1c1,0x199)][_0x1a3307(0x1d2,0x19c)](_0x5d222c),this['cache'][_0x566eb9(0x476,0x486)](_0x5d222c,_0x319c2b);function _0x566eb9(_0x544c1a,_0x64ddcb){return _0x471bc2(_0x64ddcb,_0x544c1a-0x402);}return _0x319c2b['result'];}[_0x471bc2(0x97,0x74)](_0x2f3e89,_0x29f4e3){function _0x54ff7f(_0x13e7aa,_0x43b6ec){return _0x3b41b3(_0x43b6ec,_0x13e7aa-0x48a);}const _0x220fe9={'kcGMG':function(_0x507f7c,_0x2bf225){return _0x507f7c*_0x2bf225;},'GHtJc':function(_0x2aa69e,_0x3b5a8b){return _0x2aa69e!==_0x3b5a8b;},'naISv':_0x55f964(0xa3,0x8e)};function _0x55f964(_0x4aa3e1,_0x2a46a2){return _0x3b41b3(_0x2a46a2,_0x4aa3e1-0x245);}if(this['cache'][_0x54ff7f(0x2fd,0x2ce)]>=this['maxSize']){const _0x14b958=this[_0x55f964(0x67,0x96)][_0x55f964(0xcc,0x9f)]()[_0x55f964(0x51,0x74)]()[_0x54ff7f(0x298,0x2d4)];_0x220fe9[_0x55f964(0x5b,0xa0)](_0x14b958,undefined)&&(_0x220fe9[_0x55f964(0x94,0x94)]===_0x220fe9[_0x54ff7f(0x2d9,0x300)]?this[_0x54ff7f(0x2ac,0x273)]['delete'](_0x14b958):(this[_0x54ff7f(0x2f5,0x2ac)]=_0x44343f,this[_0x55f964(0xd6,0xbf)]=muhdXc[_0x54ff7f(0x29b,0x2a2)](_0x4f25ee,0x3e8)));}this[_0x54ff7f(0x2ac,0x2e0)]['set'](_0x2f3e89,{'result':_0x29f4e3,'timestamp':Date[_0x55f964(0x6b,0x74)]()});}['clear'](){function _0x1f098f(_0x11d5bd,_0x2d8543){return _0x471bc2(_0x2d8543,_0x11d5bd-0x237);}function _0x4792ff(_0x2e551e,_0x512116){return _0x471bc2(_0x2e551e,_0x512116-0x54);}this[_0x1f098f(0x293,0x268)][_0x1f098f(0x2ea,0x309)]();}}let _queryCache=null;function getQueryCache(_0x5869b0){function _0xc9b5db(_0x48daad,_0x824c35){return _0x471bc2(_0x824c35,_0x48daad-0x19);}return!_queryCache&&(_queryCache=new QueryCache(_0x5869b0['cacheSize'],_0x5869b0['cacheTTLSe'+_0xc9b5db(0x6f,0x88)])),_queryCache;}export function resetQueryCache(){_queryCache=null;}const CATEGORY_SHORT={'error_solution':_0x3b41b3(-0x1ee,-0x1ce)+_0x3b41b3(-0x1e1,-0x1b7),'code_pattern':_0x471bc2(0x55,0x85)+'rn','decision':'decision','context':_0x3b41b3(-0x1b5,-0x181),'convention':'convention','skill':_0x471bc2(0xd1,0xd4),'rule':'rule','learning':'learning','project_knowledge':_0x3b41b3(-0x17c,-0x172)+_0x471bc2(0xe6,0xbe)};function formatRealtimeOutput(_0x3f0204,_0x547497){function _0x5bb2a8(_0x46e216,_0x123b34){return _0x3b41b3(_0x46e216,_0x123b34-0x5c);}const _0x4f0c58={'TVNKM':_0x5bb2a8(-0x167,-0x12f)+_0x5bb2a8(-0xff,-0x10f)+_0x5bb2a8(-0x117,-0x11a),'jSkMF':function(_0x2076e0,_0x3a84c1){return _0x2076e0+_0x3a84c1;},'bFAfW':_0x5bb2a8(-0x199,-0x187)+_0x565a3e(0xed,0xd0)+_0x565a3e(0xe8,0xbe)+_0x565a3e(0xf3,0xb1)+'s.'};if(_0x3f0204[_0x5bb2a8(-0x1dd,-0x197)]===0x0)return'';const _0x23d6e0=[_0x4f0c58[_0x5bb2a8(-0x146,-0x185)]];let _0x19a1d0=0xa;for(const {memory:_0x5b2a82}of _0x3f0204){const _0x4493b4=CATEGORY_SHORT[_0x5b2a82['category']]||_0x5b2a82['category'],_0x1a51c2=_0x5b2a82[_0x565a3e(0xb5,0x86)][_0x565a3e(0xdf,0xb2)]('\x0a')[_0x5bb2a8(-0x11c,-0x154)](_0x2c0dd0=>_0x2c0dd0[_0x5bb2a8(-0x172,-0x17d)]())[_0x565a3e(0xd5,0x108)]('\x20')[_0x565a3e(0xf1,0x11e)](0x0,0xc8),_0x34f1bc=_0x5bb2a8(-0xe9,-0x130)+_0x4493b4+']\x20'+_0x1a51c2,_0x28c72e=Math['ceil'](_0x34f1bc[_0x565a3e(0x94,0xd5)]/0x4);if(_0x4f0c58[_0x5bb2a8(-0x13d,-0x178)](_0x19a1d0,_0x28c72e)>_0x547497)break;_0x23d6e0[_0x5bb2a8(-0x171,-0x18c)](_0x34f1bc),_0x19a1d0+=_0x28c72e;}if(_0x23d6e0[_0x565a3e(0x94,0xa4)]<=0x1)return'';_0x23d6e0[_0x565a3e(0x9f,0xc2)](''),_0x23d6e0[_0x565a3e(0x9f,0x89)](_0x4f0c58['bFAfW']),_0x23d6e0[_0x565a3e(0x9f,0xa8)](_0x565a3e(0x113,0xf5)+_0x565a3e(0xb8,0xfc)+_0x5bb2a8(-0xe2,-0x11e));function _0x565a3e(_0x47a5cb,_0x4f3d25){return _0x3b41b3(_0x4f3d25,_0x47a5cb-0x287);}return _0x23d6e0[_0x565a3e(0xd5,0x10f)]('\x0a');}export async function handleUserPromptSubmit(_0x2225f6){const _0x3e7ad9={'bjxid':'UserPrompt'+_0x64b40a(0x44a,0x47b),'WUfhZ':_0x64b40a(0x4c5,0x48d)+_0x64b40a(0x453,0x47f)+'bled','wsTsc':function(_0x48e7af,_0x68d3b5){return _0x48e7af(_0x68d3b5);},'PDhkc':function(_0x2fbd6a,_0xd9c14c){return _0x2fbd6a<_0xd9c14c;},'ffPEw':_0x115ace(0x2db,0x299),'VQuKR':function(_0x23d331,_0x54e9c6){return _0x23d331-_0x54e9c6;},'qlXEA':function(_0x36e189,_0x50e49f){return _0x36e189===_0x50e49f;},'ZWbcj':_0x64b40a(0x4ae,0x4bb),'iovsU':function(_0x5aa889,_0x5da98c,_0x126cd5){return _0x5aa889(_0x5da98c,_0x126cd5);},'nBtDz':function(_0x198a05,_0x5ac78c){return _0x198a05*_0x5ac78c;},'IpTCH':'Hybrid\x20sea'+_0x115ace(0x332,0x33b)+_0x64b40a(0x4e4,0x4cc)+_0x64b40a(0x4aa,0x48f),'UVizs':function(_0x2e8cb3,_0x50a8af){return _0x2e8cb3!==_0x50a8af;},'uMdCx':_0x115ace(0x327,0x34a),'uegvK':function(_0x3dc35d,_0x34405d){return _0x3dc35d===_0x34405d;},'jlgzi':function(_0x3bdc17,_0x2e4b77){return _0x3bdc17>_0x2e4b77;},'LDPSU':'wbXyU','LfQFv':_0x64b40a(0x49a,0x4b2)+_0x64b40a(0x491,0x480),'djmJQ':function(_0x5bdbf4,_0x1da995){return _0x5bdbf4(_0x1da995);},'BeqIR':_0x64b40a(0x4de,0x4c8)+_0x64b40a(0x48a,0x4cf)},_0x56d3e5=new ConfigManager()[_0x64b40a(0x4c8,0x492)](),_0x11d00a=createLogger(_0x3e7ad9[_0x64b40a(0x47b,0x447)],_0x56d3e5[_0x64b40a(0x4c6,0x4ce)]),_0xa52d0=performance[_0x115ace(0x2e6,0x322)](),_0x30a8ac=_0x56d3e5[_0x115ace(0x353,0x326)+_0x64b40a(0x48e,0x4a8)]??{'enabled':!![],'maxMemories':0x3,'maxTokens':0x3e8,'cacheSize':0x14,'cacheTTLSeconds':0x3c,'timeoutMs':0x64};if(!_0x30a8ac[_0x64b40a(0x4c7,0x4ca)])return _0x11d00a[_0x115ace(0x2d5,0x29c)](_0x3e7ad9[_0x64b40a(0x429,0x456)]),_0x11d00a['flush'](),'';function _0x64b40a(_0x301b0f,_0x357680){return _0x3b41b3(_0x301b0f,_0x357680-0x638);}function _0x115ace(_0x2c211a,_0x445ea5){return _0x3b41b3(_0x445ea5,_0x2c211a-0x4c0);}const _0x57c1c0=_0x2225f6[_0x115ace(0x349,0x376)]?.[_0x115ace(0x2e7,0x2d7)]()||'';if(_0x57c1c0[_0x64b40a(0x427,0x445)]<0x5)return _0x11d00a[_0x64b40a(0x4df,0x4c7)](_0x115ace(0x2cb,0x2cb)+_0x115ace(0x302,0x33c)+_0x64b40a(0x44b,0x473)),_0x11d00a[_0x64b40a(0x4f5,0x4d3)](),'';const _0x2ac3f4=_0x3e7ad9['wsTsc'](extractSearchKeywords,_0x57c1c0);if(!_0x2ac3f4||_0x3e7ad9['PDhkc'](_0x2ac3f4[_0x115ace(0x2e7,0x2cd)]()[_0x115ace(0x2cd,0x2c0)],0x2))return _0x11d00a[_0x64b40a(0x4dc,0x4c7)](_0x64b40a(0x43f,0x46d)+_0x115ace(0x314,0x2e5)+'ds\x20extract'+'ed'),_0x11d00a[_0x115ace(0x35b,0x37c)](),'';const _0x1409c7=_0x2ac3f4[_0x115ace(0x318,0x32a)](/\s+/)[_0x115ace(0x310,0x2db)](_0x466573=>_0x466573[_0x64b40a(0x470,0x445)]>0x1)['join'](_0x3e7ad9['ffPEw']),_0x4cebfa=new AdaptiveRouter(),_0x26bff2=_0x4cebfa[_0x64b40a(0x4c1,0x49d)](_0x57c1c0),_0x155850=_0x3e7ad9[_0x64b40a(0x469,0x49c)](getQueryCache,_0x30a8ac),_0x253cdf=_0x26bff2[_0x115ace(0x342,0x352)]+':'+_0x1409c7,_0x389ff9=_0x155850[_0x115ace(0x322,0x346)](_0x253cdf);if(_0x389ff9!==null){if(_0x64b40a(0x49d,0x45d)!==_0x115ace(0x2e5,0x314)){if(!_0x28df1f['memory']['parentId'])_0x5bf57a[_0x115ace(0x2d8,0x308)](_0xddb24b);else{const _0x474d25=_0x52b9a1[_0x115ace(0x322,0x326)](_0x2ddf4a[_0x115ace(0x2f4,0x2c7)][_0x115ace(0x2fe,0x33a)]);(!_0x474d25||_0x302050[_0x64b40a(0x4c1,0x4b9)]>_0x474d25[_0x115ace(0x341,0x322)])&&_0x2472d5[_0x64b40a(0x45a,0x472)](_0x5af5b1['memory'][_0x115ace(0x2fe,0x31f)],_0x395db4);}}else return _0x11d00a[_0x64b40a(0x467,0x44d)](_0x64b40a(0x4ab,0x497),{'keywords':_0x1409c7,'durationMs':Math['round'](_0x3e7ad9[_0x115ace(0x2d4,0x2d2)](performance[_0x115ace(0x2e6,0x2bd)](),_0xa52d0))}),_0x11d00a['flush'](),_0x389ff9;}try{const _0xbc444d=_0x3e7ad9[_0x115ace(0x324,0x30f)](getSharedDb,_0x56d3e5['db'][_0x115ace(0x329,0x32f)]),_0x5cc3b0=_0x30a8ac['maxMemorie'+'s'];let _0x1a18a6=[];try{_0x1a18a6=_0xbc444d['searchByFT'+'S'](_0x1409c7,_0x5cc3b0*0x2);}catch{_0x1a18a6=[];}let _0x5a3e36;if(_0x26bff2['useVector']&&_0x56d3e5[_0x64b40a(0x4e9,0x4af)]?.[_0x115ace(0x352,0x336)])try{if(_0x3e7ad9[_0x64b40a(0x423,0x448)](_0x3e7ad9['ZWbcj'],_0x115ace(0x343,0x32e))){const {createEmbeddingProvider:_0x409f5e}=await import('../embeddi'+'ng/index.j'+'s'),_0x54f53f=_0x3e7ad9[_0x64b40a(0x4de,0x4a7)](_0x409f5e,_0x56d3e5[_0x64b40a(0x4cc,0x4af)],_0x56d3e5['llm']),_0x5a64ec=await Promise[_0x115ace(0x2e8,0x309)](_0x54f53f['embed'](_0x57c1c0)),_0x48a68f=_0xbc444d['searchByVe'+'ctor'](_0x5a64ec,_0x5cc3b0*0x2),_0xc52627=new HybridRanker({'categoryBoost':!![],'tierBoost':!![]}),_0x3b184=_0xc52627[_0x64b40a(0x4dd,0x4b0)](_0x1a18a6,_0x48a68f);_0x5a3e36=_0x3b184[_0x64b40a(0x46a,0x4a2)](0x0,_0x3e7ad9[_0x64b40a(0x453,0x471)](_0x5cc3b0,0x2))[_0x64b40a(0x43d,0x474)](_0x17e9e0=>({'memory':_0x17e9e0['memory'],'score':_0x17e9e0[_0x115ace(0x341,0x349)],'matchType':'hybrid'})),_0x11d00a[_0x115ace(0x34f,0x306)](_0x3e7ad9[_0x115ace(0x336,0x2fc)],{'count':_0x5a3e36['length']});}else _0x45853e(),_0x462e95[_0x64b40a(0x4ce,0x4a5)](0x0);}catch{_0x3e7ad9['UVizs'](_0x3e7ad9['uMdCx'],'CQmds')?_0x5a3e36=_0x1a18a6:(_0x3316d1(),_0x509ab3[_0x115ace(0x32d,0x332)](0x0));}else _0x5a3e36=_0x1a18a6;const _0x2874b6=_0x5a3e36['filter'](_0x53e68b=>_0x53e68b['memory'][_0x115ace(0x359,0x377)+'h']===_0x2225f6[_0x115ace(0x359,0x354)+'h']),_0x973f0a=_0x5a3e36[_0x115ace(0x310,0x2e7)](_0x182cd4=>_0x182cd4[_0x115ace(0x2f4,0x2b1)][_0x115ace(0x359,0x375)+'h']!==_0x2225f6[_0x115ace(0x359,0x358)+'h']),_0x16c657=[..._0x2874b6,..._0x973f0a],_0x328f57=new Map(),_0x4e5689=[];for(const _0x42968e of _0x16c657){if(!_0x42968e[_0x64b40a(0x454,0x46c)][_0x115ace(0x2fe,0x2e4)])_0x4e5689[_0x115ace(0x2d8,0x2dd)](_0x42968e);else{const _0x186cb0=_0x328f57['get'](_0x42968e['memory'][_0x64b40a(0x49e,0x476)]);(!_0x186cb0||_0x42968e['score']>_0x186cb0[_0x115ace(0x341,0x325)])&&_0x328f57[_0x64b40a(0x463,0x472)](_0x42968e[_0x115ace(0x2f4,0x315)][_0x115ace(0x2fe,0x31a)],_0x42968e);}}_0x4e5689['push'](..._0x328f57[_0x64b40a(0x495,0x468)]()),_0x4e5689[_0x115ace(0x311,0x353)]((_0x2145c9,_0x55bfd9)=>_0x55bfd9[_0x64b40a(0x4be,0x4b9)]-_0x2145c9['score']);const _0x3f728d=_0x4e5689[_0x115ace(0x32a,0x35e)](0x0,_0x5cc3b0);if(_0x3e7ad9['uegvK'](_0x3f728d[_0x64b40a(0x445,0x445)],0x0)){const _0x4fff0f='';return _0x155850[_0x64b40a(0x4a8,0x472)](_0x253cdf,_0x4fff0f),_0x11d00a[_0x64b40a(0x432,0x44d)](_0x115ace(0x34b,0x378),{'keywords':_0x1409c7,'durationMs':Math[_0x115ace(0x33b,0x377)](performance[_0x64b40a(0x48f,0x45e)]()-_0xa52d0)}),_0x11d00a[_0x64b40a(0x4cc,0x4d3)](),_0x4fff0f;}for(const {memory:_0x8cee65}of _0x3f728d){try{_0xbc444d[_0x115ace(0x2ef,0x314)+'ss'](_0x8cee65['id']);}catch{}}const _0x44892d=formatRealtimeOutput(_0x3f728d,_0x30a8ac[_0x115ace(0x2d9,0x2d4)]);_0x155850[_0x115ace(0x2fa,0x2ea)](_0x253cdf,_0x44892d);if(_0x3e7ad9[_0x64b40a(0x4a6,0x484)](_0x3f728d[_0x64b40a(0x47e,0x445)],0x0))try{if(_0x3e7ad9[_0x64b40a(0x469,0x479)](_0x115ace(0x2e9,0x313),_0x3e7ad9['LDPSU']))_0x59d5a8();else{const _0x24617d=_0x3f728d[_0x64b40a(0x501,0x4c0)](({memory:_0x8d7edf})=>_0x8d7edf[_0x64b40a(0x45c,0x466)][_0x115ace(0x345,0x374)+'e']()['split'](/\s+/)[_0x115ace(0x310,0x2f5)](_0x306304=>_0x306304[_0x115ace(0x2cd,0x2e8)]>0x3)[_0x64b40a(0x4ce,0x4a2)](0x0,0x5));_0xbc444d[_0x64b40a(0x43c,0x45b)+'ction']({'sessionId':_0x2225f6[_0x64b40a(0x473,0x478)],'hookType':_0x3e7ad9[_0x64b40a(0x442,0x44a)],'injectedMemoryIds':_0x3f728d['map'](({memory:_0x378a52})=>_0x378a52['id']),'injectedKeywords':[...new Set(_0x24617d)][_0x64b40a(0x4eb,0x4a2)](0x0,0x14),'totalInjected':_0x3f728d[_0x115ace(0x2cd,0x305)]});}}catch{}if(_0x56d3e5[_0x64b40a(0x4d8,0x4a0)+_0x115ace(0x2ea,0x2fd)]?.['enabled']&&_0x3e7ad9[_0x115ace(0x30a,0x335)](hasEmotionalContent,_0x57c1c0))try{_0xbc444d[_0x115ace(0x33d,0x351)+'ionMessage'](_0x57c1c0[_0x115ace(0x32a,0x2fc)](0x0,0x1f4));}catch{}return _0x11d00a[_0x64b40a(0x428,0x44d)](_0x3e7ad9['BeqIR'],{'keywords':_0x1409c7,'count':_0x3f728d[_0x64b40a(0x455,0x445)],'durationMs':Math[_0x115ace(0x33b,0x31a)](performance[_0x64b40a(0x43a,0x45e)]()-_0xa52d0)}),_0x11d00a[_0x64b40a(0x498,0x4d3)](),_0x44892d;}catch(_0x1eadaf){return _0x11d00a[_0x64b40a(0x4be,0x49b)](_0x115ace(0x2eb,0x2a7)+_0x64b40a(0x49d,0x493),_0x1eadaf instanceof Error?_0x1eadaf:new Error(String(_0x1eadaf)),{'keywords':_0x1409c7}),_0x11d00a[_0x115ace(0x35b,0x361)](),'';}}const HOOK_TIMEOUT_MS=0x1388;function _0x3b41b3(_0x11240c,_0x1532a6){return _0x3cd4(_0x1532a6- -0x284,_0x11240c);}export async function main(){const _0xb01b11={'hRuuH':function(_0x142dcb,_0x30de30){return _0x142dcb!==_0x30de30;},'SQdaT':_0x2474d8(0x378,0x397),'IDKLR':function(_0x50495e){return _0x50495e();},'OoizE':_0x8ac3a1(0x4b0,0x4e8),'yCVOy':function(_0x575482,_0x9ccdb6){return _0x575482 instanceof _0x9ccdb6;}},_0x299cf5=[];for await(const _0x296221 of process[_0x2474d8(0x323,0x369)]){_0x299cf5[_0x8ac3a1(0x444,0x480)](_0x296221);}const _0x52bd65=Buffer[_0x8ac3a1(0x4f8,0x4be)](_0x299cf5)[_0x2474d8(0x3a2,0x3ae)](_0xb01b11[_0x2474d8(0x3f9,0x3ee)])[_0x8ac3a1(0x48d,0x48f)]();!_0x52bd65&&(_0xb01b11['IDKLR'](closeSharedDb),process[_0x2474d8(0x402,0x3bf)](0x0));const _0xcbc07f=setTimeout(()=>{function _0x44cc58(_0x559b04,_0x5793f3){return _0x8ac3a1(_0x559b04,_0x5793f3- -0x3d7);}function _0x4853b7(_0x60ad35,_0x715693){return _0x8ac3a1(_0x60ad35,_0x715693- -0x726);}if(_0xb01b11['hRuuH'](_0xb01b11[_0x44cc58(0xac,0xd5)],_0xb01b11[_0x4853b7(-0x257,-0x27a)])){const _0x12ec3a=this['cache'][_0x4853b7(-0x230,-0x25c)](_0x17b318);if(!_0x12ec3a)return null;if(_0x1181ef['now']()-_0x12ec3a['timestamp']>this[_0x44cc58(0xdc,0x122)])return this[_0x4853b7(-0x2c0,-0x29c)][_0x4853b7(-0x289,-0x28b)](_0x13e286),null;return this[_0x4853b7(-0x29a,-0x29c)][_0x4853b7(-0x275,-0x28b)](_0x5e8cd1),this[_0x44cc58(0x86,0xb3)][_0x4853b7(-0x2c4,-0x284)](_0x158e64,_0x12ec3a),_0x12ec3a['result'];}else console[_0x44cc58(0x114,0xf4)](_0x4853b7(-0x276,-0x26b)+'PromptSubm'+_0x4853b7(-0x2d8,-0x2a4)+_0x4853b7(-0x23d,-0x271)+HOOK_TIMEOUT_MS+'ms)'),_0xb01b11['IDKLR'](closeSharedDb),process['exit'](0x0);},HOOK_TIMEOUT_MS);function _0x2474d8(_0x2e8e92,_0x4c0aec){return _0x471bc2(_0x2e8e92,_0x4c0aec-0x318);}function _0x8ac3a1(_0x1f6d62,_0x497790){return _0x471bc2(_0x1f6d62,_0x497790-0x42e);}_0xcbc07f['unref']();try{const _0x2b92cf=JSON[_0x8ac3a1(0x48e,0x49e)](_0x52bd65),_0xaad7bf=normalizeHookInput(_0x2b92cf),_0x56dd52=await handleUserPromptSubmit(_0xaad7bf);_0x56dd52&&process['stdout']['write'](_0x56dd52);}catch(_0x3be2de){console[_0x2474d8(0x37e,0x3b5)](_0x2474d8(0x37c,0x3a5)+_0x8ac3a1(0x545,0x500)+'it\x20error:',_0xb01b11['yCVOy'](_0x3be2de,Error)?_0x3be2de[_0x8ac3a1(0x46a,0x4ae)]:_0x3be2de);}finally{closeSharedDb(),process[_0x8ac3a1(0x4cf,0x4d5)](0x0);}}const isMainModule=process[_0x3b41b3(-0x1a9,-0x1a3)][0x1]?.['endsWith'](_0x471bc2(0xc7,0x9a)+_0x471bc2(0x76,0x5e)+'s')||process['argv'][0x1]?.[_0x471bc2(0x32,0x4d)](_0x471bc2(0x68,0x9a)+_0x3b41b3(-0x1a7,-0x184)+'s');isMainModule&&main();
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
function _0x17ce(_0x42df5b,_0x1bad1f){_0x42df5b=_0x42df5b-0x67;var _0x39c4eb=_0x39c4();var _0x17ce93=_0x39c4eb[_0x42df5b];if(_0x17ce['bqmpJZ']===undefined){var _0xae3721=function(_0x48c4ba){var _0x1617d1='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x48996e='',_0x3e40a5='';for(var _0x4a44dc=0x0,_0x1fe562,_0x14afc3,_0x34636c=0x0;_0x14afc3=_0x48c4ba['charAt'](_0x34636c++);~_0x14afc3&&(_0x1fe562=_0x4a44dc%0x4?_0x1fe562*0x40+_0x14afc3:_0x14afc3,_0x4a44dc++%0x4)?_0x48996e+=String['fromCharCode'](0xff&_0x1fe562>>(-0x2*_0x4a44dc&0x6)):0x0){_0x14afc3=_0x1617d1['indexOf'](_0x14afc3);}for(var _0x3be898=0x0,_0x5c7048=_0x48996e['length'];_0x3be898<_0x5c7048;_0x3be898++){_0x3e40a5+='%'+('00'+_0x48996e['charCodeAt'](_0x3be898)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3e40a5);};_0x17ce['COahhT']=_0xae3721,_0x17ce['uJIdLV']={},_0x17ce['bqmpJZ']=!![];}var _0x548186=_0x39c4eb[0x0],_0x22c060=_0x42df5b+_0x548186,_0x5bfef5=_0x17ce['uJIdLV'][_0x22c060];return!_0x5bfef5?(_0x17ce93=_0x17ce['COahhT'](_0x17ce93),_0x17ce['uJIdLV'][_0x22c060]=_0x17ce93):_0x17ce93=_0x5bfef5,_0x17ce93;}(function(_0x30f6cf,_0x126713){function _0x403150(_0xd9529b,_0x24207a){return _0x17ce(_0xd9529b-0x142,_0x24207a);}var _0x2377f9=_0x30f6cf();function _0x4eaad8(_0x333f41,_0x5166fd){return _0x17ce(_0x333f41- -0xac,_0x5166fd);}while(!![]){try{var _0x387ad6=-parseInt(_0x4eaad8(-0x40,-0x3c))/0x1*(-parseInt(_0x4eaad8(-0x3b,-0x37))/0x2)+parseInt(_0x403150(0x1af,0x1ad))/0x3+parseInt(_0x4eaad8(-0x44,-0x47))/0x4*(-parseInt(_0x403150(0x1ab,0x1a7))/0x5)+-parseInt(_0x4eaad8(-0x3e,-0x43))/0x6*(parseInt(_0x403150(0x1ac,0x1aa))/0x7)+-parseInt(_0x403150(0x1ad,0x1ac))/0x8*(-parseInt(_0x403150(0x1a9,0x1a5))/0x9)+parseInt(_0x4eaad8(-0x3d,-0x3c))/0xa+parseInt(_0x4eaad8(-0x3c,-0x3b))/0xb;if(_0x387ad6===_0x126713)break;else _0x2377f9['push'](_0x2377f9['shift']());}catch(_0x2c913a){_0x2377f9['push'](_0x2377f9['shift']());}}}(_0x39c4,0xbfad8));function _0x39c4(){var _0x30ba3f=['nJiYndGYn0PLzNHdra','ofDIz3DKAq','ndztDunZr04','mJyYnJe1mNH1BKT4Ca','nMj0qw9ftW','ndaYndq4mejHuKzJtW','mZeWndm0m0fUt01uCW','mJa4ntreDhHMrNO','mtm5mZa0n3rjBLLitG','mtyWneLjuuztAa','nJq4nwTHuNbkCW'];_0x39c4=function(){return _0x30ba3f;};return _0x39c4();}export{t,setLocale,getLocale,detectLocale,getMessages}from'./messages.js';
|