@mtkn/mega-agent 0.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.
- package/dist/artifact/artifact.repository.d.ts +17 -0
- package/dist/artifact/artifact.repository.d.ts.map +1 -0
- package/dist/artifact/artifact.repository.js +66 -0
- package/dist/artifact/artifact.repository.js.map +1 -0
- package/dist/artifact/artifact.service.d.ts +22 -0
- package/dist/artifact/artifact.service.d.ts.map +1 -0
- package/dist/artifact/artifact.service.js +87 -0
- package/dist/artifact/artifact.service.js.map +1 -0
- package/dist/artifact/artifact.types.d.ts +41 -0
- package/dist/artifact/artifact.types.d.ts.map +1 -0
- package/dist/artifact/artifact.types.js +6 -0
- package/dist/artifact/artifact.types.js.map +1 -0
- package/dist/artifact/index.d.ts +6 -0
- package/dist/artifact/index.d.ts.map +1 -0
- package/dist/artifact/index.js +4 -0
- package/dist/artifact/index.js.map +1 -0
- package/dist/chat/chat-memory.integration.d.ts +59 -0
- package/dist/chat/chat-memory.integration.d.ts.map +1 -0
- package/dist/chat/chat-memory.integration.js +148 -0
- package/dist/chat/chat-memory.integration.js.map +1 -0
- package/dist/chat/chat.repository.d.ts +58 -0
- package/dist/chat/chat.repository.d.ts.map +1 -0
- package/dist/chat/chat.repository.js +128 -0
- package/dist/chat/chat.repository.js.map +1 -0
- package/dist/chat/chat.service.d.ts +28 -0
- package/dist/chat/chat.service.d.ts.map +1 -0
- package/dist/chat/chat.service.js +217 -0
- package/dist/chat/chat.service.js.map +1 -0
- package/dist/chat/chat.types.d.ts +198 -0
- package/dist/chat/chat.types.d.ts.map +1 -0
- package/dist/chat/chat.types.js +8 -0
- package/dist/chat/chat.types.js.map +1 -0
- package/dist/chat/index.d.ts +17 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +16 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/memory-detector.d.ts +53 -0
- package/dist/chat/memory-detector.d.ts.map +1 -0
- package/dist/chat/memory-detector.js +172 -0
- package/dist/chat/memory-detector.js.map +1 -0
- package/dist/chat/prompts/index.d.ts +6 -0
- package/dist/chat/prompts/index.d.ts.map +1 -0
- package/dist/chat/prompts/index.js +6 -0
- package/dist/chat/prompts/index.js.map +1 -0
- package/dist/chat/prompts/system.prompts.d.ts +23 -0
- package/dist/chat/prompts/system.prompts.d.ts.map +1 -0
- package/dist/chat/prompts/system.prompts.js +102 -0
- package/dist/chat/prompts/system.prompts.js.map +1 -0
- package/dist/chat/response-parser.d.ts +24 -0
- package/dist/chat/response-parser.d.ts.map +1 -0
- package/dist/chat/response-parser.js +198 -0
- package/dist/chat/response-parser.js.map +1 -0
- package/dist/chat/response.types.d.ts +90 -0
- package/dist/chat/response.types.d.ts.map +1 -0
- package/dist/chat/response.types.js +6 -0
- package/dist/chat/response.types.js.map +1 -0
- package/dist/common/errors.d.ts +60 -0
- package/dist/common/errors.d.ts.map +1 -0
- package/dist/common/errors.js +105 -0
- package/dist/common/errors.js.map +1 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +3 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/retry.d.ts +23 -0
- package/dist/common/retry.d.ts.map +1 -0
- package/dist/common/retry.js +57 -0
- package/dist/common/retry.js.map +1 -0
- package/dist/create-mega-agent.d.ts +100 -0
- package/dist/create-mega-agent.d.ts.map +1 -0
- package/dist/create-mega-agent.js +153 -0
- package/dist/create-mega-agent.js.map +1 -0
- package/dist/embedding/embedding.service.d.ts +34 -0
- package/dist/embedding/embedding.service.d.ts.map +1 -0
- package/dist/embedding/embedding.service.js +68 -0
- package/dist/embedding/embedding.service.js.map +1 -0
- package/dist/embedding/embedding.types.d.ts +38 -0
- package/dist/embedding/embedding.types.d.ts.map +1 -0
- package/dist/embedding/embedding.types.js +6 -0
- package/dist/embedding/embedding.types.js.map +1 -0
- package/dist/embedding/index.d.ts +9 -0
- package/dist/embedding/index.d.ts.map +1 -0
- package/dist/embedding/index.js +9 -0
- package/dist/embedding/index.js.map +1 -0
- package/dist/embedding/providers/base.provider.d.ts +29 -0
- package/dist/embedding/providers/base.provider.d.ts.map +1 -0
- package/dist/embedding/providers/base.provider.js +19 -0
- package/dist/embedding/providers/base.provider.js.map +1 -0
- package/dist/embedding/providers/index.d.ts +7 -0
- package/dist/embedding/providers/index.d.ts.map +1 -0
- package/dist/embedding/providers/index.js +7 -0
- package/dist/embedding/providers/index.js.map +1 -0
- package/dist/embedding/providers/openai.provider.d.ts +17 -0
- package/dist/embedding/providers/openai.provider.d.ts.map +1 -0
- package/dist/embedding/providers/openai.provider.js +73 -0
- package/dist/embedding/providers/openai.provider.js.map +1 -0
- package/dist/http/chat.controller.d.ts +30 -0
- package/dist/http/chat.controller.d.ts.map +1 -0
- package/dist/http/chat.controller.js +163 -0
- package/dist/http/chat.controller.js.map +1 -0
- package/dist/http/chat.routes.d.ts +5 -0
- package/dist/http/chat.routes.d.ts.map +1 -0
- package/dist/http/chat.routes.js +38 -0
- package/dist/http/chat.routes.js.map +1 -0
- package/dist/http/chat.validation.d.ts +70 -0
- package/dist/http/chat.validation.d.ts.map +1 -0
- package/dist/http/chat.validation.js +28 -0
- package/dist/http/chat.validation.js.map +1 -0
- package/dist/incident/incident.correlator.d.ts +39 -0
- package/dist/incident/incident.correlator.d.ts.map +1 -0
- package/dist/incident/incident.correlator.js +129 -0
- package/dist/incident/incident.correlator.js.map +1 -0
- package/dist/incident/incident.detector.d.ts +62 -0
- package/dist/incident/incident.detector.d.ts.map +1 -0
- package/dist/incident/incident.detector.js +192 -0
- package/dist/incident/incident.detector.js.map +1 -0
- package/dist/incident/incident.repository.d.ts +79 -0
- package/dist/incident/incident.repository.d.ts.map +1 -0
- package/dist/incident/incident.repository.js +216 -0
- package/dist/incident/incident.repository.js.map +1 -0
- package/dist/incident/incident.service.d.ts +71 -0
- package/dist/incident/incident.service.d.ts.map +1 -0
- package/dist/incident/incident.service.js +217 -0
- package/dist/incident/incident.service.js.map +1 -0
- package/dist/incident/incident.types.d.ts +115 -0
- package/dist/incident/incident.types.d.ts.map +1 -0
- package/dist/incident/incident.types.js +6 -0
- package/dist/incident/incident.types.js.map +1 -0
- package/dist/incident/index.d.ts +13 -0
- package/dist/incident/index.d.ts.map +1 -0
- package/dist/incident/index.js +13 -0
- package/dist/incident/index.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/index.d.ts +8 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +9 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/llm.service.d.ts +52 -0
- package/dist/llm/llm.service.d.ts.map +1 -0
- package/dist/llm/llm.service.js +141 -0
- package/dist/llm/llm.service.js.map +1 -0
- package/dist/llm/llm.types.d.ts +77 -0
- package/dist/llm/llm.types.d.ts.map +1 -0
- package/dist/llm/llm.types.js +5 -0
- package/dist/llm/llm.types.js.map +1 -0
- package/dist/llm/providers/anthropic.provider.d.ts +16 -0
- package/dist/llm/providers/anthropic.provider.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.provider.js +118 -0
- package/dist/llm/providers/anthropic.provider.js.map +1 -0
- package/dist/llm/providers/base.provider.d.ts +17 -0
- package/dist/llm/providers/base.provider.d.ts.map +1 -0
- package/dist/llm/providers/base.provider.js +18 -0
- package/dist/llm/providers/base.provider.js.map +1 -0
- package/dist/llm/providers/custom.provider.d.ts +15 -0
- package/dist/llm/providers/custom.provider.d.ts.map +1 -0
- package/dist/llm/providers/custom.provider.js +110 -0
- package/dist/llm/providers/custom.provider.js.map +1 -0
- package/dist/llm/providers/gemini.provider.d.ts +19 -0
- package/dist/llm/providers/gemini.provider.d.ts.map +1 -0
- package/dist/llm/providers/gemini.provider.js +98 -0
- package/dist/llm/providers/gemini.provider.js.map +1 -0
- package/dist/llm/providers/index.d.ts +10 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/index.js +10 -0
- package/dist/llm/providers/index.js.map +1 -0
- package/dist/llm/providers/openai.provider.d.ts +15 -0
- package/dist/llm/providers/openai.provider.d.ts.map +1 -0
- package/dist/llm/providers/openai.provider.js +57 -0
- package/dist/llm/providers/openai.provider.js.map +1 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +17 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp.client.d.ts +57 -0
- package/dist/mcp/mcp.client.d.ts.map +1 -0
- package/dist/mcp/mcp.client.js +150 -0
- package/dist/mcp/mcp.client.js.map +1 -0
- package/dist/mcp/mcp.service.d.ts +64 -0
- package/dist/mcp/mcp.service.d.ts.map +1 -0
- package/dist/mcp/mcp.service.js +207 -0
- package/dist/mcp/mcp.service.js.map +1 -0
- package/dist/mcp/mcp.types.d.ts +142 -0
- package/dist/mcp/mcp.types.d.ts.map +1 -0
- package/dist/mcp/mcp.types.js +6 -0
- package/dist/mcp/mcp.types.js.map +1 -0
- package/dist/mcp/presets/common-sources.d.ts +28 -0
- package/dist/mcp/presets/common-sources.d.ts.map +1 -0
- package/dist/mcp/presets/common-sources.js +114 -0
- package/dist/mcp/presets/common-sources.js.map +1 -0
- package/dist/mcp/presets/index.d.ts +5 -0
- package/dist/mcp/presets/index.d.ts.map +1 -0
- package/dist/mcp/presets/index.js +5 -0
- package/dist/mcp/presets/index.js.map +1 -0
- package/dist/mcp/source.repository.d.ts +68 -0
- package/dist/mcp/source.repository.d.ts.map +1 -0
- package/dist/mcp/source.repository.js +114 -0
- package/dist/mcp/source.repository.js.map +1 -0
- package/dist/mcp/source.service.d.ts +74 -0
- package/dist/mcp/source.service.d.ts.map +1 -0
- package/dist/mcp/source.service.js +181 -0
- package/dist/mcp/source.service.js.map +1 -0
- package/dist/mcp/transports/http.transport.d.ts +45 -0
- package/dist/mcp/transports/http.transport.d.ts.map +1 -0
- package/dist/mcp/transports/http.transport.js +64 -0
- package/dist/mcp/transports/http.transport.js.map +1 -0
- package/dist/mcp/transports/index.d.ts +7 -0
- package/dist/mcp/transports/index.d.ts.map +1 -0
- package/dist/mcp/transports/index.js +7 -0
- package/dist/mcp/transports/index.js.map +1 -0
- package/dist/mcp/transports/stdio.transport.d.ts +21 -0
- package/dist/mcp/transports/stdio.transport.d.ts.map +1 -0
- package/dist/mcp/transports/stdio.transport.js +29 -0
- package/dist/mcp/transports/stdio.transport.js.map +1 -0
- package/dist/memory/index.d.ts +10 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +10 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/memory.repository.d.ts +62 -0
- package/dist/memory/memory.repository.d.ts.map +1 -0
- package/dist/memory/memory.repository.js +148 -0
- package/dist/memory/memory.repository.js.map +1 -0
- package/dist/memory/memory.service.d.ts +63 -0
- package/dist/memory/memory.service.d.ts.map +1 -0
- package/dist/memory/memory.service.js +263 -0
- package/dist/memory/memory.service.js.map +1 -0
- package/dist/memory/memory.types.d.ts +104 -0
- package/dist/memory/memory.types.d.ts.map +1 -0
- package/dist/memory/memory.types.js +8 -0
- package/dist/memory/memory.types.js.map +1 -0
- package/dist/qdrant/index.d.ts +8 -0
- package/dist/qdrant/index.d.ts.map +1 -0
- package/dist/qdrant/index.js +6 -0
- package/dist/qdrant/index.js.map +1 -0
- package/dist/qdrant/qdrant.service.d.ts +63 -0
- package/dist/qdrant/qdrant.service.d.ts.map +1 -0
- package/dist/qdrant/qdrant.service.js +201 -0
- package/dist/qdrant/qdrant.service.js.map +1 -0
- package/dist/qdrant/qdrant.types.d.ts +55 -0
- package/dist/qdrant/qdrant.types.d.ts.map +1 -0
- package/dist/qdrant/qdrant.types.js +6 -0
- package/dist/qdrant/qdrant.types.js.map +1 -0
- package/dist/tools/core-tools.d.ts +7 -0
- package/dist/tools/core-tools.d.ts.map +1 -0
- package/dist/tools/core-tools.js +52 -0
- package/dist/tools/core-tools.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/tool-registry.d.ts +51 -0
- package/dist/tools/tool-registry.d.ts.map +1 -0
- package/dist/tools/tool-registry.js +50 -0
- package/dist/tools/tool-registry.js.map +1 -0
- package/dist/workflow/actions/base.action.d.ts +50 -0
- package/dist/workflow/actions/base.action.d.ts.map +1 -0
- package/dist/workflow/actions/base.action.js +59 -0
- package/dist/workflow/actions/base.action.js.map +1 -0
- package/dist/workflow/actions/incident.action.d.ts +13 -0
- package/dist/workflow/actions/incident.action.d.ts.map +1 -0
- package/dist/workflow/actions/incident.action.js +70 -0
- package/dist/workflow/actions/incident.action.js.map +1 -0
- package/dist/workflow/actions/index.d.ts +9 -0
- package/dist/workflow/actions/index.d.ts.map +1 -0
- package/dist/workflow/actions/index.js +11 -0
- package/dist/workflow/actions/index.js.map +1 -0
- package/dist/workflow/actions/notify.action.d.ts +18 -0
- package/dist/workflow/actions/notify.action.d.ts.map +1 -0
- package/dist/workflow/actions/notify.action.js +106 -0
- package/dist/workflow/actions/notify.action.js.map +1 -0
- package/dist/workflow/actions/report.action.d.ts +13 -0
- package/dist/workflow/actions/report.action.d.ts.map +1 -0
- package/dist/workflow/actions/report.action.js +64 -0
- package/dist/workflow/actions/report.action.js.map +1 -0
- package/dist/workflow/index.d.ts +10 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +11 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/workflow.repository.d.ts +90 -0
- package/dist/workflow/workflow.repository.d.ts.map +1 -0
- package/dist/workflow/workflow.repository.js +238 -0
- package/dist/workflow/workflow.repository.js.map +1 -0
- package/dist/workflow/workflow.service.d.ts +98 -0
- package/dist/workflow/workflow.service.d.ts.map +1 -0
- package/dist/workflow/workflow.service.js +374 -0
- package/dist/workflow/workflow.service.js.map +1 -0
- package/dist/workflow/workflow.types.d.ts +146 -0
- package/dist/workflow/workflow.types.d.ts.map +1 -0
- package/dist/workflow/workflow.types.js +8 -0
- package/dist/workflow/workflow.types.js.map +1 -0
- package/package.json +67 -0
- package/prisma/schema.prisma +551 -0
- package/scripts/prisma-sync.mjs +187 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Module Index
|
|
3
|
+
* Export all Chat service components
|
|
4
|
+
*/
|
|
5
|
+
// Re-export Prisma types from chat.types
|
|
6
|
+
export { ChatMode, MessageRole } from './chat.types.js';
|
|
7
|
+
// Chat Service
|
|
8
|
+
export { ChatService, initChatService, getChatServiceDeps, } from './chat.service.js';
|
|
9
|
+
// Chat Repository
|
|
10
|
+
export { ChatRepository, initChatRepository, } from './chat.repository.js';
|
|
11
|
+
// Chat Memory Integration
|
|
12
|
+
export { ChatMemoryIntegration, initChatMemoryIntegration, getChatMemoryIntegrationDeps, } from './chat-memory.integration.js';
|
|
13
|
+
// Memory Detector
|
|
14
|
+
export { MemoryDetector } from './memory-detector.js';
|
|
15
|
+
export { MODE_PROMPTS, buildSystemPrompt, buildMemoryContextPrompt, } from './prompts/index.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/chat/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwBH,yCAAyC;AACzC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGxD,eAAe;AACf,OAAO,EACL,WAAW,EACX,eAAe,EACf,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B,kBAAkB;AAClB,OAAO,EACL,cAAc,EACd,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,0BAA0B;AAC1B,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,8BAA8B,CAAC;AAEtC,kBAAkB;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Detector
|
|
3
|
+
* Detects potential memories from conversation content
|
|
4
|
+
* Analyzes user messages and assistant responses for memory-worthy content
|
|
5
|
+
*/
|
|
6
|
+
import type { DetectedMemory, MemoryDetectorConfig } from './chat.types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Memory Detector class
|
|
9
|
+
* Analyzes conversations to detect potential memories
|
|
10
|
+
*/
|
|
11
|
+
export declare class MemoryDetector {
|
|
12
|
+
private config;
|
|
13
|
+
constructor(config?: Partial<MemoryDetectorConfig>);
|
|
14
|
+
/**
|
|
15
|
+
* Analyze message for potential memory content
|
|
16
|
+
* Returns detected memories that meet the confidence threshold
|
|
17
|
+
*/
|
|
18
|
+
analyzeForMemories(userMessage: string, assistantResponse: string): DetectedMemory[];
|
|
19
|
+
/**
|
|
20
|
+
* Detect explicit memory save triggers
|
|
21
|
+
* Looks for explicit save/remember commands in the response
|
|
22
|
+
*/
|
|
23
|
+
private detectExplicitTriggers;
|
|
24
|
+
/**
|
|
25
|
+
* Detect insights from analysis content
|
|
26
|
+
* Identifies key insights and findings in the response
|
|
27
|
+
*/
|
|
28
|
+
private detectInsights;
|
|
29
|
+
/**
|
|
30
|
+
* Detect patterns from conversation
|
|
31
|
+
* Identifies recurring themes and patterns mentioned
|
|
32
|
+
*/
|
|
33
|
+
private detectPatterns;
|
|
34
|
+
/**
|
|
35
|
+
* Detect decisions from conversation
|
|
36
|
+
* Identifies decisions and chosen approaches
|
|
37
|
+
*/
|
|
38
|
+
private detectDecisions;
|
|
39
|
+
/**
|
|
40
|
+
* Check if user explicitly requests memory save
|
|
41
|
+
* Detects user intent to save something to memory
|
|
42
|
+
*/
|
|
43
|
+
detectUserMemoryRequest(message: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get the current configuration
|
|
46
|
+
*/
|
|
47
|
+
getConfig(): MemoryDetectorConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Update configuration
|
|
50
|
+
*/
|
|
51
|
+
updateConfig(config: Partial<MemoryDetectorConfig>): void;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=memory-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-detector.d.ts","sourceRoot":"","sources":["../../src/chat/memory-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAW5E;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;gBAEzB,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC;IAIlD;;;OAGG;IACH,kBAAkB,CAChB,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,MAAM,GACxB,cAAc,EAAE;IAyBnB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAwB9B;;;OAGG;IACH,OAAO,CAAC,cAAc;IA0BtB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAyBtB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAyBvB;;;OAGG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAYjD;;OAEG;IACH,SAAS,IAAI,oBAAoB;IAIjC;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI;CAG1D"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Detector
|
|
3
|
+
* Detects potential memories from conversation content
|
|
4
|
+
* Analyzes user messages and assistant responses for memory-worthy content
|
|
5
|
+
*/
|
|
6
|
+
// ==================== CONFIGURATION ====================
|
|
7
|
+
const DEFAULT_CONFIG = {
|
|
8
|
+
minConfidence: 0.8,
|
|
9
|
+
enableAutoSuggestions: true,
|
|
10
|
+
};
|
|
11
|
+
// ==================== MEMORY DETECTOR ====================
|
|
12
|
+
/**
|
|
13
|
+
* Memory Detector class
|
|
14
|
+
* Analyzes conversations to detect potential memories
|
|
15
|
+
*/
|
|
16
|
+
export class MemoryDetector {
|
|
17
|
+
config;
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Analyze message for potential memory content
|
|
23
|
+
* Returns detected memories that meet the confidence threshold
|
|
24
|
+
*/
|
|
25
|
+
analyzeForMemories(userMessage, assistantResponse) {
|
|
26
|
+
const memories = [];
|
|
27
|
+
// Check for explicit memory triggers
|
|
28
|
+
const explicitMemory = this.detectExplicitTriggers(assistantResponse);
|
|
29
|
+
if (explicitMemory) {
|
|
30
|
+
memories.push(explicitMemory);
|
|
31
|
+
}
|
|
32
|
+
// Check for insights
|
|
33
|
+
const insights = this.detectInsights(assistantResponse);
|
|
34
|
+
memories.push(...insights);
|
|
35
|
+
// Check for patterns
|
|
36
|
+
const patterns = this.detectPatterns(userMessage, assistantResponse);
|
|
37
|
+
memories.push(...patterns);
|
|
38
|
+
// Check for decisions
|
|
39
|
+
const decisions = this.detectDecisions(assistantResponse);
|
|
40
|
+
memories.push(...decisions);
|
|
41
|
+
// Filter by confidence threshold
|
|
42
|
+
return memories.filter(m => m.confidence >= this.config.minConfidence);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Detect explicit memory save triggers
|
|
46
|
+
* Looks for explicit save/remember commands in the response
|
|
47
|
+
*/
|
|
48
|
+
detectExplicitTriggers(response) {
|
|
49
|
+
const triggers = [
|
|
50
|
+
{ pattern: /\[SAVE TO MEMORY\]\s*(.+)/i, type: 'FACT' },
|
|
51
|
+
{ pattern: /\[REMEMBER\]\s*(.+)/i, type: 'FACT' },
|
|
52
|
+
{ pattern: /I'll remember that\s+(.+)/i, type: 'FACT' },
|
|
53
|
+
{ pattern: /Saving insight:\s*(.+)/i, type: 'INSIGHT' },
|
|
54
|
+
];
|
|
55
|
+
for (const { pattern, type } of triggers) {
|
|
56
|
+
const match = response.match(pattern);
|
|
57
|
+
if (match) {
|
|
58
|
+
return {
|
|
59
|
+
type,
|
|
60
|
+
title: match[1].slice(0, 100),
|
|
61
|
+
content: match[1],
|
|
62
|
+
confidence: 0.95,
|
|
63
|
+
trigger: 'explicit',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Detect insights from analysis content
|
|
71
|
+
* Identifies key insights and findings in the response
|
|
72
|
+
*/
|
|
73
|
+
detectInsights(response) {
|
|
74
|
+
const insights = [];
|
|
75
|
+
const insightPatterns = [
|
|
76
|
+
/Key insight:\s*(.+?)(?:\n|$)/gi,
|
|
77
|
+
/Important finding:\s*(.+?)(?:\n|$)/gi,
|
|
78
|
+
/Analysis shows:\s*(.+?)(?:\n|$)/gi,
|
|
79
|
+
/The data reveals:\s*(.+?)(?:\n|$)/gi,
|
|
80
|
+
];
|
|
81
|
+
for (const pattern of insightPatterns) {
|
|
82
|
+
let match;
|
|
83
|
+
while ((match = pattern.exec(response)) !== null) {
|
|
84
|
+
insights.push({
|
|
85
|
+
type: 'INSIGHT',
|
|
86
|
+
title: match[1].slice(0, 100),
|
|
87
|
+
content: match[1],
|
|
88
|
+
confidence: 0.85,
|
|
89
|
+
trigger: 'insight_pattern',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return insights;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Detect patterns from conversation
|
|
97
|
+
* Identifies recurring themes and patterns mentioned
|
|
98
|
+
*/
|
|
99
|
+
detectPatterns(_userMessage, response) {
|
|
100
|
+
const patterns = [];
|
|
101
|
+
const patternIndicators = [
|
|
102
|
+
/I notice a pattern:\s*(.+?)(?:\n|$)/gi,
|
|
103
|
+
/There's a recurring theme:\s*(.+?)(?:\n|$)/gi,
|
|
104
|
+
/This follows the pattern:\s*(.+?)(?:\n|$)/gi,
|
|
105
|
+
];
|
|
106
|
+
for (const indicator of patternIndicators) {
|
|
107
|
+
let match;
|
|
108
|
+
while ((match = indicator.exec(response)) !== null) {
|
|
109
|
+
patterns.push({
|
|
110
|
+
type: 'PATTERN',
|
|
111
|
+
title: match[1].slice(0, 100),
|
|
112
|
+
content: match[1],
|
|
113
|
+
confidence: 0.80,
|
|
114
|
+
trigger: 'pattern_detection',
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return patterns;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Detect decisions from conversation
|
|
122
|
+
* Identifies decisions and chosen approaches
|
|
123
|
+
*/
|
|
124
|
+
detectDecisions(response) {
|
|
125
|
+
const decisions = [];
|
|
126
|
+
const decisionPatterns = [
|
|
127
|
+
/Decision:\s*(.+?)(?:\n|$)/gi,
|
|
128
|
+
/We've decided to:\s*(.+?)(?:\n|$)/gi,
|
|
129
|
+
/The chosen approach is:\s*(.+?)(?:\n|$)/gi,
|
|
130
|
+
];
|
|
131
|
+
for (const pattern of decisionPatterns) {
|
|
132
|
+
let match;
|
|
133
|
+
while ((match = pattern.exec(response)) !== null) {
|
|
134
|
+
decisions.push({
|
|
135
|
+
type: 'DECISION',
|
|
136
|
+
title: match[1].slice(0, 100),
|
|
137
|
+
content: match[1],
|
|
138
|
+
confidence: 0.90,
|
|
139
|
+
trigger: 'decision_pattern',
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return decisions;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Check if user explicitly requests memory save
|
|
147
|
+
* Detects user intent to save something to memory
|
|
148
|
+
*/
|
|
149
|
+
detectUserMemoryRequest(message) {
|
|
150
|
+
const requestPatterns = [
|
|
151
|
+
/remember this/i,
|
|
152
|
+
/save (?:this )?(?:to|in) memory/i,
|
|
153
|
+
/don't forget/i,
|
|
154
|
+
/keep in mind/i,
|
|
155
|
+
/note (?:this|that)/i,
|
|
156
|
+
];
|
|
157
|
+
return requestPatterns.some(p => p.test(message));
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get the current configuration
|
|
161
|
+
*/
|
|
162
|
+
getConfig() {
|
|
163
|
+
return { ...this.config };
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Update configuration
|
|
167
|
+
*/
|
|
168
|
+
updateConfig(config) {
|
|
169
|
+
this.config = { ...this.config, ...config };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=memory-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-detector.js","sourceRoot":"","sources":["../../src/chat/memory-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,0DAA0D;AAE1D,MAAM,cAAc,GAAyB;IAC3C,aAAa,EAAE,GAAG;IAClB,qBAAqB,EAAE,IAAI;CAC5B,CAAC;AAEF,4DAA4D;AAE5D;;;GAGG;AACH,MAAM,OAAO,cAAc;IACjB,MAAM,CAAuB;IAErC,YAAY,MAAsC;QAChD,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,kBAAkB,CAChB,WAAmB,EACnB,iBAAyB;QAEzB,MAAM,QAAQ,GAAqB,EAAE,CAAC;QAEtC,qCAAqC;QACrC,MAAM,cAAc,GAAG,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;QACtE,IAAI,cAAc,EAAE,CAAC;YACnB,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAChC,CAAC;QAED,qBAAqB;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QACxD,QAAQ,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AAM,EAAE,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chat/prompts/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/chat/prompts/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Prompts
|
|
3
|
+
* System and mode-specific prompts for chat interactions
|
|
4
|
+
*/
|
|
5
|
+
import type { ChatMode } from '../chat.types.js';
|
|
6
|
+
export interface MegaAgentPromptOptions {
|
|
7
|
+
agentName?: string;
|
|
8
|
+
agentDescription?: string;
|
|
9
|
+
customPrompt?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const MODE_PROMPTS: Record<ChatMode, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Build the complete system prompt for a chat session
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildSystemPrompt(mode: ChatMode, options?: MegaAgentPromptOptions): string;
|
|
16
|
+
/**
|
|
17
|
+
* Build context prompt from relevant memories
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildMemoryContextPrompt(memories: Array<{
|
|
20
|
+
content: string;
|
|
21
|
+
type: string;
|
|
22
|
+
}>): string;
|
|
23
|
+
//# sourceMappingURL=system.prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.prompts.d.ts","sourceRoot":"","sources":["../../../src/chat/prompts/system.prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAqDD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAgCjD,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAS1F;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GACjD,MAAM,CAQR"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Prompts
|
|
3
|
+
* System and mode-specific prompts for chat interactions
|
|
4
|
+
*/
|
|
5
|
+
import { getAllTools } from '../../tools/tool-registry.js';
|
|
6
|
+
function buildToolListSection() {
|
|
7
|
+
const tools = getAllTools();
|
|
8
|
+
if (tools.length === 0)
|
|
9
|
+
return '## Your Tools\n\nNo tools registered.';
|
|
10
|
+
const readTools = tools.filter(t => t.category === 'read');
|
|
11
|
+
const writeTools = tools.filter(t => t.category === 'write');
|
|
12
|
+
const lines = ['## Your Tools'];
|
|
13
|
+
if (readTools.length > 0) {
|
|
14
|
+
lines.push('\n**Read tools (auto-execute, no approval needed):**');
|
|
15
|
+
readTools.forEach(t => lines.push(`- ${t.name} — ${t.description}`));
|
|
16
|
+
}
|
|
17
|
+
if (writeTools.length > 0) {
|
|
18
|
+
lines.push('\n**Write tools (require user approval before execution):**');
|
|
19
|
+
writeTools.forEach(t => lines.push(`- ${t.name} — ${t.description}`));
|
|
20
|
+
}
|
|
21
|
+
lines.push('\nWhen you need data, USE your tools. Do not guess or make up data.');
|
|
22
|
+
return lines.join('\n');
|
|
23
|
+
}
|
|
24
|
+
function buildBasePrompt(options = {}) {
|
|
25
|
+
const name = options.agentName ?? 'MegaAgent';
|
|
26
|
+
const desc = options.agentDescription ?? 'the AI pilot for the AI-WOS manufacturing management system';
|
|
27
|
+
return `You are ${name} — ${desc}.
|
|
28
|
+
|
|
29
|
+
${buildToolListSection()}
|
|
30
|
+
|
|
31
|
+
## Long-term Memory (VectorDB)
|
|
32
|
+
- You have persistent memory. The system searches it before each response.
|
|
33
|
+
- To save something important, write: [MEMORY] <content>
|
|
34
|
+
- Save: key decisions, discovered patterns, important facts, insights
|
|
35
|
+
|
|
36
|
+
## Artifacts
|
|
37
|
+
- When you produce tables, reports or structured data, they can be saved as Artifacts
|
|
38
|
+
- Users can pin artifacts to memory, export them, or use them as input for follow-up questions
|
|
39
|
+
|
|
40
|
+
## Incidents & Workflows
|
|
41
|
+
- You can create incidents when problems are detected
|
|
42
|
+
- You can trigger workflow actions: notifications, reports, webhooks
|
|
43
|
+
|
|
44
|
+
## Communication Rules
|
|
45
|
+
- Answer in the user's language (German, Turkish, English, etc.)
|
|
46
|
+
- When you use a tool, explain what you found
|
|
47
|
+
- Be concise but thorough
|
|
48
|
+
- Be transparent: say what you know vs. what you infer`;
|
|
49
|
+
}
|
|
50
|
+
export const MODE_PROMPTS = {
|
|
51
|
+
EXPLORE: `You are in EXPLORE mode. Focus on:
|
|
52
|
+
- Answering questions thoroughly
|
|
53
|
+
- Providing analysis and insights
|
|
54
|
+
- Explaining concepts clearly
|
|
55
|
+
- Referencing relevant memories when applicable
|
|
56
|
+
|
|
57
|
+
When you discover important insights, suggest saving them to memory.`,
|
|
58
|
+
GENERATE: `You are in GENERATE mode. Focus on:
|
|
59
|
+
- Creating content (reports, documentation, code)
|
|
60
|
+
- Generating structured outputs
|
|
61
|
+
- Following templates and formats
|
|
62
|
+
- Producing high-quality artifacts
|
|
63
|
+
|
|
64
|
+
Generated content may be saved as artifacts for future reference.`,
|
|
65
|
+
EXECUTE: `You are in EXECUTE mode. Focus on:
|
|
66
|
+
- Taking actions using your available tools
|
|
67
|
+
- Read operations execute automatically; write operations require user approval
|
|
68
|
+
- Reporting results clearly with structured data
|
|
69
|
+
- Handling errors gracefully
|
|
70
|
+
|
|
71
|
+
Always confirm write actions before executing and report outcomes.`,
|
|
72
|
+
AUTOMATE: `You are in AUTOMATE mode. Focus on:
|
|
73
|
+
- Setting up automated workflows via /api/workflows
|
|
74
|
+
- Defining triggers (schedule, event, threshold) and actions (notify, create_incident, create_memory, generate_report, webhook)
|
|
75
|
+
- Use run_agent tool for complex autonomous tasks
|
|
76
|
+
- Monitoring ongoing processes and active agent sessions
|
|
77
|
+
|
|
78
|
+
All write operations require user approval.`,
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Build the complete system prompt for a chat session
|
|
82
|
+
*/
|
|
83
|
+
export function buildSystemPrompt(mode, options) {
|
|
84
|
+
const modePrompt = MODE_PROMPTS[mode] || MODE_PROMPTS.EXPLORE;
|
|
85
|
+
const base = buildBasePrompt(options);
|
|
86
|
+
if (options?.customPrompt) {
|
|
87
|
+
return `${base}\n\n${modePrompt}\n\n${options.customPrompt}`;
|
|
88
|
+
}
|
|
89
|
+
return `${base}\n\n${modePrompt}`;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Build context prompt from relevant memories
|
|
93
|
+
*/
|
|
94
|
+
export function buildMemoryContextPrompt(memories) {
|
|
95
|
+
if (memories.length === 0)
|
|
96
|
+
return '';
|
|
97
|
+
const memoryList = memories
|
|
98
|
+
.map((m, i) => `[Memory ${i + 1} - ${m.type}]: ${m.content}`)
|
|
99
|
+
.join('\n\n');
|
|
100
|
+
return `\n\n--- RELEVANT MEMORIES ---\n${memoryList}\n--- END MEMORIES ---\n\nUse these memories to inform your response when relevant. Reference them naturally.`;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=system.prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.prompts.js","sourceRoot":"","sources":["../../../src/chat/prompts/system.prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,W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import type { StructuredResponse, ResponseType, TableData, AgentData, QualityAssessment, ResponseSource, ToolUsage, MemoryAction, ResponseParseContext } from './response.types.js';
|
|
6
|
+
export declare class ResponseParser {
|
|
7
|
+
/**
|
|
8
|
+
* Parse LLM output + execution context into a StructuredResponse
|
|
9
|
+
*/
|
|
10
|
+
static parse(text: string, context: ResponseParseContext): StructuredResponse;
|
|
11
|
+
static detectType(text: string): ResponseType;
|
|
12
|
+
static containsMarkdownTable(text: string): boolean;
|
|
13
|
+
static parseTable(text: string): TableData | null;
|
|
14
|
+
static parseAgent(text: string): AgentData;
|
|
15
|
+
static extractMemory(text: string): MemoryAction;
|
|
16
|
+
static calculateQuality(text: string, ctx: ResponseParseContext): QualityAssessment;
|
|
17
|
+
static buildSources(ctx: ResponseParseContext): ResponseSource[];
|
|
18
|
+
static buildToolsUsed(ctx: ResponseParseContext): ToolUsage[];
|
|
19
|
+
/** Remove [MEMORY], [AGENT], [CHART] tags from display text */
|
|
20
|
+
static cleanTags(text: string): string;
|
|
21
|
+
/** Extract a reasonable title from text */
|
|
22
|
+
static extractTitle(text: string, fallback: string): string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=response-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-parser.d.ts","sourceRoot":"","sources":["../../src/chat/response-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,SAAS,EACT,iBAAiB,EAEjB,cAAc,EACd,SAAS,EACT,YAAY,EAEZ,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAI7B,qBAAa,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,kBAAkB;IAuC7E,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAc7C,MAAM,CAAC,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAenD,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IA6BjD,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAiB1C,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAmBhD,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,GAAG,iBAAiB;IAuCnF,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,oBAAoB,GAAG,cAAc,EAAE;IAchE,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,oBAAoB,GAAG,SAAS,EAAE;IAU7D,+DAA+D;IAC/D,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAUtC,2CAA2C;IAC3C,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;CAW5D"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response Parser
|
|
3
|
+
* Transforms raw LLM text output into a StructuredResponse
|
|
4
|
+
*/
|
|
5
|
+
// ── Main Parser ──────────────────────────────────────────────────
|
|
6
|
+
export class ResponseParser {
|
|
7
|
+
/**
|
|
8
|
+
* Parse LLM output + execution context into a StructuredResponse
|
|
9
|
+
*/
|
|
10
|
+
static parse(text, context) {
|
|
11
|
+
const type = ResponseParser.detectType(text);
|
|
12
|
+
const memory = ResponseParser.extractMemory(text);
|
|
13
|
+
const cleanedText = ResponseParser.cleanTags(text);
|
|
14
|
+
const sources = ResponseParser.buildSources(context);
|
|
15
|
+
const toolsUsed = ResponseParser.buildToolsUsed(context);
|
|
16
|
+
const quality = ResponseParser.calculateQuality(text, context);
|
|
17
|
+
const base = {
|
|
18
|
+
type,
|
|
19
|
+
content: cleanedText,
|
|
20
|
+
quality,
|
|
21
|
+
sources: sources.length > 0 ? sources : undefined,
|
|
22
|
+
toolsUsed: toolsUsed.length > 0 ? toolsUsed : undefined,
|
|
23
|
+
memory: memory.saved ? memory : undefined,
|
|
24
|
+
};
|
|
25
|
+
// Type-specific data extraction
|
|
26
|
+
if (type === 'table') {
|
|
27
|
+
const tableData = ResponseParser.parseTable(text);
|
|
28
|
+
if (tableData) {
|
|
29
|
+
base.data = tableData;
|
|
30
|
+
base.artifact = {
|
|
31
|
+
suggestedTitle: ResponseParser.extractTitle(text, 'Data Table'),
|
|
32
|
+
type: 'TABLE',
|
|
33
|
+
data: tableData,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (type === 'agent_created') {
|
|
38
|
+
base.data = ResponseParser.parseAgent(text);
|
|
39
|
+
}
|
|
40
|
+
return base;
|
|
41
|
+
}
|
|
42
|
+
// ── Type Detection ─────────────────────────────────────────────
|
|
43
|
+
static detectType(text) {
|
|
44
|
+
// Explicit tags take priority
|
|
45
|
+
if (/\[AGENT\]/i.test(text))
|
|
46
|
+
return 'agent_created';
|
|
47
|
+
if (/\[CHART\]/i.test(text))
|
|
48
|
+
return 'chart';
|
|
49
|
+
if (/\[ERROR\]/i.test(text))
|
|
50
|
+
return 'error';
|
|
51
|
+
// Content-based detection
|
|
52
|
+
if (ResponseParser.containsMarkdownTable(text))
|
|
53
|
+
return 'table';
|
|
54
|
+
return 'answer';
|
|
55
|
+
}
|
|
56
|
+
// ── Table Parsing ──────────────────────────────────────────────
|
|
57
|
+
static containsMarkdownTable(text) {
|
|
58
|
+
// A markdown table has at least: header row, separator row (|---|), data row
|
|
59
|
+
const lines = text.split('\n');
|
|
60
|
+
let hasSeparator = false;
|
|
61
|
+
let pipeRowCount = 0;
|
|
62
|
+
for (const line of lines) {
|
|
63
|
+
const trimmed = line.trim();
|
|
64
|
+
if (/^\|[\s\-:|]+\|$/.test(trimmed))
|
|
65
|
+
hasSeparator = true;
|
|
66
|
+
if (trimmed.startsWith('|') && trimmed.endsWith('|'))
|
|
67
|
+
pipeRowCount++;
|
|
68
|
+
}
|
|
69
|
+
return hasSeparator && pipeRowCount >= 3;
|
|
70
|
+
}
|
|
71
|
+
static parseTable(text) {
|
|
72
|
+
const lines = text.split('\n');
|
|
73
|
+
const tableLines = [];
|
|
74
|
+
let inTable = false;
|
|
75
|
+
for (const line of lines) {
|
|
76
|
+
const trimmed = line.trim();
|
|
77
|
+
if (trimmed.startsWith('|') && trimmed.endsWith('|')) {
|
|
78
|
+
inTable = true;
|
|
79
|
+
tableLines.push(trimmed);
|
|
80
|
+
}
|
|
81
|
+
else if (inTable && trimmed === '') {
|
|
82
|
+
break; // End of table
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (tableLines.length < 3)
|
|
86
|
+
return null;
|
|
87
|
+
const parseLine = (line) => line.split('|').slice(1, -1).map(cell => cell.trim());
|
|
88
|
+
const headers = parseLine(tableLines[0]);
|
|
89
|
+
// Skip separator (index 1)
|
|
90
|
+
const rows = tableLines.slice(2).map(line => parseLine(line));
|
|
91
|
+
return { headers, rows, totalRows: rows.length };
|
|
92
|
+
}
|
|
93
|
+
// ── Agent Parsing ──────────────────────────────────────────────
|
|
94
|
+
static parseAgent(text) {
|
|
95
|
+
const descMatch = text.match(/\[AGENT\]\s*(.+?)(?:\n|$)/i);
|
|
96
|
+
const triggerMatch = text.match(/Trigger:\s*(.+?)(?:\n|$)/i);
|
|
97
|
+
const conditionMatch = text.match(/Condition:\s*(.+?)(?:\n|$)/i);
|
|
98
|
+
const actionMatch = text.match(/Action:\s*(.+?)(?:\n|$)/i);
|
|
99
|
+
return {
|
|
100
|
+
agentType: 'watcher',
|
|
101
|
+
description: descMatch?.[1]?.trim() || 'Agent created',
|
|
102
|
+
trigger: triggerMatch?.[1]?.trim(),
|
|
103
|
+
condition: conditionMatch?.[1]?.trim(),
|
|
104
|
+
action: actionMatch?.[1]?.trim(),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// ── Memory Extraction ─────────────────────────────────────────
|
|
108
|
+
static extractMemory(text) {
|
|
109
|
+
const memoryMatches = text.match(/\[MEMORY\]\s*(.+?)(?:\n|$)/gi);
|
|
110
|
+
if (!memoryMatches || memoryMatches.length === 0) {
|
|
111
|
+
return { saved: false };
|
|
112
|
+
}
|
|
113
|
+
const content = memoryMatches
|
|
114
|
+
.map(m => m.replace(/\[MEMORY\]\s*/i, '').trim())
|
|
115
|
+
.join('\n');
|
|
116
|
+
return {
|
|
117
|
+
saved: true,
|
|
118
|
+
savedContent: content,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
// ── Quality Assessment ─────────────────────────────────────────
|
|
122
|
+
static calculateQuality(text, ctx) {
|
|
123
|
+
let score = 0;
|
|
124
|
+
const reasons = [];
|
|
125
|
+
if (ctx.memoriesUsed.length > 0) {
|
|
126
|
+
score += 30;
|
|
127
|
+
reasons.push(`${ctx.memoriesUsed.length} memories referenced`);
|
|
128
|
+
}
|
|
129
|
+
if (ctx.toolsCalled.length > 0) {
|
|
130
|
+
score += 30;
|
|
131
|
+
reasons.push(`${ctx.toolsCalled.length} tools used`);
|
|
132
|
+
}
|
|
133
|
+
if (ctx.memoriesUsed.length + ctx.toolsCalled.length > 2) {
|
|
134
|
+
score += 20;
|
|
135
|
+
reasons.push('multiple sources');
|
|
136
|
+
}
|
|
137
|
+
if (text.length > 500) {
|
|
138
|
+
score += 20;
|
|
139
|
+
reasons.push('detailed response');
|
|
140
|
+
}
|
|
141
|
+
else if (text.length > 200) {
|
|
142
|
+
score += 10;
|
|
143
|
+
}
|
|
144
|
+
let signal = 'weak';
|
|
145
|
+
if (score >= 60)
|
|
146
|
+
signal = 'strong';
|
|
147
|
+
else if (score >= 30)
|
|
148
|
+
signal = 'moderate';
|
|
149
|
+
return {
|
|
150
|
+
signal,
|
|
151
|
+
confidence: Math.min(score / 100, 1),
|
|
152
|
+
reasoning: reasons.join(', '),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
// ── Sources Builder ────────────────────────────────────────────
|
|
156
|
+
static buildSources(ctx) {
|
|
157
|
+
const sources = [];
|
|
158
|
+
for (const mem of ctx.memoriesUsed) {
|
|
159
|
+
sources.push({
|
|
160
|
+
name: mem.title || `Memory ${mem.id.slice(0, 8)}`,
|
|
161
|
+
type: 'memory',
|
|
162
|
+
relevance: Math.round(mem.score * 100),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return sources;
|
|
166
|
+
}
|
|
167
|
+
static buildToolsUsed(ctx) {
|
|
168
|
+
return ctx.toolsCalled.map(t => ({
|
|
169
|
+
name: t.name,
|
|
170
|
+
description: t.name.replace(/_/g, ' '),
|
|
171
|
+
executionTimeMs: t.durationMs,
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
// ── Helpers ────────────────────────────────────────────────────
|
|
175
|
+
/** Remove [MEMORY], [AGENT], [CHART] tags from display text */
|
|
176
|
+
static cleanTags(text) {
|
|
177
|
+
return text
|
|
178
|
+
.replace(/\[MEMORY\]\s*[^\n]*/gi, '')
|
|
179
|
+
.replace(/\[AGENT\]\s*/gi, '')
|
|
180
|
+
.replace(/\[CHART\]\s*/gi, '')
|
|
181
|
+
.replace(/\[ERROR\]\s*/gi, '')
|
|
182
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
183
|
+
.trim();
|
|
184
|
+
}
|
|
185
|
+
/** Extract a reasonable title from text */
|
|
186
|
+
static extractTitle(text, fallback) {
|
|
187
|
+
// First heading
|
|
188
|
+
const heading = text.match(/^#+\s+(.+)$/m);
|
|
189
|
+
if (heading)
|
|
190
|
+
return heading[1].trim().slice(0, 100);
|
|
191
|
+
// First sentence
|
|
192
|
+
const sentence = text.match(/^[^.\n]+/);
|
|
193
|
+
if (sentence)
|
|
194
|
+
return sentence[0].trim().slice(0, 100);
|
|
195
|
+
return fallback;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=response-parser.js.map
|
|
@@ -0,0 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