@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +44 -54
  2. package/bin/cli.js +1 -115
  3. package/bin/loxia-terminal-v2.js +3 -0
  4. package/bin/loxia-terminal.js +3 -0
  5. package/bin/start-with-terminal.js +3 -0
  6. package/package.json +14 -15
  7. package/scripts/install-scanners.js +1 -235
  8. package/src/analyzers/CSSAnalyzer.js +1 -297
  9. package/src/analyzers/ConfigValidator.js +1 -690
  10. package/src/analyzers/ESLintAnalyzer.js +1 -320
  11. package/src/analyzers/JavaScriptAnalyzer.js +1 -261
  12. package/src/analyzers/PrettierFormatter.js +1 -247
  13. package/src/analyzers/PythonAnalyzer.js +1 -266
  14. package/src/analyzers/SecurityAnalyzer.js +1 -729
  15. package/src/analyzers/TypeScriptAnalyzer.js +1 -247
  16. package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
  17. package/src/analyzers/codeCloneDetector/detector.js +1 -203
  18. package/src/analyzers/codeCloneDetector/index.js +1 -160
  19. package/src/analyzers/codeCloneDetector/parser.js +1 -199
  20. package/src/analyzers/codeCloneDetector/reporter.js +1 -148
  21. package/src/analyzers/codeCloneDetector/scanner.js +1 -59
  22. package/src/core/agentPool.js +1 -1474
  23. package/src/core/agentScheduler.js +1 -2147
  24. package/src/core/contextManager.js +1 -709
  25. package/src/core/messageProcessor.js +1 -732
  26. package/src/core/orchestrator.js +1 -548
  27. package/src/core/stateManager.js +1 -877
  28. package/src/index.js +1 -631
  29. package/src/interfaces/cli.js +1 -549
  30. package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
  31. package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
  32. package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
  33. package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
  34. package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
  35. package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
  36. package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
  37. package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
  38. package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
  39. package/src/interfaces/terminal/api/apiClient.js +1 -0
  40. package/src/interfaces/terminal/api/messageRouter.js +1 -0
  41. package/src/interfaces/terminal/api/session.js +1 -0
  42. package/src/interfaces/terminal/api/websocket.js +1 -0
  43. package/src/interfaces/terminal/components/AgentCreator.js +1 -0
  44. package/src/interfaces/terminal/components/AgentEditor.js +1 -0
  45. package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
  46. package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
  47. package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
  48. package/src/interfaces/terminal/components/Header.js +1 -0
  49. package/src/interfaces/terminal/components/HelpPanel.js +1 -0
  50. package/src/interfaces/terminal/components/InputBox.js +1 -0
  51. package/src/interfaces/terminal/components/Layout.js +1 -0
  52. package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
  53. package/src/interfaces/terminal/components/MessageList.js +1 -0
  54. package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
  55. package/src/interfaces/terminal/components/SearchPanel.js +1 -0
  56. package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
  57. package/src/interfaces/terminal/components/StatusBar.js +1 -0
  58. package/src/interfaces/terminal/components/TextInput.js +1 -0
  59. package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
  60. package/src/interfaces/terminal/config/constants.js +1 -0
  61. package/src/interfaces/terminal/index.js +1 -0
  62. package/src/interfaces/terminal/state/useAgentControl.js +1 -0
  63. package/src/interfaces/terminal/state/useAgents.js +1 -0
  64. package/src/interfaces/terminal/state/useConnection.js +1 -0
  65. package/src/interfaces/terminal/state/useMessages.js +1 -0
  66. package/src/interfaces/terminal/state/useTools.js +1 -0
  67. package/src/interfaces/terminal/utils/debugLogger.js +1 -0
  68. package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
  69. package/src/interfaces/terminal/utils/theme.js +1 -0
  70. package/src/interfaces/webServer.js +1 -2162
  71. package/src/modules/fileExplorer/controller.js +1 -280
  72. package/src/modules/fileExplorer/index.js +1 -37
  73. package/src/modules/fileExplorer/middleware.js +1 -92
  74. package/src/modules/fileExplorer/routes.js +1 -125
  75. package/src/modules/fileExplorer/types.js +1 -44
  76. package/src/services/aiService.js +1 -1232
  77. package/src/services/apiKeyManager.js +1 -164
  78. package/src/services/benchmarkService.js +1 -366
  79. package/src/services/budgetService.js +1 -539
  80. package/src/services/contextInjectionService.js +1 -247
  81. package/src/services/conversationCompactionService.js +1 -637
  82. package/src/services/errorHandler.js +1 -810
  83. package/src/services/fileAttachmentService.js +1 -544
  84. package/src/services/modelRouterService.js +1 -366
  85. package/src/services/modelsService.js +1 -322
  86. package/src/services/qualityInspector.js +1 -796
  87. package/src/services/tokenCountingService.js +1 -536
  88. package/src/tools/agentCommunicationTool.js +1 -1344
  89. package/src/tools/agentDelayTool.js +1 -485
  90. package/src/tools/asyncToolManager.js +1 -604
  91. package/src/tools/baseTool.js +1 -800
  92. package/src/tools/browserTool.js +1 -920
  93. package/src/tools/cloneDetectionTool.js +1 -621
  94. package/src/tools/dependencyResolverTool.js +1 -1215
  95. package/src/tools/fileContentReplaceTool.js +1 -875
  96. package/src/tools/fileSystemTool.js +1 -1107
  97. package/src/tools/fileTreeTool.js +1 -853
  98. package/src/tools/imageTool.js +1 -901
  99. package/src/tools/importAnalyzerTool.js +1 -1060
  100. package/src/tools/jobDoneTool.js +1 -248
  101. package/src/tools/seekTool.js +1 -956
  102. package/src/tools/staticAnalysisTool.js +1 -1778
  103. package/src/tools/taskManagerTool.js +1 -2873
  104. package/src/tools/terminalTool.js +1 -2304
  105. package/src/tools/webTool.js +1 -1430
  106. package/src/types/agent.js +1 -519
  107. package/src/types/contextReference.js +1 -972
  108. package/src/types/conversation.js +1 -730
  109. package/src/types/toolCommand.js +1 -747
  110. package/src/utilities/attachmentValidator.js +1 -292
  111. package/src/utilities/configManager.js +1 -582
  112. package/src/utilities/constants.js +1 -722
  113. package/src/utilities/directoryAccessManager.js +1 -535
  114. package/src/utilities/fileProcessor.js +1 -307
  115. package/src/utilities/logger.js +1 -436
  116. package/src/utilities/tagParser.js +1 -1246
  117. package/src/utilities/toolConstants.js +1 -317
  118. package/web-ui/build/index.html +2 -2
  119. package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
  120. package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
