@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.4
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/README.md +44 -54
- package/bin/cli.js +1 -115
- package/bin/loxia-terminal-v2.js +3 -0
- package/bin/loxia-terminal.js +3 -0
- package/bin/start-with-terminal.js +3 -0
- package/package.json +15 -15
- package/scripts/install-scanners.js +1 -235
- package/src/analyzers/CSSAnalyzer.js +1 -297
- package/src/analyzers/ConfigValidator.js +1 -690
- package/src/analyzers/ESLintAnalyzer.js +1 -320
- package/src/analyzers/JavaScriptAnalyzer.js +1 -261
- package/src/analyzers/PrettierFormatter.js +1 -247
- package/src/analyzers/PythonAnalyzer.js +1 -266
- package/src/analyzers/SecurityAnalyzer.js +1 -729
- package/src/analyzers/TypeScriptAnalyzer.js +1 -247
- package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
- package/src/analyzers/codeCloneDetector/detector.js +1 -203
- package/src/analyzers/codeCloneDetector/index.js +1 -160
- package/src/analyzers/codeCloneDetector/parser.js +1 -199
- package/src/analyzers/codeCloneDetector/reporter.js +1 -148
- package/src/analyzers/codeCloneDetector/scanner.js +1 -59
- package/src/core/agentPool.js +1 -1474
- package/src/core/agentScheduler.js +1 -2147
- package/src/core/contextManager.js +1 -709
- package/src/core/messageProcessor.js +1 -732
- package/src/core/orchestrator.js +1 -548
- package/src/core/stateManager.js +1 -877
- package/src/index.js +1 -631
- package/src/interfaces/cli.js +1 -549
- package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
- package/src/interfaces/terminal/api/apiClient.js +1 -0
- package/src/interfaces/terminal/api/messageRouter.js +1 -0
- package/src/interfaces/terminal/api/session.js +1 -0
- package/src/interfaces/terminal/api/websocket.js +1 -0
- package/src/interfaces/terminal/components/AgentCreator.js +1 -0
- package/src/interfaces/terminal/components/AgentEditor.js +1 -0
- package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
- package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
- package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
- package/src/interfaces/terminal/components/Header.js +1 -0
- package/src/interfaces/terminal/components/HelpPanel.js +1 -0
- package/src/interfaces/terminal/components/InputBox.js +1 -0
- package/src/interfaces/terminal/components/Layout.js +1 -0
- package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
- package/src/interfaces/terminal/components/MessageList.js +1 -0
- package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
- package/src/interfaces/terminal/components/SearchPanel.js +1 -0
- package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
- package/src/interfaces/terminal/components/StatusBar.js +1 -0
- package/src/interfaces/terminal/components/TextInput.js +1 -0
- package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
- package/src/interfaces/terminal/config/constants.js +1 -0
- package/src/interfaces/terminal/index.js +1 -0
- package/src/interfaces/terminal/state/useAgentControl.js +1 -0
- package/src/interfaces/terminal/state/useAgents.js +1 -0
- package/src/interfaces/terminal/state/useConnection.js +1 -0
- package/src/interfaces/terminal/state/useMessages.js +1 -0
- package/src/interfaces/terminal/state/useTools.js +1 -0
- package/src/interfaces/terminal/utils/debugLogger.js +1 -0
- package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
- package/src/interfaces/terminal/utils/theme.js +1 -0
- package/src/interfaces/webServer.js +1 -2162
- package/src/modules/fileExplorer/controller.js +1 -280
- package/src/modules/fileExplorer/index.js +1 -37
- package/src/modules/fileExplorer/middleware.js +1 -92
- package/src/modules/fileExplorer/routes.js +1 -125
- package/src/modules/fileExplorer/types.js +1 -44
- package/src/services/aiService.js +1 -1232
- package/src/services/apiKeyManager.js +1 -164
- package/src/services/benchmarkService.js +1 -366
- package/src/services/budgetService.js +1 -539
- package/src/services/contextInjectionService.js +1 -247
- package/src/services/conversationCompactionService.js +1 -637
- package/src/services/errorHandler.js +1 -810
- package/src/services/fileAttachmentService.js +1 -544
- package/src/services/modelRouterService.js +1 -366
- package/src/services/modelsService.js +1 -322
- package/src/services/qualityInspector.js +1 -796
- package/src/services/tokenCountingService.js +1 -536
- package/src/tools/agentCommunicationTool.js +1 -1344
- package/src/tools/agentDelayTool.js +1 -485
- package/src/tools/asyncToolManager.js +1 -604
- package/src/tools/baseTool.js +1 -800
- package/src/tools/browserTool.js +1 -920
- package/src/tools/cloneDetectionTool.js +1 -621
- package/src/tools/dependencyResolverTool.js +1 -1215
- package/src/tools/fileContentReplaceTool.js +1 -875
- package/src/tools/fileSystemTool.js +1 -1107
- package/src/tools/fileTreeTool.js +1 -853
- package/src/tools/imageTool.js +1 -901
- package/src/tools/importAnalyzerTool.js +1 -1060
- package/src/tools/jobDoneTool.js +1 -248
- package/src/tools/seekTool.js +1 -956
- package/src/tools/staticAnalysisTool.js +1 -1778
- package/src/tools/taskManagerTool.js +1 -2873
- package/src/tools/terminalTool.js +1 -2304
- package/src/tools/webTool.js +1 -1430
- package/src/types/agent.js +1 -519
- package/src/types/contextReference.js +1 -972
- package/src/types/conversation.js +1 -730
- package/src/types/toolCommand.js +1 -747
- package/src/utilities/attachmentValidator.js +1 -292
- package/src/utilities/configManager.js +1 -582
- package/src/utilities/constants.js +1 -722
- package/src/utilities/directoryAccessManager.js +1 -535
- package/src/utilities/fileProcessor.js +1 -307
- package/src/utilities/logger.js +1 -436
- package/src/utilities/tagParser.js +1 -1246
- package/src/utilities/toolConstants.js +1 -317
- package/web-ui/build/index.html +2 -2
- package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
- package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
|
@@ -1,730 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Conversation Data Model - Type definitions and validation for conversations
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Define the structure and properties of conversations
|
|
6
|
-
* - Provide validation functions for conversation data
|
|
7
|
-
* - Handle conversation lifecycle and state management
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { CONVERSATION_STATUS, MESSAGE_ROLES } from '../utilities/constants.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Conversation data model
|
|
14
|
-
* @typedef {Object} Conversation
|
|
15
|
-
* @property {string} id - Unique conversation identifier
|
|
16
|
-
* @property {string} title - Human-readable conversation title
|
|
17
|
-
* @property {string} agentId - ID of the associated agent
|
|
18
|
-
* @property {string} status - Conversation status (active, archived, suspended)
|
|
19
|
-
* @property {Message[]} messages - Array of conversation messages
|
|
20
|
-
* @property {ConversationMetadata} metadata - Conversation metadata
|
|
21
|
-
* @property {ConversationSettings} settings - Conversation-specific settings
|
|
22
|
-
* @property {ConversationContext} context - Current conversation context
|
|
23
|
-
* @property {string} createdAt - ISO timestamp of creation
|
|
24
|
-
* @property {string} updatedAt - ISO timestamp of last update
|
|
25
|
-
* @property {string} lastMessageAt - ISO timestamp of last message
|
|
26
|
-
* @property {number} messageCount - Total number of messages
|
|
27
|
-
* @property {number} tokenCount - Total tokens used in conversation
|
|
28
|
-
* @property {number} cost - Total cost of conversation (USD)
|
|
29
|
-
* @property {string[]} participants - List of participant IDs
|
|
30
|
-
* @property {Object} summary - Conversation summary data
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Message data model
|
|
35
|
-
* @typedef {Object} Message
|
|
36
|
-
* @property {string} id - Unique message identifier
|
|
37
|
-
* @property {string} conversationId - ID of parent conversation
|
|
38
|
-
* @property {string} role - Message role (user, assistant, system)
|
|
39
|
-
* @property {string} content - Message content
|
|
40
|
-
* @property {string} agentId - ID of agent (for assistant messages)
|
|
41
|
-
* @property {string} userId - ID of user (for user messages)
|
|
42
|
-
* @property {MessageMetadata} metadata - Message metadata
|
|
43
|
-
* @property {ContextReference[]} contextReferences - Referenced context items
|
|
44
|
-
* @property {ToolExecution[]} toolExecutions - Tool executions in this message
|
|
45
|
-
* @property {TokenUsage} tokenUsage - Token usage for this message
|
|
46
|
-
* @property {string} createdAt - ISO timestamp of creation
|
|
47
|
-
* @property {string} [editedAt] - ISO timestamp of last edit
|
|
48
|
-
* @property {string} [parentMessageId] - ID of parent message (for edits/branches)
|
|
49
|
-
* @property {boolean} isEdited - Whether message has been edited
|
|
50
|
-
* @property {Object} flags - Message flags and annotations
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Conversation metadata
|
|
55
|
-
* @typedef {Object} ConversationMetadata
|
|
56
|
-
* @property {string[]} tags - Conversation tags
|
|
57
|
-
* @property {string} category - Conversation category
|
|
58
|
-
* @property {string} description - Conversation description
|
|
59
|
-
* @property {boolean} isBookmarked - Whether conversation is bookmarked
|
|
60
|
-
* @property {number} priority - Conversation priority (1-5)
|
|
61
|
-
* @property {string} language - Primary language of conversation
|
|
62
|
-
* @property {Object} customFields - Custom metadata fields
|
|
63
|
-
* @property {string[]} relatedConversations - IDs of related conversations
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Conversation settings
|
|
68
|
-
* @typedef {Object} ConversationSettings
|
|
69
|
-
* @property {boolean} persistHistory - Whether to persist conversation history
|
|
70
|
-
* @property {number} maxMessages - Maximum number of messages to keep
|
|
71
|
-
* @property {boolean} autoSummarize - Whether to auto-generate summaries
|
|
72
|
-
* @property {number} summarizeThreshold - Message count threshold for summarization
|
|
73
|
-
* @property {boolean} enableContextReferences - Whether context references are enabled
|
|
74
|
-
* @property {number} maxContextReferences - Maximum context references per message
|
|
75
|
-
* @property {Object} notificationSettings - Notification preferences
|
|
76
|
-
* @property {Object} privacySettings - Privacy and sharing settings
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Conversation context
|
|
81
|
-
* @typedef {Object} ConversationContext
|
|
82
|
-
* @property {string} currentTopic - Current conversation topic
|
|
83
|
-
* @property {string[]} mentionedEntities - Entities mentioned in conversation
|
|
84
|
-
* @property {Object} variables - Context variables and their values
|
|
85
|
-
* @property {string[]} activeTools - Currently active/relevant tools
|
|
86
|
-
* @property {Object} workingMemory - Short-term memory for conversation
|
|
87
|
-
* @property {Object} preferences - User preferences relevant to conversation
|
|
88
|
-
* @property {string} phase - Current conversation phase
|
|
89
|
-
* @property {Object} goals - Conversation goals and objectives
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Message metadata
|
|
94
|
-
* @typedef {Object} MessageMetadata
|
|
95
|
-
* @property {string} model - AI model used (for assistant messages)
|
|
96
|
-
* @property {number} temperature - Generation temperature used
|
|
97
|
-
* @property {number} responseTime - Time taken to generate response (ms)
|
|
98
|
-
* @property {string} ipAddress - IP address of sender (if applicable)
|
|
99
|
-
* @property {string} userAgent - User agent string (if applicable)
|
|
100
|
-
* @property {Object} modelParameters - Model-specific parameters used
|
|
101
|
-
* @property {string} generationId - Unique generation identifier
|
|
102
|
-
* @property {Object} annotations - Message annotations and labels
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Token usage information
|
|
107
|
-
* @typedef {Object} TokenUsage
|
|
108
|
-
* @property {number} promptTokens - Tokens used in prompt
|
|
109
|
-
* @property {number} completionTokens - Tokens used in completion
|
|
110
|
-
* @property {number} totalTokens - Total tokens used
|
|
111
|
-
* @property {number} cost - Cost of token usage (USD)
|
|
112
|
-
* @property {string} model - Model used for generation
|
|
113
|
-
* @property {Object} breakdown - Detailed token usage breakdown
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Context reference in messages
|
|
118
|
-
* @typedef {Object} ContextReference
|
|
119
|
-
* @property {string} id - Unique reference identifier
|
|
120
|
-
* @property {string} type - Reference type (file, component, selection, directory)
|
|
121
|
-
* @property {string} path - Path or identifier of referenced item
|
|
122
|
-
* @property {string} name - Human-readable name
|
|
123
|
-
* @property {string} [content] - Referenced content (if applicable)
|
|
124
|
-
* @property {number} [startLine] - Start line (for selections)
|
|
125
|
-
* @property {number} [endLine] - End line (for selections)
|
|
126
|
-
* @property {Object} metadata - Reference metadata
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Tool execution information
|
|
131
|
-
* @typedef {Object} ToolExecution
|
|
132
|
-
* @property {string} id - Unique execution identifier
|
|
133
|
-
* @property {string} toolId - Tool identifier
|
|
134
|
-
* @property {string} status - Execution status (pending, executing, completed, failed)
|
|
135
|
-
* @property {Object} input - Tool input parameters
|
|
136
|
-
* @property {Object} [output] - Tool output (if completed)
|
|
137
|
-
* @property {string} [error] - Error message (if failed)
|
|
138
|
-
* @property {number} executionTime - Execution time in milliseconds
|
|
139
|
-
* @property {string} startedAt - ISO timestamp when execution started
|
|
140
|
-
* @property {string} [completedAt] - ISO timestamp when execution completed
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Conversation validation functions
|
|
145
|
-
*/
|
|
146
|
-
export class ConversationValidator {
|
|
147
|
-
/**
|
|
148
|
-
* Validate conversation data structure
|
|
149
|
-
* @param {Object} conversation - Conversation data to validate
|
|
150
|
-
* @returns {Object} Validation result
|
|
151
|
-
*/
|
|
152
|
-
static validate(conversation) {
|
|
153
|
-
const errors = [];
|
|
154
|
-
const warnings = [];
|
|
155
|
-
|
|
156
|
-
// Required fields
|
|
157
|
-
if (!conversation.id || typeof conversation.id !== 'string') {
|
|
158
|
-
errors.push('Conversation ID is required and must be a string');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (!conversation.agentId || typeof conversation.agentId !== 'string') {
|
|
162
|
-
errors.push('Agent ID is required and must be a string');
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (!conversation.title || typeof conversation.title !== 'string') {
|
|
166
|
-
errors.push('Conversation title is required and must be a string');
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (conversation.title && conversation.title.length > 200) {
|
|
170
|
-
warnings.push('Conversation title is very long (>200 characters)');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Status validation
|
|
174
|
-
if (conversation.status && !Object.values(CONVERSATION_STATUS).includes(conversation.status)) {
|
|
175
|
-
errors.push(`Invalid conversation status: ${conversation.status}`);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Messages validation
|
|
179
|
-
if (conversation.messages && !Array.isArray(conversation.messages)) {
|
|
180
|
-
errors.push('Messages must be an array');
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (conversation.messages) {
|
|
184
|
-
conversation.messages.forEach((message, index) => {
|
|
185
|
-
const messageValidation = this.validateMessage(message);
|
|
186
|
-
messageValidation.errors.forEach(error => {
|
|
187
|
-
errors.push(`Message ${index}: ${error}`);
|
|
188
|
-
});
|
|
189
|
-
messageValidation.warnings.forEach(warning => {
|
|
190
|
-
warnings.push(`Message ${index}: ${warning}`);
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Numeric validations
|
|
196
|
-
if (conversation.messageCount !== undefined && typeof conversation.messageCount !== 'number') {
|
|
197
|
-
errors.push('Message count must be a number');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (conversation.tokenCount !== undefined && typeof conversation.tokenCount !== 'number') {
|
|
201
|
-
errors.push('Token count must be a number');
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (conversation.cost !== undefined && typeof conversation.cost !== 'number') {
|
|
205
|
-
errors.push('Cost must be a number');
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Participants validation
|
|
209
|
-
if (conversation.participants && !Array.isArray(conversation.participants)) {
|
|
210
|
-
errors.push('Participants must be an array');
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Timestamp validation
|
|
214
|
-
const timestampFields = ['createdAt', 'updatedAt', 'lastMessageAt'];
|
|
215
|
-
timestampFields.forEach(field => {
|
|
216
|
-
if (conversation[field] && !this.isValidTimestamp(conversation[field])) {
|
|
217
|
-
errors.push(`Invalid timestamp for ${field}: ${conversation[field]}`);
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
return {
|
|
222
|
-
isValid: errors.length === 0,
|
|
223
|
-
errors,
|
|
224
|
-
warnings
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Validate message data structure
|
|
230
|
-
* @param {Object} message - Message data to validate
|
|
231
|
-
* @returns {Object} Validation result
|
|
232
|
-
*/
|
|
233
|
-
static validateMessage(message) {
|
|
234
|
-
const errors = [];
|
|
235
|
-
const warnings = [];
|
|
236
|
-
|
|
237
|
-
// Required fields
|
|
238
|
-
if (!message.id || typeof message.id !== 'string') {
|
|
239
|
-
errors.push('Message ID is required and must be a string');
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (!message.conversationId || typeof message.conversationId !== 'string') {
|
|
243
|
-
errors.push('Conversation ID is required and must be a string');
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (!message.role || typeof message.role !== 'string') {
|
|
247
|
-
errors.push('Message role is required and must be a string');
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (message.role && !Object.values(MESSAGE_ROLES).includes(message.role)) {
|
|
251
|
-
errors.push(`Invalid message role: ${message.role}`);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (!message.content || typeof message.content !== 'string') {
|
|
255
|
-
errors.push('Message content is required and must be a string');
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (message.content && message.content.length > 100000) {
|
|
259
|
-
warnings.push('Message content is very long (>100000 characters)');
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Role-specific validations
|
|
263
|
-
if (message.role === MESSAGE_ROLES.ASSISTANT && !message.agentId) {
|
|
264
|
-
errors.push('Assistant messages must have an agentId');
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (message.role === MESSAGE_ROLES.USER && !message.userId) {
|
|
268
|
-
warnings.push('User messages should have a userId');
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// Context references validation
|
|
272
|
-
if (message.contextReferences && !Array.isArray(message.contextReferences)) {
|
|
273
|
-
errors.push('Context references must be an array');
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// Tool executions validation
|
|
277
|
-
if (message.toolExecutions && !Array.isArray(message.toolExecutions)) {
|
|
278
|
-
errors.push('Tool executions must be an array');
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Token usage validation
|
|
282
|
-
if (message.tokenUsage) {
|
|
283
|
-
const tokenValidation = this.validateTokenUsage(message.tokenUsage);
|
|
284
|
-
errors.push(...tokenValidation.errors);
|
|
285
|
-
warnings.push(...tokenValidation.warnings);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// Timestamp validation
|
|
289
|
-
if (message.createdAt && !this.isValidTimestamp(message.createdAt)) {
|
|
290
|
-
errors.push(`Invalid createdAt timestamp: ${message.createdAt}`);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (message.editedAt && !this.isValidTimestamp(message.editedAt)) {
|
|
294
|
-
errors.push(`Invalid editedAt timestamp: ${message.editedAt}`);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
return { errors, warnings };
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Validate token usage data
|
|
302
|
-
* @param {Object} tokenUsage - Token usage to validate
|
|
303
|
-
* @returns {Object} Validation result
|
|
304
|
-
*/
|
|
305
|
-
static validateTokenUsage(tokenUsage) {
|
|
306
|
-
const errors = [];
|
|
307
|
-
const warnings = [];
|
|
308
|
-
|
|
309
|
-
if (typeof tokenUsage.totalTokens !== 'number' || tokenUsage.totalTokens < 0) {
|
|
310
|
-
errors.push('Total tokens must be a non-negative number');
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (tokenUsage.promptTokens !== undefined && (typeof tokenUsage.promptTokens !== 'number' || tokenUsage.promptTokens < 0)) {
|
|
314
|
-
errors.push('Prompt tokens must be a non-negative number');
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if (tokenUsage.completionTokens !== undefined && (typeof tokenUsage.completionTokens !== 'number' || tokenUsage.completionTokens < 0)) {
|
|
318
|
-
errors.push('Completion tokens must be a non-negative number');
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
if (tokenUsage.cost !== undefined && (typeof tokenUsage.cost !== 'number' || tokenUsage.cost < 0)) {
|
|
322
|
-
errors.push('Cost must be a non-negative number');
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (tokenUsage.promptTokens && tokenUsage.completionTokens) {
|
|
326
|
-
const calculatedTotal = tokenUsage.promptTokens + tokenUsage.completionTokens;
|
|
327
|
-
if (Math.abs(calculatedTotal - tokenUsage.totalTokens) > 1) {
|
|
328
|
-
warnings.push('Total tokens does not match sum of prompt and completion tokens');
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
return { errors, warnings };
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Check if a timestamp is valid ISO string
|
|
337
|
-
* @param {string} timestamp - Timestamp to validate
|
|
338
|
-
* @returns {boolean} True if valid
|
|
339
|
-
*/
|
|
340
|
-
static isValidTimestamp(timestamp) {
|
|
341
|
-
if (typeof timestamp !== 'string') return false;
|
|
342
|
-
const date = new Date(timestamp);
|
|
343
|
-
return date instanceof Date && !isNaN(date.getTime());
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Conversation factory functions
|
|
349
|
-
*/
|
|
350
|
-
export class ConversationFactory {
|
|
351
|
-
/**
|
|
352
|
-
* Create a new conversation
|
|
353
|
-
* @param {string} agentId - Agent ID
|
|
354
|
-
* @param {string} title - Conversation title
|
|
355
|
-
* @param {Object} options - Additional options
|
|
356
|
-
* @returns {Conversation} New conversation object
|
|
357
|
-
*/
|
|
358
|
-
static create(agentId, title, options = {}) {
|
|
359
|
-
const now = new Date().toISOString();
|
|
360
|
-
const conversationId = this.generateConversationId();
|
|
361
|
-
|
|
362
|
-
return {
|
|
363
|
-
id: conversationId,
|
|
364
|
-
title: title || 'New Conversation',
|
|
365
|
-
agentId,
|
|
366
|
-
status: CONVERSATION_STATUS.ACTIVE,
|
|
367
|
-
messages: [],
|
|
368
|
-
metadata: this.createDefaultMetadata(options.metadata),
|
|
369
|
-
settings: this.createDefaultSettings(options.settings),
|
|
370
|
-
context: this.createDefaultContext(),
|
|
371
|
-
createdAt: now,
|
|
372
|
-
updatedAt: now,
|
|
373
|
-
lastMessageAt: now,
|
|
374
|
-
messageCount: 0,
|
|
375
|
-
tokenCount: 0,
|
|
376
|
-
cost: 0,
|
|
377
|
-
participants: [agentId, ...(options.participants || [])],
|
|
378
|
-
summary: {}
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Create a new message
|
|
384
|
-
* @param {string} conversationId - Conversation ID
|
|
385
|
-
* @param {string} role - Message role
|
|
386
|
-
* @param {string} content - Message content
|
|
387
|
-
* @param {Object} options - Additional options
|
|
388
|
-
* @returns {Message} New message object
|
|
389
|
-
*/
|
|
390
|
-
static createMessage(conversationId, role, content, options = {}) {
|
|
391
|
-
const now = new Date().toISOString();
|
|
392
|
-
const messageId = this.generateMessageId();
|
|
393
|
-
|
|
394
|
-
return {
|
|
395
|
-
id: messageId,
|
|
396
|
-
conversationId,
|
|
397
|
-
role,
|
|
398
|
-
content,
|
|
399
|
-
agentId: options.agentId || null,
|
|
400
|
-
userId: options.userId || null,
|
|
401
|
-
metadata: options.metadata || {},
|
|
402
|
-
contextReferences: options.contextReferences || [],
|
|
403
|
-
toolExecutions: options.toolExecutions || [],
|
|
404
|
-
tokenUsage: options.tokenUsage || null,
|
|
405
|
-
createdAt: now,
|
|
406
|
-
editedAt: null,
|
|
407
|
-
parentMessageId: options.parentMessageId || null,
|
|
408
|
-
isEdited: false,
|
|
409
|
-
flags: options.flags || {}
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Create default conversation metadata
|
|
415
|
-
* @param {Object} overrides - Metadata overrides
|
|
416
|
-
* @returns {ConversationMetadata} Default metadata
|
|
417
|
-
*/
|
|
418
|
-
static createDefaultMetadata(overrides = {}) {
|
|
419
|
-
return {
|
|
420
|
-
tags: [],
|
|
421
|
-
category: 'general',
|
|
422
|
-
description: '',
|
|
423
|
-
isBookmarked: false,
|
|
424
|
-
priority: 3,
|
|
425
|
-
language: 'en',
|
|
426
|
-
customFields: {},
|
|
427
|
-
relatedConversations: [],
|
|
428
|
-
...overrides
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Create default conversation settings
|
|
434
|
-
* @param {Object} overrides - Settings overrides
|
|
435
|
-
* @returns {ConversationSettings} Default settings
|
|
436
|
-
*/
|
|
437
|
-
static createDefaultSettings(overrides = {}) {
|
|
438
|
-
return {
|
|
439
|
-
persistHistory: true,
|
|
440
|
-
maxMessages: 1000,
|
|
441
|
-
autoSummarize: true,
|
|
442
|
-
summarizeThreshold: 50,
|
|
443
|
-
enableContextReferences: true,
|
|
444
|
-
maxContextReferences: 10,
|
|
445
|
-
notificationSettings: {
|
|
446
|
-
newMessage: true,
|
|
447
|
-
agentResponse: true,
|
|
448
|
-
toolExecution: false
|
|
449
|
-
},
|
|
450
|
-
privacySettings: {
|
|
451
|
-
shareHistory: false,
|
|
452
|
-
allowAnalytics: true
|
|
453
|
-
},
|
|
454
|
-
...overrides
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Create default conversation context
|
|
460
|
-
* @returns {ConversationContext} Default context
|
|
461
|
-
*/
|
|
462
|
-
static createDefaultContext() {
|
|
463
|
-
return {
|
|
464
|
-
currentTopic: null,
|
|
465
|
-
mentionedEntities: [],
|
|
466
|
-
variables: {},
|
|
467
|
-
activeTools: [],
|
|
468
|
-
workingMemory: {},
|
|
469
|
-
preferences: {},
|
|
470
|
-
phase: 'initial',
|
|
471
|
-
goals: {}
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Generate unique conversation ID
|
|
477
|
-
* @returns {string} Unique conversation ID
|
|
478
|
-
*/
|
|
479
|
-
static generateConversationId() {
|
|
480
|
-
const timestamp = Date.now().toString(36);
|
|
481
|
-
const random = Math.random().toString(36).substr(2, 9);
|
|
482
|
-
return `conv_${timestamp}_${random}`;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Generate unique message ID
|
|
487
|
-
* @returns {string} Unique message ID
|
|
488
|
-
*/
|
|
489
|
-
static generateMessageId() {
|
|
490
|
-
const timestamp = Date.now().toString(36);
|
|
491
|
-
const random = Math.random().toString(36).substr(2, 9);
|
|
492
|
-
return `msg_${timestamp}_${random}`;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Conversation utility functions
|
|
498
|
-
*/
|
|
499
|
-
export class ConversationUtils {
|
|
500
|
-
/**
|
|
501
|
-
* Calculate conversation statistics
|
|
502
|
-
* @param {Conversation} conversation - Conversation to analyze
|
|
503
|
-
* @returns {Object} Conversation statistics
|
|
504
|
-
*/
|
|
505
|
-
static getStatistics(conversation) {
|
|
506
|
-
const messages = conversation.messages || [];
|
|
507
|
-
const userMessages = messages.filter(m => m.role === MESSAGE_ROLES.USER);
|
|
508
|
-
const assistantMessages = messages.filter(m => m.role === MESSAGE_ROLES.ASSISTANT);
|
|
509
|
-
const systemMessages = messages.filter(m => m.role === MESSAGE_ROLES.SYSTEM);
|
|
510
|
-
|
|
511
|
-
const totalTokens = messages.reduce((sum, m) => sum + (m.tokenUsage?.totalTokens || 0), 0);
|
|
512
|
-
const totalCost = messages.reduce((sum, m) => sum + (m.tokenUsage?.cost || 0), 0);
|
|
513
|
-
|
|
514
|
-
const toolExecutions = messages.reduce((sum, m) => sum + (m.toolExecutions?.length || 0), 0);
|
|
515
|
-
const contextReferences = messages.reduce((sum, m) => sum + (m.contextReferences?.length || 0), 0);
|
|
516
|
-
|
|
517
|
-
return {
|
|
518
|
-
totalMessages: messages.length,
|
|
519
|
-
userMessages: userMessages.length,
|
|
520
|
-
assistantMessages: assistantMessages.length,
|
|
521
|
-
systemMessages: systemMessages.length,
|
|
522
|
-
totalTokens,
|
|
523
|
-
totalCost,
|
|
524
|
-
toolExecutions,
|
|
525
|
-
contextReferences,
|
|
526
|
-
averageMessageLength: messages.length > 0
|
|
527
|
-
? messages.reduce((sum, m) => sum + m.content.length, 0) / messages.length
|
|
528
|
-
: 0,
|
|
529
|
-
conversationDuration: this.getConversationDuration(conversation)
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* Get conversation duration in milliseconds
|
|
535
|
-
* @param {Conversation} conversation - Conversation to analyze
|
|
536
|
-
* @returns {number} Duration in milliseconds
|
|
537
|
-
*/
|
|
538
|
-
static getConversationDuration(conversation) {
|
|
539
|
-
if (!conversation.messages || conversation.messages.length === 0) {
|
|
540
|
-
return 0;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
const firstMessage = conversation.messages[0];
|
|
544
|
-
const lastMessage = conversation.messages[conversation.messages.length - 1];
|
|
545
|
-
|
|
546
|
-
const startTime = new Date(firstMessage.createdAt);
|
|
547
|
-
const endTime = new Date(lastMessage.createdAt);
|
|
548
|
-
|
|
549
|
-
return endTime.getTime() - startTime.getTime();
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Generate conversation summary
|
|
554
|
-
* @param {Conversation} conversation - Conversation to summarize
|
|
555
|
-
* @returns {Object} Conversation summary
|
|
556
|
-
*/
|
|
557
|
-
static generateSummary(conversation) {
|
|
558
|
-
const stats = this.getStatistics(conversation);
|
|
559
|
-
const messages = conversation.messages || [];
|
|
560
|
-
|
|
561
|
-
// Extract key topics and entities
|
|
562
|
-
const topics = this.extractTopics(messages);
|
|
563
|
-
const entities = this.extractEntities(messages);
|
|
564
|
-
|
|
565
|
-
// Get recent activity
|
|
566
|
-
const recentMessages = messages.slice(-10);
|
|
567
|
-
const lastActivity = conversation.lastMessageAt || conversation.updatedAt;
|
|
568
|
-
|
|
569
|
-
return {
|
|
570
|
-
title: conversation.title,
|
|
571
|
-
messageCount: stats.totalMessages,
|
|
572
|
-
duration: stats.conversationDuration,
|
|
573
|
-
participants: conversation.participants.length,
|
|
574
|
-
topics: topics.slice(0, 5), // Top 5 topics
|
|
575
|
-
entities: entities.slice(0, 10), // Top 10 entities
|
|
576
|
-
lastActivity,
|
|
577
|
-
recentActivity: recentMessages.map(m => ({
|
|
578
|
-
role: m.role,
|
|
579
|
-
timestamp: m.createdAt,
|
|
580
|
-
preview: m.content.substring(0, 100) + (m.content.length > 100 ? '...' : '')
|
|
581
|
-
})),
|
|
582
|
-
stats
|
|
583
|
-
};
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* Extract topics from conversation messages
|
|
588
|
-
* @param {Message[]} messages - Messages to analyze
|
|
589
|
-
* @returns {string[]} Extracted topics
|
|
590
|
-
*/
|
|
591
|
-
static extractTopics(messages) {
|
|
592
|
-
// Simple topic extraction based on keywords
|
|
593
|
-
// In a real implementation, this would use more sophisticated NLP
|
|
594
|
-
const topicKeywords = new Map();
|
|
595
|
-
|
|
596
|
-
messages.forEach(message => {
|
|
597
|
-
const words = message.content.toLowerCase()
|
|
598
|
-
.split(/\s+/)
|
|
599
|
-
.filter(word => word.length > 3 && !this.isStopWord(word));
|
|
600
|
-
|
|
601
|
-
words.forEach(word => {
|
|
602
|
-
topicKeywords.set(word, (topicKeywords.get(word) || 0) + 1);
|
|
603
|
-
});
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
return Array.from(topicKeywords.entries())
|
|
607
|
-
.sort((a, b) => b[1] - a[1])
|
|
608
|
-
.map(([word]) => word);
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* Extract entities from conversation messages
|
|
613
|
-
* @param {Message[]} messages - Messages to analyze
|
|
614
|
-
* @returns {string[]} Extracted entities
|
|
615
|
-
*/
|
|
616
|
-
static extractEntities(messages) {
|
|
617
|
-
// Simple entity extraction
|
|
618
|
-
// In a real implementation, this would use NER
|
|
619
|
-
const entities = new Set();
|
|
620
|
-
|
|
621
|
-
messages.forEach(message => {
|
|
622
|
-
// Extract capitalized words (potential proper nouns)
|
|
623
|
-
const capitalizedWords = message.content.match(/\b[A-Z][a-z]+\b/g) || [];
|
|
624
|
-
capitalizedWords.forEach(word => entities.add(word));
|
|
625
|
-
|
|
626
|
-
// Extract file paths
|
|
627
|
-
const filePaths = message.content.match(/\b[\w\/\-\.]+\.\w+\b/g) || [];
|
|
628
|
-
filePaths.forEach(path => entities.add(path));
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
return Array.from(entities);
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* Check if word is a stop word
|
|
636
|
-
* @param {string} word - Word to check
|
|
637
|
-
* @returns {boolean} True if stop word
|
|
638
|
-
*/
|
|
639
|
-
static isStopWord(word) {
|
|
640
|
-
const stopWords = new Set([
|
|
641
|
-
'the', 'and', 'or', 'but', 'in', 'on', 'at', 'to', 'for', 'of', 'with',
|
|
642
|
-
'by', 'from', 'up', 'about', 'into', 'through', 'during', 'before',
|
|
643
|
-
'after', 'above', 'below', 'over', 'under', 'again', 'further',
|
|
644
|
-
'then', 'once', 'here', 'there', 'when', 'where', 'why', 'how',
|
|
645
|
-
'all', 'any', 'both', 'each', 'few', 'more', 'most', 'other',
|
|
646
|
-
'some', 'such', 'only', 'own', 'same', 'so', 'than', 'too',
|
|
647
|
-
'very', 'can', 'will', 'just', 'should', 'now'
|
|
648
|
-
]);
|
|
649
|
-
|
|
650
|
-
return stopWords.has(word.toLowerCase());
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* Format conversation for export
|
|
655
|
-
* @param {Conversation} conversation - Conversation to format
|
|
656
|
-
* @param {string} format - Export format ('json', 'markdown', 'plain')
|
|
657
|
-
* @returns {string} Formatted conversation
|
|
658
|
-
*/
|
|
659
|
-
static formatForExport(conversation, format = 'json') {
|
|
660
|
-
switch (format) {
|
|
661
|
-
case 'markdown':
|
|
662
|
-
return this.formatAsMarkdown(conversation);
|
|
663
|
-
case 'plain':
|
|
664
|
-
return this.formatAsPlainText(conversation);
|
|
665
|
-
case 'json':
|
|
666
|
-
default:
|
|
667
|
-
return JSON.stringify(conversation, null, 2);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* Format conversation as markdown
|
|
673
|
-
* @param {Conversation} conversation - Conversation to format
|
|
674
|
-
* @returns {string} Markdown formatted conversation
|
|
675
|
-
*/
|
|
676
|
-
static formatAsMarkdown(conversation) {
|
|
677
|
-
let markdown = `# ${conversation.title}\n\n`;
|
|
678
|
-
markdown += `**Created:** ${new Date(conversation.createdAt).toLocaleString()}\n`;
|
|
679
|
-
markdown += `**Agent:** ${conversation.agentId}\n`;
|
|
680
|
-
markdown += `**Messages:** ${conversation.messageCount}\n\n`;
|
|
681
|
-
|
|
682
|
-
conversation.messages.forEach(message => {
|
|
683
|
-
const timestamp = new Date(message.createdAt).toLocaleTimeString();
|
|
684
|
-
const role = message.role.charAt(0).toUpperCase() + message.role.slice(1);
|
|
685
|
-
|
|
686
|
-
markdown += `## ${role} (${timestamp})\n\n`;
|
|
687
|
-
markdown += `${message.content}\n\n`;
|
|
688
|
-
|
|
689
|
-
if (message.contextReferences && message.contextReferences.length > 0) {
|
|
690
|
-
markdown += `**Context References:**\n`;
|
|
691
|
-
message.contextReferences.forEach(ref => {
|
|
692
|
-
markdown += `- ${ref.name} (${ref.type})\n`;
|
|
693
|
-
});
|
|
694
|
-
markdown += '\n';
|
|
695
|
-
}
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
return markdown;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Format conversation as plain text
|
|
703
|
-
* @param {Conversation} conversation - Conversation to format
|
|
704
|
-
* @returns {string} Plain text formatted conversation
|
|
705
|
-
*/
|
|
706
|
-
static formatAsPlainText(conversation) {
|
|
707
|
-
let text = `Conversation: ${conversation.title}\n`;
|
|
708
|
-
text += `Created: ${new Date(conversation.createdAt).toLocaleString()}\n`;
|
|
709
|
-
text += `Agent: ${conversation.agentId}\n`;
|
|
710
|
-
text += `Messages: ${conversation.messageCount}\n\n`;
|
|
711
|
-
|
|
712
|
-
text += '-'.repeat(50) + '\n\n';
|
|
713
|
-
|
|
714
|
-
conversation.messages.forEach(message => {
|
|
715
|
-
const timestamp = new Date(message.createdAt).toLocaleTimeString();
|
|
716
|
-
const role = message.role.toUpperCase();
|
|
717
|
-
|
|
718
|
-
text += `[${timestamp}] ${role}:\n`;
|
|
719
|
-
text += `${message.content}\n\n`;
|
|
720
|
-
});
|
|
721
|
-
|
|
722
|
-
return text;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
export default {
|
|
727
|
-
ConversationValidator,
|
|
728
|
-
ConversationFactory,
|
|
729
|
-
ConversationUtils
|
|
730
|
-
};
|
|
1
|
+
const a0_0x558d39=a0_0x53e6;function a0_0x53e6(_0x3d8061,_0x1bad76){_0x3d8061=_0x3d8061-0x14e;const _0x427700=a0_0x4277();let _0x53e660=_0x427700[_0x3d8061];if(a0_0x53e6['LvpoGD']===undefined){var _0x207d2c=function(_0x4602ca){const _0x542a0b='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x231f3b='',_0x2ac9f5='';for(let _0x43beec=0x0,_0x4797e1,_0x566e65,_0x48d05b=0x0;_0x566e65=_0x4602ca['charAt'](_0x48d05b++);~_0x566e65&&(_0x4797e1=_0x43beec%0x4?_0x4797e1*0x40+_0x566e65:_0x566e65,_0x43beec++%0x4)?_0x231f3b+=String['fromCharCode'](0xff&_0x4797e1>>(-0x2*_0x43beec&0x6)):0x0){_0x566e65=_0x542a0b['indexOf'](_0x566e65);}for(let _0x6f372d=0x0,_0x9b341c=_0x231f3b['length'];_0x6f372d<_0x9b341c;_0x6f372d++){_0x2ac9f5+='%'+('00'+_0x231f3b['charCodeAt'](_0x6f372d)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2ac9f5);};a0_0x53e6['QzqJkk']=_0x207d2c,a0_0x53e6['BnEphy']={},a0_0x53e6['LvpoGD']=!![];}const _0x3f411b=_0x427700[0x0],_0x1e652a=_0x3d8061+_0x3f411b,_0x34271c=a0_0x53e6['BnEphy'][_0x1e652a];return!_0x34271c?(_0x53e660=a0_0x53e6['QzqJkk'](_0x53e660),a0_0x53e6['BnEphy'][_0x1e652a]=_0x53e660):_0x53e660=_0x34271c,_0x53e660;}(function(_0x370070,_0x114908){const _0x2835f2=a0_0x53e6,_0x54ff7c=_0x370070();while(!![]){try{const _0x433f3e=parseInt(_0x2835f2(0x1be))/0x1*(-parseInt(_0x2835f2(0x16c))/0x2)+-parseInt(_0x2835f2(0x199))/0x3+parseInt(_0x2835f2(0x186))/0x4*(-parseInt(_0x2835f2(0x16a))/0x5)+parseInt(_0x2835f2(0x1cb))/0x6+-parseInt(_0x2835f2(0x163))/0x7+parseInt(_0x2835f2(0x158))/0x8+parseInt(_0x2835f2(0x1cd))/0x9;if(_0x433f3e===_0x114908)break;else _0x54ff7c['push'](_0x54ff7c['shift']());}catch(_0x40068a){_0x54ff7c['push'](_0x54ff7c['shift']());}}}(a0_0x4277,0xad276));function a0_0x4277(){const _0x53fd5a=['yM90Aa','DMfSAwrHDgu','CMvKDwnL','zxH0CMfJDfrVCgLJCW','mtjwEMvZDeC','BwvZC2fNzxm','BNvTyMvY','yNv0','Dg9Rzw5vC2fNzq','y2HHCKf0','C2XPy2u','qunusvzf','C3rYAw5NAwz5','Dg90ywXuB2TLBNm','BgfZDe1LC3nHz2vbDa','twvZC2fNzsbjrcbPCYbYzxf1AxjLzcbHBMqGBxvZDcbIzsbHihn0CMLUzW','uhjVBxb0ihrVA2vUCYbTDxn0igjLigeGBM9Ulw5Lz2f0AxzLig51BwjLCG','DMfSDwvZ','y3jLyxrLrgvMyxvSDe1LDgfKyxrH','y29ZDa','twvZC2fNzsbJB3vUDcbTDxn0igjLigeGBNvTyMvY','y3jLyxrLrgvMyxvSDfnLDhrPBMDZ','ANnVBG','ndiWndm4oxDWvxbsBq','C2v0','DgHL','ANvZDa','zM9YBwf0qxnqBgfPBLrLEhq','BgvUz3rO','BwfW','ywjVDxq','CgfYDgLJAxbHBNrZ','zNjVBq','kIPdCMvHDgvKoIOQia','D2LSBa','Dg9vChbLCKnHC2u','DMvYEq','DgHHBG','Dg9ju09tDhjPBMC','q29UDMvYC2f0Aw9UihrPDgXLigLZihjLCxvPCMvKigfUzcbTDxn0igjLigeGC3rYAw5N','Dg9mB2nHBgvuAw1Lu3rYAw5N','qwDLBNqGsuqGAxmGCMvXDwLYzwqGyw5Kig11C3qGyMuGysbZDhjPBMC','zxjYB3jZ','Ag93','z2v0','q29UDMvYC2f0Aw9UoIa','z2v0vgLTzq','C2HVDwXK','zM9YrwfJAa','sw52ywXPzcbJCMvHDgvKqxqGDgLTzxn0yw1WoIa','zM9YBwf0qxnnyxjRzg93BG','DgHLCMu','Aw5JBhvKzxm','zwfJAa','qwDLBNq6ia','AxntDg9Wv29Yza','BwvZC2fNzunVDw50','z2vUzxjHDgvdB252zxjZyxrPB25jza','y29UDgvUDa','ChjVBxb0vg9Rzw5Z','mtzvrKzjCLm','C2v0DgLUz3m','B3zLCG','iYmG','AxnbCNjHEq','CgXHAw4','y2fU','vxnLCIbTzxnZywDLCYbZAg91BgqGAgf2zsbHihvZzxjjza','twvZC2fNzsbJB250zw50igLZihzLCNKGBg9UzYaOpJeWmdaWmcbJAgfYywn0zxjZkq','zMLSDgvY','AxnwywXPzfrPBwvZDgfTCa','vg9Rzw4Gy291BNqGBxvZDcbIzsbHig51BwjLCG','Dg9mB3DLCKnHC2u','mJe4mJe0menLwKLUuW','AgvYzq','mte1nJyWotHKEMXYsuG','Bwv0ywrHDge','zwrPDgvKqxq','zMXHz3m','sw52ywXPzcb0Aw1LC3rHBxaGzM9Yia','zM9YBwf0rM9YrxHWB3j0','DMfSAwrHDgvuB2TLBLvZywDL','y29TCgXLDgLVBLrVA2vUCW','z2vUzxjHDgvnzxnZywDLswq','ywDLBNrjza','twvZC2fNzxm6ia','Dw5Kzxi','B25SEq','y3jLyxrLzef0','y29UDgv4DfjLzMvYzw5Jzxm','odK2nZyWohDrwhH3vq','C29YDa','zxH0CMfJDevUDgL0AwvZ','y29UDMvYC2f0Aw9UrhvYyxrPB24','B3rOzxi','z2v0u3rHDgLZDgLJCW','Dg9Rzw5dB3vUDa','Dg9V','ywXS','ywjZ','q29ZDcbTDxn0igjLigeGBNvTyMvY','otKYnJq5EMfVu29V','Dg9VBev4zwn1DgLVBNm','sw52ywXPzcbJB252zxjZyxrPB24GC3rHDhvZoIa','z2v0q29UDMvYC2f0Aw9UrhvYyxrPB24','ChvZAa','C3rYAw5N','D2fYBMLUz3m','mZuWnZa1u1zMvfr6','kIPbz2vUDdOQkIa','mZGZntr1DgnMzLm','tMv3ienVBNzLCNnHDgLVBG','twvZC2fNzsbYB2XLigLZihjLCxvPCMvKigfUzcbTDxn0igjLigeGC3rYAw5N','DgL0Bgu','Bwf0y2G','z2vUzxjHBa','BxnNxW','q29UDMvYC2f0Aw9UihrPDgXLigLZihzLCNKGBg9UzYaOpJiWmcbJAgfYywn0zxjZkq','qxnZAxn0yw50ig1LC3nHz2vZig11C3qGAgf2zsbHBIbHz2vUDeLK','zw50CMLLCW','kIPnzxnZywDLCZOQkIa','Dg9mB2nHBgvtDhjPBMC','Dg90ywXnzxnZywDLCW','yMvMB3jL','CM9Szq','BwfYA2rVD24','B3DU','C3rHDhvZ','CMfUzg9T','zNvYDgHLCG','y3jLyxrLrgvMyxvSDenVBNrLEhq','vvnfuG'];a0_0x4277=function(){return _0x53fd5a;};return a0_0x4277();}import{CONVERSATION_STATUS,MESSAGE_ROLES}from'../utilities/constants.js';export class ConversationValidator{static[a0_0x558d39(0x183)](_0x231f3b){const _0x55e6ff=a0_0x558d39,_0x2ac9f5=[],_0x43beec=[];(!_0x231f3b['id']||typeof _0x231f3b['id']!==_0x55e6ff(0x168))&&_0x2ac9f5[_0x55e6ff(0x167)]('Conversation\x20ID\x20is\x20required\x20and\x20must\x20be\x20a\x20string');(!_0x231f3b[_0x55e6ff(0x152)]||typeof _0x231f3b[_0x55e6ff(0x152)]!==_0x55e6ff(0x168))&&_0x2ac9f5[_0x55e6ff(0x167)](_0x55e6ff(0x1ab));(!_0x231f3b[_0x55e6ff(0x16f)]||typeof _0x231f3b['title']!=='string')&&_0x2ac9f5['push'](_0x55e6ff(0x1a9));_0x231f3b['title']&&_0x231f3b[_0x55e6ff(0x16f)]['length']>0xc8&&_0x43beec['push'](_0x55e6ff(0x173));_0x231f3b['status']&&!Object[_0x55e6ff(0x193)](CONVERSATION_STATUS)[_0x55e6ff(0x1b6)](_0x231f3b[_0x55e6ff(0x17d)])&&_0x2ac9f5[_0x55e6ff(0x167)](_0x55e6ff(0x165)+_0x231f3b[_0x55e6ff(0x17d)]);_0x231f3b[_0x55e6ff(0x187)]&&!Array[_0x55e6ff(0x1c2)](_0x231f3b['messages'])&&_0x2ac9f5['push']('Messages\x20must\x20be\x20an\x20array');_0x231f3b['messages']&&_0x231f3b['messages'][_0x55e6ff(0x1b2)]((_0x566e65,_0x48d05b)=>{const _0x326d44=_0x55e6ff,_0x6f372d=this['validateMessage'](_0x566e65);_0x6f372d[_0x326d44(0x1ac)]['forEach'](_0x9b341c=>{_0x2ac9f5['push']('Message\x20'+_0x48d05b+':\x20'+_0x9b341c);}),_0x6f372d[_0x326d44(0x169)]['forEach'](_0x93169a=>{const _0x2a1c75=_0x326d44;_0x43beec[_0x2a1c75(0x167)]('Message\x20'+_0x48d05b+':\x20'+_0x93169a);});});_0x231f3b[_0x55e6ff(0x1ba)]!==undefined&&typeof _0x231f3b['messageCount']!=='number'&&_0x2ac9f5[_0x55e6ff(0x167)](_0x55e6ff(0x196));_0x231f3b[_0x55e6ff(0x15e)]!==undefined&&typeof _0x231f3b[_0x55e6ff(0x15e)]!=='number'&&_0x2ac9f5[_0x55e6ff(0x167)](_0x55e6ff(0x1c9));_0x231f3b['cost']!==undefined&&typeof _0x231f3b['cost']!=='number'&&_0x2ac9f5['push'](_0x55e6ff(0x162));_0x231f3b['participants']&&!Array['isArray'](_0x231f3b[_0x55e6ff(0x1a1)])&&_0x2ac9f5[_0x55e6ff(0x167)]('Participants\x20must\x20be\x20an\x20array');const _0x4797e1=[_0x55e6ff(0x156),'updatedAt','lastMessageAt'];return _0x4797e1['forEach'](_0x4f1b95=>{const _0x32c651=_0x55e6ff;_0x231f3b[_0x4f1b95]&&!this['isValidTimestamp'](_0x231f3b[_0x4f1b95])&&_0x2ac9f5['push'](_0x32c651(0x1d1)+_0x4f1b95+':\x20'+_0x231f3b[_0x4f1b95]);}),{'isValid':_0x2ac9f5['length']===0x0,'errors':_0x2ac9f5,'warnings':_0x43beec};}static['validateMessage'](_0x3ae52f){const _0x4efe9e=a0_0x558d39,_0x4dd494=[],_0x5de9bd=[];(!_0x3ae52f['id']||typeof _0x3ae52f['id']!==_0x4efe9e(0x168))&&_0x4dd494[_0x4efe9e(0x167)](_0x4efe9e(0x191));(!_0x3ae52f['conversationId']||typeof _0x3ae52f['conversationId']!=='string')&&_0x4dd494[_0x4efe9e(0x167)]('Conversation\x20ID\x20is\x20required\x20and\x20must\x20be\x20a\x20string');(!_0x3ae52f[_0x4efe9e(0x17a)]||typeof _0x3ae52f[_0x4efe9e(0x17a)]!=='string')&&_0x4dd494[_0x4efe9e(0x167)](_0x4efe9e(0x16e));_0x3ae52f[_0x4efe9e(0x17a)]&&!Object['values'](MESSAGE_ROLES)['includes'](_0x3ae52f[_0x4efe9e(0x17a)])&&_0x4dd494[_0x4efe9e(0x167)]('Invalid\x20message\x20role:\x20'+_0x3ae52f[_0x4efe9e(0x17a)]);(!_0x3ae52f['content']||typeof _0x3ae52f[_0x4efe9e(0x1bc)]!=='string')&&_0x4dd494[_0x4efe9e(0x167)]('Message\x20content\x20is\x20required\x20and\x20must\x20be\x20a\x20string');_0x3ae52f['content']&&_0x3ae52f[_0x4efe9e(0x1bc)]['length']>0x186a0&&_0x5de9bd['push'](_0x4efe9e(0x1c6));_0x3ae52f[_0x4efe9e(0x17a)]===MESSAGE_ROLES['ASSISTANT']&&!_0x3ae52f['agentId']&&_0x4dd494[_0x4efe9e(0x167)](_0x4efe9e(0x174));_0x3ae52f['role']===MESSAGE_ROLES[_0x4efe9e(0x181)]&&!_0x3ae52f['userId']&&_0x5de9bd['push'](_0x4efe9e(0x1c5));_0x3ae52f[_0x4efe9e(0x157)]&&!Array['isArray'](_0x3ae52f[_0x4efe9e(0x157)])&&_0x4dd494[_0x4efe9e(0x167)]('Context\x20references\x20must\x20be\x20an\x20array');_0x3ae52f[_0x4efe9e(0x164)]&&!Array['isArray'](_0x3ae52f['toolExecutions'])&&_0x4dd494[_0x4efe9e(0x167)]('Tool\x20executions\x20must\x20be\x20an\x20array');if(_0x3ae52f['tokenUsage']){const _0x4de443=this['validateTokenUsage'](_0x3ae52f[_0x4efe9e(0x18a)]);_0x4dd494[_0x4efe9e(0x167)](..._0x4de443['errors']),_0x5de9bd[_0x4efe9e(0x167)](..._0x4de443[_0x4efe9e(0x169)]);}return _0x3ae52f[_0x4efe9e(0x156)]&&!this['isValidTimestamp'](_0x3ae52f[_0x4efe9e(0x156)])&&_0x4dd494[_0x4efe9e(0x167)](_0x4efe9e(0x1b3)+_0x3ae52f['createdAt']),_0x3ae52f[_0x4efe9e(0x1cf)]&&!this['isValidTimestamp'](_0x3ae52f['editedAt'])&&_0x4dd494[_0x4efe9e(0x167)]('Invalid\x20editedAt\x20timestamp:\x20'+_0x3ae52f['editedAt']),{'errors':_0x4dd494,'warnings':_0x5de9bd};}static[a0_0x558d39(0x14f)](_0xc3b332){const _0x169e03=a0_0x558d39,_0x421c82=[],_0x2ca4e8=[];(typeof _0xc3b332[_0x169e03(0x18f)]!==_0x169e03(0x188)||_0xc3b332[_0x169e03(0x18f)]<0x0)&&_0x421c82['push']('Total\x20tokens\x20must\x20be\x20a\x20non-negative\x20number');_0xc3b332[_0x169e03(0x1bd)]!==undefined&&(typeof _0xc3b332[_0x169e03(0x1bd)]!==_0x169e03(0x188)||_0xc3b332['promptTokens']<0x0)&&_0x421c82['push'](_0x169e03(0x192));_0xc3b332[_0x169e03(0x150)]!==undefined&&(typeof _0xc3b332['completionTokens']!=='number'||_0xc3b332['completionTokens']<0x0)&&_0x421c82['push']('Completion\x20tokens\x20must\x20be\x20a\x20non-negative\x20number');_0xc3b332['cost']!==undefined&&(typeof _0xc3b332['cost']!==_0x169e03(0x188)||_0xc3b332[_0x169e03(0x195)]<0x0)&&_0x421c82['push']('Cost\x20must\x20be\x20a\x20non-negative\x20number');if(_0xc3b332['promptTokens']&&_0xc3b332[_0x169e03(0x150)]){const _0x461958=_0xc3b332['promptTokens']+_0xc3b332['completionTokens'];Math[_0x169e03(0x161)](_0x461958-_0xc3b332['totalTokens'])>0x1&&_0x2ca4e8[_0x169e03(0x167)]('Total\x20tokens\x20does\x20not\x20match\x20sum\x20of\x20prompt\x20and\x20completion\x20tokens');}return{'errors':_0x421c82,'warnings':_0x2ca4e8};}static[a0_0x558d39(0x1c8)](_0x27f11d){const _0x23132d=a0_0x558d39;if(typeof _0x27f11d!=='string')return![];const _0x46c550=new Date(_0x27f11d);return _0x46c550 instanceof Date&&!isNaN(_0x46c550[_0x23132d(0x1b0)]());}}export class ConversationFactory{static['create'](_0xe9bb16,_0x2b9c6d,_0x622552={}){const _0x6cc820=a0_0x558d39,_0x2d03e6=new Date()['toISOString'](),_0x3bfe2=this[_0x6cc820(0x1bb)]();return{'id':_0x3bfe2,'title':_0x2b9c6d||_0x6cc820(0x16d),'agentId':_0xe9bb16,'status':CONVERSATION_STATUS[_0x6cc820(0x18d)],'messages':[],'metadata':this['createDefaultMetadata'](_0x622552[_0x6cc820(0x1ce)]),'settings':this['createDefaultSettings'](_0x622552[_0x6cc820(0x1bf)]),'context':this[_0x6cc820(0x180)](),'createdAt':_0x2d03e6,'updatedAt':_0x2d03e6,'lastMessageAt':_0x2d03e6,'messageCount':0x0,'tokenCount':0x0,'cost':0x0,'participants':[_0xe9bb16,..._0x622552['participants']||[]],'summary':{}};}static['createMessage'](_0x53e62d,_0x4aae56,_0x4ce4e5,_0x9da3cc={}){const _0x548771=a0_0x558d39,_0x269c2c=new Date()[_0x548771(0x1a8)](),_0x1086a7=this[_0x548771(0x151)]();return{'id':_0x1086a7,'conversationId':_0x53e62d,'role':_0x4aae56,'content':_0x4ce4e5,'agentId':_0x9da3cc[_0x548771(0x152)]||null,'userId':_0x9da3cc['userId']||null,'metadata':_0x9da3cc[_0x548771(0x1ce)]||{},'contextReferences':_0x9da3cc[_0x548771(0x157)]||[],'toolExecutions':_0x9da3cc['toolExecutions']||[],'tokenUsage':_0x9da3cc[_0x548771(0x18a)]||null,'createdAt':_0x269c2c,'editedAt':null,'parentMessageId':_0x9da3cc['parentMessageId']||null,'isEdited':![],'flags':_0x9da3cc[_0x548771(0x1d0)]||{}};}static[a0_0x558d39(0x194)](_0x5967a8={}){const _0x5192a4=a0_0x558d39;return{'tags':[],'category':_0x5192a4(0x171),'description':'','isBookmarked':![],'priority':0x3,'language':'en','customFields':{},'relatedConversations':[],..._0x5967a8};}static[a0_0x558d39(0x197)](_0x524fd9={}){return{'persistHistory':!![],'maxMessages':0x3e8,'autoSummarize':!![],'summarizeThreshold':0x32,'enableContextReferences':!![],'maxContextReferences':0xa,'notificationSettings':{'newMessage':!![],'agentResponse':!![],'toolExecution':![]},'privacySettings':{'shareHistory':![],'allowAnalytics':!![]},..._0x524fd9};}static['createDefaultContext'](){return{'currentTopic':null,'mentionedEntities':[],'variables':{},'activeTools':[],'workingMemory':{},'preferences':{},'phase':'initial','goals':{}};}static[a0_0x558d39(0x1bb)](){const _0x160b33=Date['now']()['toString'](0x24),_0x2ddbbc=Math['random']()['toString'](0x24)['substr'](0x2,0x9);return'conv_'+_0x160b33+'_'+_0x2ddbbc;}static[a0_0x558d39(0x151)](){const _0x3ba655=a0_0x558d39,_0x49e086=Date['now']()['toString'](0x24),_0x4cc7ec=Math[_0x3ba655(0x17e)]()['toString'](0x24)['substr'](0x2,0x9);return _0x3ba655(0x172)+_0x49e086+'_'+_0x4cc7ec;}}export class ConversationUtils{static[a0_0x558d39(0x15d)](_0x5c2b07){const _0x25a3d2=a0_0x558d39,_0x5eaeef=_0x5c2b07['messages']||[],_0x3c6d80=_0x5eaeef[_0x25a3d2(0x1c7)](_0x20eede=>_0x20eede['role']===MESSAGE_ROLES['USER']),_0x462be8=_0x5eaeef[_0x25a3d2(0x1c7)](_0x3aa64a=>_0x3aa64a[_0x25a3d2(0x17a)]===MESSAGE_ROLES['ASSISTANT']),_0x48d8ab=_0x5eaeef['filter'](_0x220e2a=>_0x220e2a[_0x25a3d2(0x17a)]===MESSAGE_ROLES['SYSTEM']),_0x5b4401=_0x5eaeef[_0x25a3d2(0x184)]((_0x2092be,_0xf516ea)=>_0x2092be+(_0xf516ea['tokenUsage']?.['totalTokens']||0x0),0x0),_0x149b67=_0x5eaeef['reduce']((_0x29c1a3,_0x493cb9)=>_0x29c1a3+(_0x493cb9['tokenUsage']?.['cost']||0x0),0x0),_0x7168d2=_0x5eaeef[_0x25a3d2(0x184)]((_0x2bcb71,_0x22b4e7)=>_0x2bcb71+(_0x22b4e7[_0x25a3d2(0x164)]?.[_0x25a3d2(0x19e)]||0x0),0x0),_0x3b5458=_0x5eaeef['reduce']((_0x14a93b,_0x52041f)=>_0x14a93b+(_0x52041f['contextReferences']?.['length']||0x0),0x0);return{'totalMessages':_0x5eaeef[_0x25a3d2(0x19e)],'userMessages':_0x3c6d80[_0x25a3d2(0x19e)],'assistantMessages':_0x462be8[_0x25a3d2(0x19e)],'systemMessages':_0x48d8ab['length'],'totalTokens':_0x5b4401,'totalCost':_0x149b67,'toolExecutions':_0x7168d2,'contextReferences':_0x3b5458,'averageMessageLength':_0x5eaeef['length']>0x0?_0x5eaeef[_0x25a3d2(0x184)]((_0x3076e8,_0x19b343)=>_0x3076e8+_0x19b343[_0x25a3d2(0x1bc)][_0x25a3d2(0x19e)],0x0)/_0x5eaeef['length']:0x0,'conversationDuration':this[_0x25a3d2(0x166)](_0x5c2b07)};}static[a0_0x558d39(0x166)](_0x2fde80){const _0x26e7a0=a0_0x558d39;if(!_0x2fde80[_0x26e7a0(0x187)]||_0x2fde80['messages']['length']===0x0)return 0x0;const _0x4ddccd=_0x2fde80['messages'][0x0],_0x47c29a=_0x2fde80['messages'][_0x2fde80['messages'][_0x26e7a0(0x19e)]-0x1],_0x2021d4=new Date(_0x4ddccd[_0x26e7a0(0x156)]),_0x5af711=new Date(_0x47c29a[_0x26e7a0(0x156)]);return _0x5af711['getTime']()-_0x2021d4['getTime']();}static['generateSummary'](_0x45d759){const _0x243dc4=a0_0x558d39,_0xff8e85=this['getStatistics'](_0x45d759),_0x25cddd=_0x45d759['messages']||[],_0x1cba96=this[_0x243dc4(0x185)](_0x25cddd),_0x514182=this['extractEntities'](_0x25cddd),_0x1ff68b=_0x25cddd[_0x243dc4(0x18c)](-0xa),_0x84b789=_0x45d759[_0x243dc4(0x190)]||_0x45d759['updatedAt'];return{'title':_0x45d759[_0x243dc4(0x16f)],'messageCount':_0xff8e85[_0x243dc4(0x178)],'duration':_0xff8e85[_0x243dc4(0x15b)],'participants':_0x45d759[_0x243dc4(0x1a1)][_0x243dc4(0x19e)],'topics':_0x1cba96[_0x243dc4(0x18c)](0x0,0x5),'entities':_0x514182['slice'](0x0,0xa),'lastActivity':_0x84b789,'recentActivity':_0x1ff68b[_0x243dc4(0x19f)](_0x16d74c=>({'role':_0x16d74c[_0x243dc4(0x17a)],'timestamp':_0x16d74c[_0x243dc4(0x156)],'preview':_0x16d74c['content']['substring'](0x0,0x64)+(_0x16d74c[_0x243dc4(0x1bc)]['length']>0x64?'...':'')})),'stats':_0xff8e85};}static['extractTopics'](_0xfa3766){const _0x23e2cc=a0_0x558d39,_0x2fc53e=new Map();return _0xfa3766['forEach'](_0x5af39f=>{const _0x41b3a1=a0_0x53e6,_0x1a42fc=_0x5af39f[_0x41b3a1(0x1bc)]['toLowerCase']()['split'](/\s+/)[_0x41b3a1(0x1c7)](_0x1a6e45=>_0x1a6e45['length']>0x3&&!this['isStopWord'](_0x1a6e45));_0x1a42fc[_0x41b3a1(0x1b2)](_0x26c355=>{const _0x1f92d4=_0x41b3a1;_0x2fc53e[_0x1f92d4(0x19a)](_0x26c355,(_0x2fc53e[_0x1f92d4(0x1ae)](_0x26c355)||0x0)+0x1);});}),Array['from'](_0x2fc53e[_0x23e2cc(0x175)]())[_0x23e2cc(0x159)]((_0x1357b9,_0x7be07a)=>_0x7be07a[0x1]-_0x1357b9[0x1])[_0x23e2cc(0x19f)](([_0x1edbdd])=>_0x1edbdd);}static[a0_0x558d39(0x15a)](_0x415fb4){const _0x7888b6=a0_0x558d39,_0x5d37ea=new Set();return _0x415fb4['forEach'](_0x29f13d=>{const _0x2ae2ad=a0_0x53e6,_0x45982e=_0x29f13d[_0x2ae2ad(0x1bc)]['match'](/\b[A-Z][a-z]+\b/g)||[];_0x45982e['forEach'](_0x1aed0a=>_0x5d37ea['add'](_0x1aed0a));const _0x427623=_0x29f13d['content'][_0x2ae2ad(0x170)](/\b[\w\/\-\.]+\.\w+\b/g)||[];_0x427623['forEach'](_0x401f45=>_0x5d37ea['add'](_0x401f45));}),Array[_0x7888b6(0x1a2)](_0x5d37ea);}static[a0_0x558d39(0x1b9)](_0x273f85){const _0x144f24=a0_0x558d39,_0x13397a=new Set([_0x144f24(0x19b),'and','or',_0x144f24(0x189),'in','on','at','to','for','of','with','by','from','up',_0x144f24(0x1a0),'into','through','during',_0x144f24(0x179),'after','above','below',_0x144f24(0x1c0),_0x144f24(0x154),'again',_0x144f24(0x17f),'then','once',_0x144f24(0x1cc),_0x144f24(0x1b5),'when','where','why',_0x144f24(0x1ad),_0x144f24(0x160),'any',_0x144f24(0x182),_0x144f24(0x1b7),'few','more','most',_0x144f24(0x15c),'some','such',_0x144f24(0x155),_0x144f24(0x17c),'same','so',_0x144f24(0x1a7),_0x144f24(0x15f),_0x144f24(0x1a6),_0x144f24(0x1c4),_0x144f24(0x1a4),_0x144f24(0x19c),_0x144f24(0x1b1),'now']);return _0x13397a['has'](_0x273f85[_0x144f24(0x1ca)]());}static[a0_0x558d39(0x14e)](_0x47e9b3,_0x3a6a04=a0_0x558d39(0x198)){const _0x2e9333=a0_0x558d39;switch(_0x3a6a04){case _0x2e9333(0x17b):return this['formatAsMarkdown'](_0x47e9b3);case _0x2e9333(0x1c3):return this[_0x2e9333(0x19d)](_0x47e9b3);case _0x2e9333(0x198):default:return JSON[_0x2e9333(0x18e)](_0x47e9b3,null,0x2);}}static[a0_0x558d39(0x1b4)](_0x5977ec){const _0x2c2a6f=a0_0x558d39;let _0x13f725='#\x20'+_0x5977ec[_0x2c2a6f(0x16f)]+'\x0a\x0a';return _0x13f725+=_0x2c2a6f(0x1a3)+new Date(_0x5977ec['createdAt'])['toLocaleString']()+'\x0a',_0x13f725+=_0x2c2a6f(0x16b)+_0x5977ec['agentId']+'\x0a',_0x13f725+=_0x2c2a6f(0x176)+_0x5977ec['messageCount']+'\x0a\x0a',_0x5977ec[_0x2c2a6f(0x187)][_0x2c2a6f(0x1b2)](_0x13a0cf=>{const _0x79ba26=_0x2c2a6f,_0xf7d663=new Date(_0x13a0cf['createdAt'])['toLocaleTimeString'](),_0x49cb1d=_0x13a0cf['role'][_0x79ba26(0x18b)](0x0)[_0x79ba26(0x1a5)]()+_0x13a0cf['role']['slice'](0x1);_0x13f725+=_0x79ba26(0x1c1)+_0x49cb1d+'\x20('+_0xf7d663+')\x0a\x0a',_0x13f725+=_0x13a0cf['content']+'\x0a\x0a',_0x13a0cf['contextReferences']&&_0x13a0cf['contextReferences'][_0x79ba26(0x19e)]>0x0&&(_0x13f725+='**Context\x20References:**\x0a',_0x13a0cf[_0x79ba26(0x157)]['forEach'](_0x191049=>{_0x13f725+='-\x20'+_0x191049['name']+'\x20('+_0x191049['type']+')\x0a';}),_0x13f725+='\x0a');}),_0x13f725;}static[a0_0x558d39(0x19d)](_0x4c452b){const _0xd433e4=a0_0x558d39;let _0x29d8ef=_0xd433e4(0x1af)+_0x4c452b['title']+'\x0a';return _0x29d8ef+='Created:\x20'+new Date(_0x4c452b[_0xd433e4(0x156)])[_0xd433e4(0x177)]()+'\x0a',_0x29d8ef+=_0xd433e4(0x1b8)+_0x4c452b['agentId']+'\x0a',_0x29d8ef+=_0xd433e4(0x153)+_0x4c452b['messageCount']+'\x0a\x0a',_0x29d8ef+='-'['repeat'](0x32)+'\x0a\x0a',_0x4c452b['messages']['forEach'](_0xbe1ebe=>{const _0x3b690a=_0xd433e4,_0x5a8e91=new Date(_0xbe1ebe['createdAt'])[_0x3b690a(0x1aa)](),_0x4496d3=_0xbe1ebe[_0x3b690a(0x17a)][_0x3b690a(0x1a5)]();_0x29d8ef+='['+_0x5a8e91+']\x20'+_0x4496d3+':\x0a',_0x29d8ef+=_0xbe1ebe['content']+'\x0a\x0a';}),_0x29d8ef;}}export default{'ConversationValidator':ConversationValidator,'ConversationFactory':ConversationFactory,'ConversationUtils':ConversationUtils};
|