kratos-mcp 1.1.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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +351 -0
  3. package/dist/host-middleware-v2.d.ts +3 -0
  4. package/dist/host-middleware-v2.d.ts.map +1 -0
  5. package/dist/host-middleware-v2.js +471 -0
  6. package/dist/host-middleware-v2.js.map +1 -0
  7. package/dist/index.d.ts +21 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +939 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/memory-server/concept-store-enhanced.d.ts +88 -0
  12. package/dist/memory-server/concept-store-enhanced.d.ts.map +1 -0
  13. package/dist/memory-server/concept-store-enhanced.js +392 -0
  14. package/dist/memory-server/concept-store-enhanced.js.map +1 -0
  15. package/dist/memory-server/concept-store.d.ts +58 -0
  16. package/dist/memory-server/concept-store.d.ts.map +1 -0
  17. package/dist/memory-server/concept-store.js +329 -0
  18. package/dist/memory-server/concept-store.js.map +1 -0
  19. package/dist/memory-server/context-broker.d.ts +63 -0
  20. package/dist/memory-server/context-broker.d.ts.map +1 -0
  21. package/dist/memory-server/context-broker.js +340 -0
  22. package/dist/memory-server/context-broker.js.map +1 -0
  23. package/dist/memory-server/database.d.ts +61 -0
  24. package/dist/memory-server/database.d.ts.map +1 -0
  25. package/dist/memory-server/database.js +309 -0
  26. package/dist/memory-server/database.js.map +1 -0
  27. package/dist/modules/prd/index.d.ts +47 -0
  28. package/dist/modules/prd/index.d.ts.map +1 -0
  29. package/dist/modules/prd/index.js +220 -0
  30. package/dist/modules/prd/index.js.map +1 -0
  31. package/dist/modules/prompt/index.d.ts +47 -0
  32. package/dist/modules/prompt/index.d.ts.map +1 -0
  33. package/dist/modules/prompt/index.js +313 -0
  34. package/dist/modules/prompt/index.js.map +1 -0
  35. package/dist/project-manager.d.ts +69 -0
  36. package/dist/project-manager.d.ts.map +1 -0
  37. package/dist/project-manager.js +207 -0
  38. package/dist/project-manager.js.map +1 -0
  39. package/dist/security/data-retention.d.ts +104 -0
  40. package/dist/security/data-retention.d.ts.map +1 -0
  41. package/dist/security/data-retention.js +444 -0
  42. package/dist/security/data-retention.js.map +1 -0
  43. package/dist/security/encryption.d.ts +48 -0
  44. package/dist/security/encryption.d.ts.map +1 -0
  45. package/dist/security/encryption.js +131 -0
  46. package/dist/security/encryption.js.map +1 -0
  47. package/dist/security/pii-detector.d.ts +61 -0
  48. package/dist/security/pii-detector.d.ts.map +1 -0
  49. package/dist/security/pii-detector.js +220 -0
  50. package/dist/security/pii-detector.js.map +1 -0
  51. package/dist/tools/ci-hooks.d.ts +48 -0
  52. package/dist/tools/ci-hooks.d.ts.map +1 -0
  53. package/dist/tools/ci-hooks.js +452 -0
  54. package/dist/tools/ci-hooks.js.map +1 -0
  55. package/dist/tools/migrate-to-sqlite.d.ts +32 -0
  56. package/dist/tools/migrate-to-sqlite.d.ts.map +1 -0
  57. package/dist/tools/migrate-to-sqlite.js +341 -0
  58. package/dist/tools/migrate-to-sqlite.js.map +1 -0
  59. package/dist/types/index.d.ts +151 -0
  60. package/dist/types/index.d.ts.map +1 -0
  61. package/dist/types/index.js +2 -0
  62. package/dist/types/index.js.map +1 -0
  63. package/dist/utils/logger.d.ts +9 -0
  64. package/dist/utils/logger.d.ts.map +1 -0
  65. package/dist/utils/logger.js +33 -0
  66. package/dist/utils/logger.js.map +1 -0
  67. package/dist/utils/mcp-logger.d.ts +14 -0
  68. package/dist/utils/mcp-logger.d.ts.map +1 -0
  69. package/dist/utils/mcp-logger.js +40 -0
  70. package/dist/utils/mcp-logger.js.map +1 -0
  71. package/package.json +88 -0