@@ -1,247 +1 @@
1
- /**
2
- * Context Injection Service
3
- * Builds dynamic context sections from active file attachments
4
- */
5
-
6
- import FileAttachmentService from './fileAttachmentService.js';
7
-
8
- class ContextInjectionService {
9
- constructor(config = {}, logger = null) {
10
- this.config = config;
11
- this.logger = logger;
12
- this.attachmentService = new FileAttachmentService(config, logger);
13
- }
14
-
15
- /**
16
- * Initialize service
17
- * @returns {Promise<void>}
18
- */
19
- async initialize() {
20
- await this.attachmentService.initialize();
21
- }
22
-
23
- /**
24
- * Build dynamic context for an agent
25
- * @param {string} agentId - Agent ID
26
- * @returns {Promise<string>} Dynamic context section
27
- */
28
- async buildDynamicContext(agentId) {
29
- try {
30
- const activeAttachments = await this.attachmentService.getActiveAttachments(agentId);
31
-
32
- if (activeAttachments.length === 0) {
33
- return ''; // No context to inject
34
- }
35
-
36
- // Separate content and reference mode attachments
37
- const contentFiles = activeAttachments.filter(a => a.mode === 'content');
38
- const referenceFiles = activeAttachments.filter(a => a.mode === 'reference');
39
-
40
- let contextSection = '';
41
-
42
- // Build content files section
43
- if (contentFiles.length > 0) {
44
- contextSection += '\n<attached-files>\n';
45
-
46
- for (const attachment of contentFiles) {
47
- const content = await this.attachmentService.getAttachmentContent(attachment.fileId);
48
- if (content) {
49
- const formattedContent = this.formatContentFile(attachment, content);
50
- contextSection += formattedContent + '\n';
51
- }
52
- }
53
-
54
- contextSection += '</attached-files>\n';
55
- }
56
-
57
- // Build reference files section
58
- if (referenceFiles.length > 0) {
59
- contextSection += '\n<file-references>\n';
60
-
61
- for (const attachment of referenceFiles) {
62
- const formattedRef = this.formatReferenceFile(attachment);
63
- contextSection += formattedRef + '\n';
64
- }
65
-
66
- contextSection += '</file-references>\n';
67
- contextSection += '\nNote: Referenced files can be accessed using the filesystem tool if needed.\n';
68
- }
69
-
70
- return contextSection;
71
- } catch (error) {
72
- this.logger?.error('Error building dynamic context', { agentId, error: error.message });
73
- return ''; // Return empty on error to avoid breaking the conversation
74
- }
75
- }
76
-
77
- /**
78
- * Format content mode file
79
- * @param {Object} attachment - Attachment metadata
80
- * @param {string} content - File content
81
- * @returns {string} Formatted XML
82
- */
83
- formatContentFile(attachment, content) {
84
- const { fileName, fileType, size, contentType } = attachment;
85
- const sizeKB = (size / 1024).toFixed(2);
86
-
87
- // Format based on content type
88
- if (contentType === 'text') {
89
- return this.formatTextFile(attachment, content);
90
- } else if (contentType === 'image') {
91
- return this.formatImageFile(attachment, content);
92
- } else if (contentType === 'pdf') {
93
- return this.formatPdfFile(attachment, content);
94
- }
95
-
96
- // Fallback
97
- return ` <file name="${this.escapeXml(fileName)}" type="${fileType}" size="${sizeKB}KB" mode="content">\n${this.escapeXml(content)}\n </file>`;
98
- }
99
-
100
- /**
101
- * Format text file
102
- * @param {Object} attachment - Attachment metadata
103
- * @param {string} content - File content
104
- * @returns {string} Formatted XML
105
- */
106
- formatTextFile(attachment, content) {
107
- const { fileName, fileType, size } = attachment;
108
- const sizeKB = (size / 1024).toFixed(2);
109
-
110
- return ` <file name="${this.escapeXml(fileName)}" type="${fileType}" size="${sizeKB}KB" mode="content">\n${this.escapeXml(content)}\n </file>`;
111
- }
112
-
113
- /**
114
- * Format image file
115
- * @param {Object} attachment - Attachment metadata
116
- * @param {string} base64Content - Base64 data URI
117
- * @returns {string} Formatted XML
118
- */
119
- formatImageFile(attachment, base64Content) {
120
- const { fileName, fileType, size } = attachment;
121
- const sizeKB = (size / 1024).toFixed(2);
122
-
123
- return ` <file name="${this.escapeXml(fileName)}" type="${fileType}" size="${sizeKB}KB" mode="content">\n${base64Content}\n </file>`;
124
- }
125
-
126
- /**
127
- * Format PDF file
128
- * @param {Object} attachment - Attachment metadata
129
- * @param {string} extractedText - Extracted text from PDF
130
- * @returns {string} Formatted XML
131
- */
132
- formatPdfFile(attachment, extractedText) {
133
- const { fileName, fileType, size } = attachment;
134
- const sizeKB = (size / 1024).toFixed(2);
135
-
136
- return ` <file name="${this.escapeXml(fileName)}" type="${fileType}" size="${sizeKB}KB" mode="content">\n${this.escapeXml(extractedText)}\n </file>`;
137
- }
138
-
139
- /**
140
- * Format reference mode file
141
- * @param {Object} attachment - Attachment metadata
142
- * @returns {string} Formatted XML
143
- */
144
- formatReferenceFile(attachment) {
145
- const { fileName, originalPath, size, fileType, lastModified } = attachment;
146
- const sizeFormatted = this.formatBytes(size);
147
- const modifiedDate = new Date(lastModified).toISOString().split('T')[0];
148
-
149
- return ` <file name="${this.escapeXml(fileName)}" path="${this.escapeXml(originalPath)}" size="${sizeFormatted}" type="${fileType}" modified="${modifiedDate}" />`;
150
- }
151
-
152
- /**
153
- * Escape XML special characters
154
- * @param {string} text - Text to escape
155
- * @returns {string} Escaped text
156
- */
157
- escapeXml(text) {
158
- if (!text) return '';
159
- return text
160
- .replace(/&/g, '&amp;')
161
- .replace(/</g, '&lt;')
162
- .replace(/>/g, '&gt;')
163
- .replace(/"/g, '&quot;')
164
- .replace(/'/g, '&apos;');
165
- }
166
-
167
- /**
168
- * Format bytes to human-readable string
169
- * @param {number} bytes
170
- * @returns {string}
171
- */
172
- formatBytes(bytes) {
173
- if (bytes === 0) return '0 Bytes';
174
- const k = 1024;
175
- const sizes = ['Bytes', 'KB', 'MB', 'GB'];
176
- const i = Math.floor(Math.log(bytes) / Math.log(k));
177
- return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + sizes[i];
178
- }
179
-
180
- /**
181
- * Estimate total tokens for active attachments
182
- * @param {string} agentId - Agent ID
183
- * @returns {Promise<number>} Total estimated tokens
184
- */
185
- async estimateTotalTokens(agentId) {
186
- try {
187
- const activeAttachments = await this.attachmentService.getActiveAttachments(agentId);
188
- let total = 0;
189
-
190
- for (const attachment of activeAttachments) {
191
- if (attachment.mode === 'content') {
192
- total += attachment.tokenEstimate || 0;
193
- } else {
194
- // Reference mode: estimate XML tag overhead
195
- total += 20; // Approximate tokens for XML tag
196
- }
197
- }
198
-
199
- return total;
200
- } catch (error) {
201
- this.logger?.error('Error estimating total tokens', { agentId, error: error.message });
202
- return 0;
203
- }
204
- }
205
-
206
- /**
207
- * Get summary of active attachments
208
- * @param {string} agentId - Agent ID
209
- * @returns {Promise<Object>} Summary object
210
- */
211
- async getAttachmentSummary(agentId) {
212
- try {
213
- const activeAttachments = await this.attachmentService.getActiveAttachments(agentId);
214
-
215
- const summary = {
216
- totalActive: activeAttachments.length,
217
- contentMode: activeAttachments.filter(a => a.mode === 'content').length,
218
- referenceMode: activeAttachments.filter(a => a.mode === 'reference').length,
219
- estimatedTokens: 0,
220
- files: []
221
- };
222
-
223
- for (const attachment of activeAttachments) {
224
- summary.estimatedTokens += attachment.tokenEstimate || 0;
225
- summary.files.push({
226
- fileName: attachment.fileName,
227
- mode: attachment.mode,
228
- size: this.formatBytes(attachment.size),
229
- tokens: attachment.tokenEstimate || 0
230
- });
231
- }
232
-
233
- return summary;
234
- } catch (error) {
235
- this.logger?.error('Error getting attachment summary', { agentId, error: error.message });
236
- return {
237
- totalActive: 0,
238
- contentMode: 0,
239
- referenceMode: 0,
240
- estimatedTokens: 0,
241
- files: []
242
- };
243
- }
244
- }
245
- }
246
-
247
- export default ContextInjectionService;
1
+ function a0_0x1ee2(_0x681f59,_0xd92735){_0x681f59=_0x681f59-0xde;const _0x2836d5=a0_0x2836();let _0x1ee2ea=_0x2836d5[_0x681f59];if(a0_0x1ee2['UqPcMq']===undefined){var _0x1dc8f8=function(_0x5bd17f){const _0x2d8509='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x107faf='',_0x2b68cb='';for(let _0x5cab88=0x0,_0x550ad6,_0x3068fb,_0x3585b7=0x0;_0x3068fb=_0x5bd17f['charAt'](_0x3585b7++);~_0x3068fb&&(_0x550ad6=_0x5cab88%0x4?_0x550ad6*0x40+_0x3068fb:_0x3068fb,_0x5cab88++%0x4)?_0x107faf+=String['fromCharCode'](0xff&_0x550ad6>>(-0x2*_0x5cab88&0x6)):0x0){_0x3068fb=_0x2d8509['indexOf'](_0x3068fb);}for(let _0x3d469a=0x0,_0x3be1a8=_0x107faf['length'];_0x3d469a<_0x3be1a8;_0x3d469a++){_0x2b68cb+='%'+('00'+_0x107faf['charCodeAt'](_0x3d469a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2b68cb);};a0_0x1ee2['ErkEiO']=_0x1dc8f8,a0_0x1ee2['nhEhcx']={},a0_0x1ee2['UqPcMq']=!![];}const _0xf3944e=_0x2836d5[0x0],_0x336ecf=_0x681f59+_0xf3944e,_0x24f813=a0_0x1ee2['nhEhcx'][_0x336ecf];return!_0x24f813?(_0x1ee2ea=a0_0x1ee2['ErkEiO'](_0x1ee2ea),a0_0x1ee2['nhEhcx'][_0x336ecf]=_0x1ee2ea):_0x1ee2ea=_0x24f813,_0x1ee2ea;}const a0_0x119fb1=a0_0x1ee2;(function(_0x2e4d36,_0x2ca494){const _0x349c70=a0_0x1ee2,_0xadea37=_0x2e4d36();while(!![]){try{const _0x38bf67=parseInt(_0x349c70(0xe3))/0x1*(parseInt(_0x349c70(0x10e))/0x2)+-parseInt(_0x349c70(0x103))/0x3+-parseInt(_0x349c70(0xe1))/0x4*(parseInt(_0x349c70(0xef))/0x5)+parseInt(_0x349c70(0x10f))/0x6+-parseInt(_0x349c70(0xf4))/0x7*(parseInt(_0x349c70(0xfa))/0x8)+parseInt(_0x349c70(0xff))/0x9*(-parseInt(_0x349c70(0xe2))/0xa)+-parseInt(_0x349c70(0xf3))/0xb*(-parseInt(_0x349c70(0xe9))/0xc);if(_0x38bf67===_0x2ca494)break;else _0xadea37['push'](_0xadea37['shift']());}catch(_0x310b14){_0xadea37['push'](_0xadea37['shift']());}}}(a0_0x2836,0xef04b));import a0_0x107faf from'./fileAttachmentService.js';function a0_0x2836(){const _0x19be58=['Dg9gAxHLza','zM9YBwf0ugrMrMLSzq','jMX0oW','zM9YBwf0uMvMzxjLBMnLrMLSzq','Aw5PDgLHBgL6zq','jMfWB3m7','CMvMzxjLBMnL','iIbTB2rPzMLLzd0I','rxjYB3iGz2v0DgLUzYbHDhrHy2HTzw50ihn1Bw1HCNK','mLDbA1zrCq','nJeXntiWnLzgEKTctG','Dg9ju09tDhjPBMC','C3bSAxq','ica8zMLSzsbUyw1Lpsi','Bw9Kzq','jMD0oW','cJXMAwXLlxjLzMvYzw5Jzxm+cG','cIaGpc9MAwXLpG','Bg9Nz2vY','zxnJyxbLwg1S','ntG1mMjPu2vkEq','mJyZmdeWBMPkBvPi','mJC1nJeXvMjfB0DU','Dgv4Da','cJXHDhrHy2HLzc1MAwXLCZ4k','C2L6zq','iIbZAxPLpsi','Cg93','nZiXnJq4ntz4EMLbyNu','zMLSzuLK','CMvWBgfJzq','yxr0ywnOBwvUDfnLCNzPy2u','BwvZC2fNzq','z2v0qwn0AxzLqxr0ywnOBwvUDhm','ntK2nxzYCuvJza','iIaVpG','zMLSzu5HBwu','CgrM','mtfQueTYtwK','nZKZotC1qxr5rLP3','pc9MAwXLlxjLzMvYzw5Jzxm+cG','zM9YBwf0vgv4DezPBgu','BgvUz3rO','zMLSDgvY','Dg9Rzw5fC3rPBwf0zq','mteYuM9MDe1S','qNL0zxm','zM9YBwf0sw1Hz2vgAwXL','zMXVB3i','iIbWyxrOpsi','ndiZDKrnBLnq','s0iIig1Vzgu9iMnVBNrLBNqIpGO','zM9YBwf0qNL0zxm','iIb0ExbLpsi','nti4mdiYnuLSzhjeAG','zxjYB3i'];a0_0x2836=function(){return _0x19be58;};return a0_0x2836();}class ContextInjectionService{constructor(_0x2b68cb={},_0x5cab88=null){const _0x49b542=a0_0x1ee2;this['config']=_0x2b68cb,this['logger']=_0x5cab88,this[_0x49b542(0xec)]=new a0_0x107faf(_0x2b68cb,_0x5cab88);}async[a0_0x119fb1(0x109)](){await this['attachmentService']['initialize']();}async['buildDynamicContext'](_0x550ad6){const _0x117fce=a0_0x119fb1;try{const _0x3068fb=await this['attachmentService']['getActiveAttachments'](_0x550ad6);if(_0x3068fb[_0x117fce(0xf7)]===0x0)return'';const _0x3585b7=_0x3068fb['filter'](_0x366543=>_0x366543[_0x117fce(0x113)]==='content'),_0x3d469a=_0x3068fb['filter'](_0x5d6b16=>_0x5d6b16['mode']===_0x117fce(0x10b));let _0x3be1a8='';if(_0x3585b7['length']>0x0){_0x3be1a8+=_0x117fce(0xe5);for(const _0x512c0d of _0x3585b7){const _0x1e5a5d=await this[_0x117fce(0xec)]['getAttachmentContent'](_0x512c0d[_0x117fce(0xea)]);if(_0x1e5a5d){const _0x38bcfc=this['formatContentFile'](_0x512c0d,_0x1e5a5d);_0x3be1a8+=_0x38bcfc+'\x0a';}}_0x3be1a8+='</attached-files>\x0a';}if(_0x3d469a['length']>0x0){_0x3be1a8+=_0x117fce(0x115);for(const _0x13a160 of _0x3d469a){const _0x21fc58=this[_0x117fce(0x108)](_0x13a160);_0x3be1a8+=_0x21fc58+'\x0a';}_0x3be1a8+=_0x117fce(0xf5),_0x3be1a8+='\x0aNote:\x20Referenced\x20files\x20can\x20be\x20accessed\x20using\x20the\x20filesystem\x20tool\x20if\x20needed.\x0a';}return _0x3be1a8;}catch(_0x1245b6){return this[_0x117fce(0xdf)]?.['error']('Error\x20building\x20dynamic\x20context',{'agentId':_0x550ad6,'error':_0x1245b6['message']}),'';}}['formatContentFile'](_0x5b34e9,_0xe01fc4){const _0x537daf=a0_0x119fb1,{fileName:_0x1ab11b,fileType:_0x2a1a0f,size:_0x91fe2d,contentType:_0x3d6c32}=_0x5b34e9,_0xddedfc=(_0x91fe2d/0x400)[_0x537daf(0x105)](0x2);if(_0x3d6c32===_0x537daf(0xe4))return this[_0x537daf(0xf6)](_0x5b34e9,_0xe01fc4);else{if(_0x3d6c32==='image')return this[_0x537daf(0xfc)](_0x5b34e9,_0xe01fc4);else{if(_0x3d6c32===_0x537daf(0xf2))return this[_0x537daf(0x106)](_0x5b34e9,_0xe01fc4);}}return _0x537daf(0x112)+this[_0x537daf(0xe0)](_0x1ab11b)+_0x537daf(0x102)+_0x2a1a0f+'\x22\x20size=\x22'+_0xddedfc+'KB\x22\x20mode=\x22content\x22>\x0a'+this['escapeXml'](_0xe01fc4)+_0x537daf(0xde);}['formatTextFile'](_0x5e2207,_0x31ef9b){const _0x41364a=a0_0x119fb1,{fileName:_0x30373f,fileType:_0x506293,size:_0x1b87f3}=_0x5e2207,_0x5f594b=(_0x1b87f3/0x400)[_0x41364a(0x105)](0x2);return _0x41364a(0x112)+this[_0x41364a(0xe0)](_0x30373f)+_0x41364a(0x102)+_0x506293+_0x41364a(0xe7)+_0x5f594b+'KB\x22\x20mode=\x22content\x22>\x0a'+this['escapeXml'](_0x31ef9b)+'\x0a\x20\x20</file>';}['formatImageFile'](_0x2e2a77,_0x1b7baa){const _0x2c78ab=a0_0x119fb1,{fileName:_0x5c9b8f,fileType:_0x4839b0,size:_0x32bc61}=_0x2e2a77,_0x2f0889=(_0x32bc61/0x400)['toFixed'](0x2);return'\x20\x20<file\x20name=\x22'+this['escapeXml'](_0x5c9b8f)+'\x22\x20type=\x22'+_0x4839b0+'\x22\x20size=\x22'+_0x2f0889+_0x2c78ab(0x100)+_0x1b7baa+'\x0a\x20\x20</file>';}['formatPdfFile'](_0xef0200,_0x997abc){const _0x5093ee=a0_0x119fb1,{fileName:_0x2cbbe7,fileType:_0x2dfa24,size:_0x27aece}=_0xef0200,_0x512204=(_0x27aece/0x400)[_0x5093ee(0x105)](0x2);return'\x20\x20<file\x20name=\x22'+this[_0x5093ee(0xe0)](_0x2cbbe7)+_0x5093ee(0x102)+_0x2dfa24+'\x22\x20size=\x22'+_0x512204+_0x5093ee(0x100)+this[_0x5093ee(0xe0)](_0x997abc)+_0x5093ee(0xde);}['formatReferenceFile'](_0x5b9372){const _0x13be4b=a0_0x119fb1,{fileName:_0x46637a,originalPath:_0x423dc6,size:_0x318b74,fileType:_0xc89e92,lastModified:_0x8f3904}=_0x5b9372,_0x178b40=this[_0x13be4b(0x101)](_0x318b74),_0x173642=new Date(_0x8f3904)[_0x13be4b(0x110)]()[_0x13be4b(0x111)]('T')[0x0];return'\x20\x20<file\x20name=\x22'+this[_0x13be4b(0xe0)](_0x46637a)+_0x13be4b(0xfe)+this['escapeXml'](_0x423dc6)+_0x13be4b(0xe7)+_0x178b40+'\x22\x20type=\x22'+_0xc89e92+_0x13be4b(0x10c)+_0x173642+_0x13be4b(0xf0);}['escapeXml'](_0x1dc8c4){const _0x3e33a6=a0_0x119fb1;if(!_0x1dc8c4)return'';return _0x1dc8c4[_0x3e33a6(0xeb)](/&/g,'&amp;')['replace'](/</g,_0x3e33a6(0x107))['replace'](/>/g,_0x3e33a6(0x114))[_0x3e33a6(0xeb)](/"/g,'&quot;')['replace'](/'/g,_0x3e33a6(0x10a));}['formatBytes'](_0x4f3df2){const _0x1c5360=a0_0x119fb1;if(_0x4f3df2===0x0)return'0\x20Bytes';const _0x1997d5=0x400,_0x38e4d1=[_0x1c5360(0xfb),'KB','MB','GB'],_0x474f48=Math[_0x1c5360(0xfd)](Math['log'](_0x4f3df2)/Math['log'](_0x1997d5));return parseFloat((_0x4f3df2/Math[_0x1c5360(0xe8)](_0x1997d5,_0x474f48))['toFixed'](0x2))+_0x38e4d1[_0x474f48];}async['estimateTotalTokens'](_0x10219c){const _0x1045e5=a0_0x119fb1;try{const _0xca9787=await this[_0x1045e5(0xec)][_0x1045e5(0xee)](_0x10219c);let _0x16f02a=0x0;for(const _0x1d0f15 of _0xca9787){_0x1d0f15['mode']==='content'?_0x16f02a+=_0x1d0f15[_0x1045e5(0xf9)]||0x0:_0x16f02a+=0x14;}return _0x16f02a;}catch(_0x2a4004){return this['logger']?.[_0x1045e5(0x104)]('Error\x20estimating\x20total\x20tokens',{'agentId':_0x10219c,'error':_0x2a4004[_0x1045e5(0xed)]}),0x0;}}async['getAttachmentSummary'](_0x5b849e){const _0x4130b7=a0_0x119fb1;try{const _0x15fb36=await this['attachmentService']['getActiveAttachments'](_0x5b849e),_0x349c8e={'totalActive':_0x15fb36['length'],'contentMode':_0x15fb36[_0x4130b7(0xf8)](_0x20ce99=>_0x20ce99[_0x4130b7(0x113)]==='content')[_0x4130b7(0xf7)],'referenceMode':_0x15fb36['filter'](_0x128a70=>_0x128a70[_0x4130b7(0x113)]===_0x4130b7(0x10b))['length'],'estimatedTokens':0x0,'files':[]};for(const _0x184fb2 of _0x15fb36){_0x349c8e['estimatedTokens']+=_0x184fb2[_0x4130b7(0xf9)]||0x0,_0x349c8e['files']['push']({'fileName':_0x184fb2[_0x4130b7(0xf1)],'mode':_0x184fb2['mode'],'size':this['formatBytes'](_0x184fb2[_0x4130b7(0xe6)]),'tokens':_0x184fb2[_0x4130b7(0xf9)]||0x0});}return _0x349c8e;}catch(_0x4eb1ac){return this['logger']?.['error'](_0x4130b7(0x10d),{'agentId':_0x5b849e,'error':_0x4eb1ac['message']}),{'totalActive':0x0,'contentMode':0x0,'referenceMode':0x0,'estimatedTokens':0x0,'files':[]};}}}export default ContextInjectionService;