@@ -0,0 +1,471 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'child_process';
3
+ import { createInterface } from 'readline';
4
+ import path from 'path';
5
+ import fs from 'fs-extra';
6
+ import yaml from 'js-yaml';
7
+ import { Logger } from './utils/logger.js';
8
+ const logger = new Logger('KratosMiddlewareV2');
9
+ class KratosMiddlewareV2 {
10
+ mcpProcess;
11
+ currentTurn;
12
+ activeProject = null;
13
+ config;
14
+ redactPatterns;
15
+ triggerPatterns;
16
+ constructor() {
17
+ this.currentTurn = {
18
+ cwd: process.cwd(),
19
+ openFiles: [],
20
+ toolCalls: [],
21
+ timestamp: new Date(),
22
+ };
23
+ this.config = this.loadConfig();
24
+ this.redactPatterns = this.config.redact.map(pattern => new RegExp(pattern, 'gi'));
25
+ this.triggerPatterns = this.config.triggers.map(pattern => new RegExp(pattern, 'i'));
26
+ }
27
+ async start(mcpServerPath) {
28
+ // Detect and load active project
29
+ await this.detectActiveProject();
30
+ // Start MCP server
31
+ this.mcpProcess = spawn('node', [mcpServerPath], {
32
+ stdio: ['pipe', 'pipe', 'pipe'],
33
+ env: {
34
+ ...process.env,
35
+ KRATOS_ACTIVE_PROJECT: this.activeProject?.project_id || '',
36
+ KRATOS_PROJECT_ROOT: this.activeProject?.root || process.cwd(),
37
+ },
38
+ });
39
+ this.setupCommunication();
40
+ logger.info('🔱 Kratos Middleware V2 - Production Ready');
41
+ logger.info(`📁 Active Project: ${this.activeProject?.name || 'None'}`);
42
+ logger.info(`🎯 Mode: ${this.config.mode.toUpperCase()}`);
43
+ logger.info(`💾 Auto-save: ${this.config.autosave ? 'ON' : 'OFF'}`);
44
+ logger.info(`💰 Budget: ${this.config.budget_bytes} bytes, Top-K: ${this.config.top_k}`);
45
+ }
46
+ loadConfig() {
47
+ const defaultConfig = {
48
+ mode: 'hard',
49
+ autosave: true,
50
+ confirm_on_save: false,
51
+ budget_bytes: 1024,
52
+ top_k: 5,
53
+ ttl_days_low: 21,
54
+ allowlist_concepts: [],
55
+ triggers: [
56
+ '(decision:|we chose|we\'ll use)',
57
+ '(fixed:|bugfix|root cause)',
58
+ '(feature shipped|progress:)',
59
+ '(path:|routes:|endpoint:)',
60
+ '(call me \\w+)',
61
+ '(remind me|todo:)',
62
+ '(prefer(s)? .+)',
63
+ '(always .+|never .+)',
64
+ ],
65
+ redact: [
66
+ '(sk_live_[A-Za-z0-9]+)',
67
+ '(sk_test_[A-Za-z0-9]+)',
68
+ '([A-Fa-f0-9]{64})', // SHA256 hashes
69
+ '(api[_-]?key[s]?\\s*[:=]\\s*["\']?([^"\'\\s]+))',
70
+ '(password[s]?\\s*[:=]\\s*["\']?([^"\'\\s]+))',
71
+ '(secret[s]?\\s*[:=]\\s*["\']?([^"\'\\s]+))',
72
+ '(token[s]?\\s*[:=]\\s*["\']?([^"\'\\s]+))',
73
+ ],
74
+ };
75
+ // Try to load project-specific config
76
+ const configPath = path.join(process.cwd(), '.kratos', 'config.yaml');
77
+ if (fs.existsSync(configPath)) {
78
+ try {
79
+ const fileConfig = yaml.load(fs.readFileSync(configPath, 'utf8'));
80
+ return { ...defaultConfig, ...fileConfig };
81
+ }
82
+ catch (error) {
83
+ logger.warn('Failed to load config, using defaults:', error);
84
+ }
85
+ }
86
+ return defaultConfig;
87
+ }
88
+ async detectActiveProject() {
89
+ const projectJsonPath = path.join(process.cwd(), '.kratos', 'project.json');
90
+ if (fs.existsSync(projectJsonPath)) {
91
+ try {
92
+ this.activeProject = await fs.readJson(projectJsonPath);
93
+ logger.info(`Loaded project: ${this.activeProject?.name}`);
94
+ }
95
+ catch (error) {
96
+ logger.warn('Failed to load project.json:', error);
97
+ }
98
+ }
99
+ else {
100
+ // Create default project
101
+ const projectId = this.generateProjectId();
102
+ this.activeProject = {
103
+ project_id: projectId,
104
+ name: path.basename(process.cwd()),
105
+ root: process.cwd(),
106
+ repo_hash: await this.getRepoHash(),
107
+ };
108
+ await fs.ensureDir(path.dirname(projectJsonPath));
109
+ await fs.writeJson(projectJsonPath, this.activeProject, { spaces: 2 });
110
+ logger.info(`Created new project: ${this.activeProject.name}`);
111
+ }
112
+ }
113
+ async getRepoHash() {
114
+ try {
115
+ const { spawn } = await import('child_process');
116
+ return new Promise((resolve) => {
117
+ const git = spawn('git', ['rev-parse', 'HEAD'], { stdio: 'pipe' });
118
+ let hash = '';
119
+ git.stdout.on('data', (data) => { hash += data.toString(); });
120
+ git.on('close', () => resolve(hash.trim() || undefined));
121
+ git.on('error', () => resolve(undefined));
122
+ });
123
+ }
124
+ catch {
125
+ return undefined;
126
+ }
127
+ }
128
+ generateProjectId() {
129
+ return `proj_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
130
+ }
131
+ setupCommunication() {
132
+ // Host → MCP
133
+ const stdinReader = createInterface({ input: process.stdin });
134
+ stdinReader.on('line', (line) => {
135
+ try {
136
+ const message = JSON.parse(line);
137
+ this.interceptHostToMcp(message);
138
+ this.mcpProcess.stdin.write(line + '\n');
139
+ }
140
+ catch (e) {
141
+ // Forward non-JSON lines as-is
142
+ this.mcpProcess.stdin.write(line + '\n');
143
+ }
144
+ });
145
+ // MCP → Host
146
+ const mcpReader = createInterface({ input: this.mcpProcess.stdout });
147
+ mcpReader.on('line', (line) => {
148
+ try {
149
+ const message = JSON.parse(line);
150
+ this.interceptMcpToHost(message);
151
+ process.stdout.write(line + '\n');
152
+ }
153
+ catch (e) {
154
+ // Forward non-JSON lines as-is
155
+ process.stdout.write(line + '\n');
156
+ }
157
+ });
158
+ // Error handling
159
+ this.mcpProcess.stderr.on('data', (data) => {
160
+ logger.error('MCP stderr:', data.toString());
161
+ });
162
+ }
163
+ interceptHostToMcp(message) {
164
+ // Track tool calls and context
165
+ if (message.method === 'tools/call') {
166
+ this.currentTurn.toolCalls.push({
167
+ name: message.params?.name,
168
+ args: message.params?.arguments,
169
+ });
170
+ }
171
+ // Update context from host
172
+ if (message.params?.context) {
173
+ this.currentTurn.openFiles = message.params.context.openFiles || [];
174
+ this.currentTurn.cwd = message.params.context.cwd || this.currentTurn.cwd;
175
+ }
176
+ // Track user messages
177
+ if (message.method === 'conversation/user' || message.params?.role === 'user') {
178
+ this.currentTurn.userMessage = message.params?.content || message.params?.message;
179
+ }
180
+ }
181
+ interceptMcpToHost(message) {
182
+ // Track tool results
183
+ if (message.id && this.currentTurn.toolCalls.length > 0) {
184
+ const lastTool = this.currentTurn.toolCalls[this.currentTurn.toolCalls.length - 1];
185
+ if (!lastTool.result) {
186
+ lastTool.result = message.result;
187
+ }
188
+ }
189
+ // Track assistant responses
190
+ if (message.params?.role === 'assistant' || message.method === 'conversation/assistant') {
191
+ this.currentTurn.assistantMessage = message.params?.content || message.params?.message;
192
+ }
193
+ // Detect turn completion and trigger processing
194
+ if (this.isTurnComplete(message)) {
195
+ setImmediate(() => this.processTurnEnd());
196
+ }
197
+ }
198
+ isTurnComplete(message) {
199
+ // Multiple heuristics for turn detection
200
+ return (message.method === 'turn/complete' ||
201
+ message.method === 'conversation/complete' ||
202
+ (message.result && this.currentTurn.assistantMessage) ||
203
+ (this.currentTurn.toolCalls.length > 0 && message.result));
204
+ }
205
+ async processTurnEnd() {
206
+ if (!this.config.autosave || !this.activeProject)
207
+ return;
208
+ try {
209
+ // Extract important facts from the dialogue
210
+ const candidates = this.extractImportantFacts();
211
+ for (const candidate of candidates) {
212
+ if (this.config.confirm_on_save) {
213
+ // In production, this would integrate with the host's confirmation system
214
+ logger.info(`Would save: ${candidate.summary} (confirmation required)`);
215
+ }
216
+ else {
217
+ await this.autoSaveMemory(candidate);
218
+ }
219
+ }
220
+ // Inject context for next turn if needed
221
+ if (this.currentTurn.openFiles.length > 0) {
222
+ await this.injectContext();
223
+ }
224
+ }
225
+ catch (error) {
226
+ logger.error('Turn processing failed:', error);
227
+ }
228
+ finally {
229
+ // Reset turn state
230
+ this.resetTurn();
231
+ }
232
+ }
233
+ extractImportantFacts() {
234
+ const candidates = [];
235
+ const dialogue = this.buildDialogue();
236
+ // Pattern-based extraction
237
+ for (const [index, pattern] of this.triggerPatterns.entries()) {
238
+ const match = dialogue.match(pattern);
239
+ if (match) {
240
+ const candidate = this.buildCandidate(match, this.config.triggers[index], dialogue);
241
+ if (candidate) {
242
+ candidates.push(candidate);
243
+ }
244
+ }
245
+ }
246
+ // Tool-based pattern detection
247
+ const toolPatterns = this.detectToolPatterns();
248
+ candidates.push(...toolPatterns);
249
+ // Deduplicate by summary
250
+ return this.deduplicateCandidates(candidates);
251
+ }
252
+ buildCandidate(match, pattern, dialogue) {
253
+ const matchedText = match[0];
254
+ const summary = this.generateSummary(matchedText, pattern);
255
+ const text = this.redactSecrets(this.extractContext(dialogue, match.index || 0));
256
+ // Classify and tag
257
+ const { type, tags, importance } = this.classifyContent(pattern, text);
258
+ const paths = this.extractPaths(text);
259
+ return {
260
+ summary,
261
+ text,
262
+ tags: [...tags, type],
263
+ paths,
264
+ importance,
265
+ pattern
266
+ };
267
+ }
268
+ detectToolPatterns() {
269
+ const candidates = [];
270
+ // Bug fix detection
271
+ if (this.hasBugFixPattern()) {
272
+ candidates.push({
273
+ summary: 'Bug fix documented',
274
+ text: this.buildDialogue(),
275
+ tags: ['bugfix', 'auto-detected'],
276
+ paths: this.inferPathsFromFiles(),
277
+ importance: 4,
278
+ pattern: 'tool-pattern-bugfix'
279
+ });
280
+ }
281
+ // Architecture decision detection
282
+ if (this.hasArchitecturePattern()) {
283
+ candidates.push({
284
+ summary: 'Architecture decision made',
285
+ text: this.buildDialogue(),
286
+ tags: ['architecture', 'decision', 'auto-detected'],
287
+ paths: this.inferPathsFromFiles(),
288
+ importance: 5,
289
+ pattern: 'tool-pattern-architecture'
290
+ });
291
+ }
292
+ return candidates;
293
+ }
294
+ hasBugFixPattern() {
295
+ const hasErrorSearch = this.currentTurn.toolCalls.some(t => t.name === 'memory.search' &&
296
+ JSON.stringify(t.args).toLowerCase().includes('error'));
297
+ const hasCodeChanges = this.currentTurn.toolCalls.some(t => ['memory.save', 'prd.update'].includes(t.name));
298
+ return hasErrorSearch && hasCodeChanges;
299
+ }
300
+ hasArchitecturePattern() {
301
+ const hasPRDAccess = this.currentTurn.toolCalls.some(t => t.name === 'prd.fetch');
302
+ const hasContextCheck = this.currentTurn.toolCalls.some(t => t.name === 'context.preview');
303
+ return hasPRDAccess && hasContextCheck;
304
+ }
305
+ async autoSaveMemory(candidate) {
306
+ const saveRequest = {
307
+ jsonrpc: '2.0',
308
+ id: Date.now(),
309
+ method: 'tools/call',
310
+ params: {
311
+ name: 'memory.save',
312
+ arguments: {
313
+ summary: candidate.summary,
314
+ text: candidate.text,
315
+ tags: candidate.tags,
316
+ paths: candidate.paths,
317
+ importance: candidate.importance,
318
+ ttl: this.calculateTTL(candidate.importance),
319
+ }
320
+ }
321
+ };
322
+ this.mcpProcess.stdin.write(JSON.stringify(saveRequest) + '\n');
323
+ logger.info(`Auto-saved: ${candidate.summary}`);
324
+ }
325
+ async injectContext() {
326
+ const previewRequest = {
327
+ jsonrpc: '2.0',
328
+ id: Date.now(),
329
+ method: 'tools/call',
330
+ params: {
331
+ name: 'context.preview',
332
+ arguments: {
333
+ open_files: this.currentTurn.openFiles,
334
+ task: this.currentTurn.userMessage || 'Current task',
335
+ budget_bytes: this.config.budget_bytes,
336
+ top_k: this.config.top_k
337
+ }
338
+ }
339
+ };
340
+ this.mcpProcess.stdin.write(JSON.stringify(previewRequest) + '\n');
341
+ }
342
+ buildDialogue() {
343
+ const parts = [];
344
+ if (this.currentTurn.userMessage) {
345
+ parts.push(`User: ${this.currentTurn.userMessage}`);
346
+ }
347
+ if (this.currentTurn.assistantMessage) {
348
+ parts.push(`Assistant: ${this.currentTurn.assistantMessage}`);
349
+ }
350
+ // Include relevant tool calls
351
+ for (const tool of this.currentTurn.toolCalls) {
352
+ if (this.isRelevantTool(tool.name)) {
353
+ parts.push(`Tool: ${tool.name}(${JSON.stringify(tool.args)})`);
354
+ if (tool.result) {
355
+ const resultStr = JSON.stringify(tool.result).substring(0, 200);
356
+ parts.push(`Result: ${resultStr}...`);
357
+ }
358
+ }
359
+ }
360
+ return parts.join('\n\n');
361
+ }
362
+ isRelevantTool(toolName) {
363
+ const relevantTools = ['memory.save', 'prd.update', 'concept.search', 'memory.search'];
364
+ return relevantTools.includes(toolName);
365
+ }
366
+ redactSecrets(text) {
367
+ let redacted = text;
368
+ for (const pattern of this.redactPatterns) {
369
+ redacted = redacted.replace(pattern, '[REDACTED]');
370
+ }
371
+ return redacted;
372
+ }
373
+ generateSummary(matchedText, pattern) {
374
+ // Smart summary generation based on pattern type
375
+ if (pattern.includes('decision')) {
376
+ return `Decision: ${matchedText.substring(0, 60)}...`;
377
+ }
378
+ if (pattern.includes('bugfix|fixed')) {
379
+ return `Fix: ${matchedText.substring(0, 60)}...`;
380
+ }
381
+ if (pattern.includes('call me')) {
382
+ const nameMatch = matchedText.match(/call me (\w+)/i);
383
+ return `Preference: Call user "${nameMatch?.[1] || 'Unknown'}"`;
384
+ }
385
+ if (pattern.includes('remind me')) {
386
+ return `TODO: ${matchedText.replace(/remind me to?/i, '').trim()}`;
387
+ }
388
+ return `Auto-captured: ${matchedText.substring(0, 60)}...`;
389
+ }
390
+ extractContext(dialogue, matchIndex) {
391
+ // Extract surrounding context (±200 chars)
392
+ const start = Math.max(0, matchIndex - 200);
393
+ const end = Math.min(dialogue.length, matchIndex + 400);
394
+ return dialogue.substring(start, end);
395
+ }
396
+ classifyContent(pattern, text) {
397
+ if (pattern.includes('decision')) {
398
+ return { type: 'architecture', tags: ['decision'], importance: 5 };
399
+ }
400
+ if (pattern.includes('bugfix|fixed')) {
401
+ return { type: 'fixed-guide', tags: ['bug', 'fix'], importance: 4 };
402
+ }
403
+ if (pattern.includes('call me|prefer')) {
404
+ return { type: 'reference', tags: ['preference'], importance: 3 };
405
+ }
406
+ if (pattern.includes('remind|todo')) {
407
+ return { type: 'open-issue', tags: ['todo'], importance: 3 };
408
+ }
409
+ if (pattern.includes('feature|progress')) {
410
+ return { type: 'progress', tags: ['feature'], importance: 4 };
411
+ }
412
+ return { type: 'reference', tags: ['general'], importance: 2 };
413
+ }
414
+ extractPaths(text) {
415
+ const pathPatterns = [
416
+ /(?:^|\s)([a-zA-Z0-9_-]+\/[a-zA-Z0-9_\/-]+\.(?:js|ts|py|go|java|cpp|h))/g,
417
+ /(?:path|route|endpoint):\s*([^\s]+)/gi,
418
+ /(?:file|dir):\s*([^\s]+)/gi,
419
+ ];
420
+ const paths = new Set();
421
+ for (const pattern of pathPatterns) {
422
+ let match;
423
+ while ((match = pattern.exec(text)) !== null) {
424
+ paths.add(match[1]);
425
+ }
426
+ }
427
+ return Array.from(paths);
428
+ }
429
+ inferPathsFromFiles() {
430
+ return this.currentTurn.openFiles
431
+ .map(file => path.relative(this.activeProject?.root || process.cwd(), file))
432
+ .filter(p => !p.startsWith('..')) // Only include files within project
433
+ .map(p => path.dirname(p) + '/*'); // Convert to glob patterns
434
+ }
435
+ calculateTTL(importance) {
436
+ // TTL in seconds based on importance
437
+ const baseDays = this.config.ttl_days_low;
438
+ const multiplier = Math.max(1, importance - 1);
439
+ return baseDays * multiplier * 24 * 60 * 60;
440
+ }
441
+ deduplicateCandidates(candidates) {
442
+ const seen = new Set();
443
+ return candidates.filter(candidate => {
444
+ const key = candidate.summary.toLowerCase().replace(/[^\w]/g, '');
445
+ if (seen.has(key))
446
+ return false;
447
+ seen.add(key);
448
+ return true;
449
+ });
450
+ }
451
+ resetTurn() {
452
+ this.currentTurn = {
453
+ cwd: this.currentTurn.cwd,
454
+ openFiles: [],
455
+ toolCalls: [],
456
+ timestamp: new Date(),
457
+ };
458
+ }
459
+ }
460
+ // CLI Entry Point
461
+ const mcpServerPath = process.argv[2] || './dist/index-v4.js';
462
+ const middleware = new KratosMiddlewareV2();
463
+ process.on('SIGINT', () => {
464
+ logger.info('Shutting down middleware...');
465
+ process.exit(0);
466
+ });
467
+ middleware.start(mcpServerPath).catch(error => {
468
+ logger.error('Middleware failed:', error);
469
+ process.exit(1);
470
+ });
471
+ //# sourceMappingURL=host-middleware-v2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-middleware-v2.js","sourceRoot":"","sources":["../src/host-middleware-v2.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,IAAI,MAAM,MAAM,CAAC;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server;
4
+ private projectManager;
5
+ private memoryDb;
6
+ private conceptStore;
7
+ private contextBroker;
8
+ private prdManager;
9
+ private promptManager;
10
+ private encryption;
11
+ private piiDetector;
12
+ private dataRetention;
13
+ constructor();
14
+ private ensureInitialized;
15
+ private initializeProject;
16
+ private setupHandlers;
17
+ private getSystemStatus;
18
+ run(): Promise<void>;
19
+ }
20
+ export { KratosProtocolServer };
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AA8BA,cAAM,oBAAoB;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,aAAa,CAA8B;IAEnD,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,aAAa,CAAgB;IAGrC,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,aAAa,CAAqC;;IAwB1D,OAAO,CAAC,iBAAiB;YAMX,iBAAiB;IA0B/B,OAAO,CAAC,aAAa;YAg2BP,eAAe;IA2CvB,GAAG;CA2BV;AAGD,OAAO,EAAE,oBAAoB,EAAE,CAAC"}