@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,2873 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TaskManagerTool - Manages task list for agent autonomous operation
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Allows agents to create, update, and manage their own TODO list
|
|
6
|
-
* - Provides task tracking for agent-mode scheduling decisions
|
|
7
|
-
* - Ensures agents only consume resources when they have actual work
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { BaseTool } from './baseTool.js';
|
|
11
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
12
|
-
|
|
13
|
-
class TaskManagerTool extends BaseTool {
|
|
14
|
-
constructor(config = {}) {
|
|
15
|
-
super({
|
|
16
|
-
name: 'taskmanager',
|
|
17
|
-
description: config.description || 'Task management tool for organizing and tracking work',
|
|
18
|
-
...config
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
this.supportedActions = ['create', 'update', 'list', 'complete', 'cancel', 'clear', 'depend', 'relate', 'subtask', 'prioritize', 'template', 'progress', 'analytics', 'sync'];
|
|
22
|
-
this.taskStatuses = ['pending', 'in_progress', 'blocked', 'completed', 'cancelled'];
|
|
23
|
-
this.taskPriorities = ['urgent', 'high', 'medium', 'low'];
|
|
24
|
-
this.dependencyTypes = ['blocks', 'relates', 'subtask', 'parent'];
|
|
25
|
-
|
|
26
|
-
// Phase 3.4: Progress tracking stages
|
|
27
|
-
this.progressStages = ['not_started', 'planning', 'in_development', 'testing', 'review', 'completed'];
|
|
28
|
-
this.milestoneTypes = ['checkpoint', 'deliverable', 'review_point', 'dependency_gate'];
|
|
29
|
-
|
|
30
|
-
// Phase 3.2: Priority scoring weights
|
|
31
|
-
this.priorityWeights = {
|
|
32
|
-
blocking: 3.0, // Tasks that block others
|
|
33
|
-
age: 1.5, // Older tasks get higher priority
|
|
34
|
-
userPriority: 2.0, // User-defined priority
|
|
35
|
-
contextSwitching: 1.2, // Reduce context switching penalty
|
|
36
|
-
dependency: 1.8 // Tasks with many dependencies
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Phase 3.3: Built-in task templates
|
|
40
|
-
this.taskTemplates = {
|
|
41
|
-
'web-app-development': {
|
|
42
|
-
name: 'Web Application Development',
|
|
43
|
-
description: 'Complete workflow for building a web application',
|
|
44
|
-
category: 'development',
|
|
45
|
-
tasks: [
|
|
46
|
-
{
|
|
47
|
-
title: 'Project Setup & Planning',
|
|
48
|
-
description: 'Initialize project structure, configure tools, and plan architecture',
|
|
49
|
-
priority: 'high',
|
|
50
|
-
dependencies: []
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
title: 'Database Design & Setup',
|
|
54
|
-
description: 'Design database schema, create tables, and set up connections',
|
|
55
|
-
priority: 'high',
|
|
56
|
-
dependencies: ['Project Setup & Planning']
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
title: 'Backend API Development',
|
|
60
|
-
description: 'Implement REST API endpoints and business logic',
|
|
61
|
-
priority: 'high',
|
|
62
|
-
dependencies: ['Database Design & Setup']
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
title: 'Frontend Development',
|
|
66
|
-
description: 'Build user interface components and implement client-side logic',
|
|
67
|
-
priority: 'medium',
|
|
68
|
-
dependencies: ['Backend API Development']
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
title: 'Testing & Quality Assurance',
|
|
72
|
-
description: 'Write and run unit tests, integration tests, and perform QA',
|
|
73
|
-
priority: 'medium',
|
|
74
|
-
dependencies: ['Frontend Development']
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
title: 'Deployment & Launch',
|
|
78
|
-
description: 'Deploy to production environment and monitor launch',
|
|
79
|
-
priority: 'high',
|
|
80
|
-
dependencies: ['Testing & Quality Assurance']
|
|
81
|
-
}
|
|
82
|
-
]
|
|
83
|
-
},
|
|
84
|
-
'api-integration': {
|
|
85
|
-
name: 'API Integration',
|
|
86
|
-
description: 'Standard workflow for integrating with external APIs',
|
|
87
|
-
category: 'integration',
|
|
88
|
-
tasks: [
|
|
89
|
-
{
|
|
90
|
-
title: 'API Research & Documentation Review',
|
|
91
|
-
description: 'Study API documentation, authentication, and rate limits',
|
|
92
|
-
priority: 'high',
|
|
93
|
-
dependencies: []
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
title: 'Authentication Setup',
|
|
97
|
-
description: 'Implement API key management and authentication flow',
|
|
98
|
-
priority: 'high',
|
|
99
|
-
dependencies: ['API Research & Documentation Review']
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
title: 'Core Integration Implementation',
|
|
103
|
-
description: 'Build API client and implement main integration logic',
|
|
104
|
-
priority: 'high',
|
|
105
|
-
dependencies: ['Authentication Setup']
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
title: 'Error Handling & Retry Logic',
|
|
109
|
-
description: 'Implement robust error handling and retry mechanisms',
|
|
110
|
-
priority: 'medium',
|
|
111
|
-
dependencies: ['Core Integration Implementation']
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
title: 'Testing & Validation',
|
|
115
|
-
description: 'Test integration with various scenarios and edge cases',
|
|
116
|
-
priority: 'medium',
|
|
117
|
-
dependencies: ['Error Handling & Retry Logic']
|
|
118
|
-
}
|
|
119
|
-
]
|
|
120
|
-
},
|
|
121
|
-
'bug-fix': {
|
|
122
|
-
name: 'Bug Fix Workflow',
|
|
123
|
-
description: 'Systematic approach to identifying and fixing bugs',
|
|
124
|
-
category: 'maintenance',
|
|
125
|
-
tasks: [
|
|
126
|
-
{
|
|
127
|
-
title: 'Bug Reproduction & Analysis',
|
|
128
|
-
description: 'Reproduce the bug and analyze root cause',
|
|
129
|
-
priority: 'urgent',
|
|
130
|
-
dependencies: []
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
title: 'Fix Implementation',
|
|
134
|
-
description: 'Implement the bug fix with minimal side effects',
|
|
135
|
-
priority: 'urgent',
|
|
136
|
-
dependencies: ['Bug Reproduction & Analysis']
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
title: 'Testing & Verification',
|
|
140
|
-
description: 'Test fix and verify no regressions introduced',
|
|
141
|
-
priority: 'high',
|
|
142
|
-
dependencies: ['Fix Implementation']
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
title: 'Documentation Update',
|
|
146
|
-
description: 'Update documentation if behavior changed',
|
|
147
|
-
priority: 'low',
|
|
148
|
-
dependencies: ['Testing & Verification']
|
|
149
|
-
}
|
|
150
|
-
]
|
|
151
|
-
},
|
|
152
|
-
'feature-development': {
|
|
153
|
-
name: 'Feature Development',
|
|
154
|
-
description: 'End-to-end feature development workflow',
|
|
155
|
-
category: 'development',
|
|
156
|
-
tasks: [
|
|
157
|
-
{
|
|
158
|
-
title: 'Requirements Analysis',
|
|
159
|
-
description: 'Analyze requirements and create technical specification',
|
|
160
|
-
priority: 'high',
|
|
161
|
-
dependencies: []
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
title: 'Design & Architecture',
|
|
165
|
-
description: 'Design system architecture and user interface',
|
|
166
|
-
priority: 'high',
|
|
167
|
-
dependencies: ['Requirements Analysis']
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
title: 'Backend Implementation',
|
|
171
|
-
description: 'Implement backend logic and data models',
|
|
172
|
-
priority: 'high',
|
|
173
|
-
dependencies: ['Design & Architecture']
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
title: 'Frontend Implementation',
|
|
177
|
-
description: 'Build user interface and integrate with backend',
|
|
178
|
-
priority: 'medium',
|
|
179
|
-
dependencies: ['Backend Implementation']
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
title: 'Testing & Documentation',
|
|
183
|
-
description: 'Write tests and update documentation',
|
|
184
|
-
priority: 'medium',
|
|
185
|
-
dependencies: ['Frontend Implementation']
|
|
186
|
-
}
|
|
187
|
-
]
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Get basic tool description (required by BaseTool)
|
|
194
|
-
* @returns {string} Tool description
|
|
195
|
-
*/
|
|
196
|
-
getDescription() {
|
|
197
|
-
return `
|
|
198
|
-
Task Manager Tool: Organize and track work with TODO lists for agent-mode scheduling.
|
|
199
|
-
|
|
200
|
-
**CRITICAL FOR AGENT MODE**: You MUST maintain your task list to remain active in agent mode!
|
|
201
|
-
|
|
202
|
-
The TaskManager tool allows you to organize and track your work. Without tasks, you will not receive scheduling time.
|
|
203
|
-
|
|
204
|
-
### Actions:
|
|
205
|
-
- **sync**: 🌟 RECOMMENDED - Manage entire task list at once (Claude Code style)
|
|
206
|
-
- **create**: Create a new task with title and description
|
|
207
|
-
- **update**: Update task status or properties
|
|
208
|
-
- **list**: List all tasks with their current status
|
|
209
|
-
- **complete**: Mark a task as completed
|
|
210
|
-
- **cancel**: Cancel a task (mark as irrelevant)
|
|
211
|
-
- **clear**: Clear all completed/cancelled tasks
|
|
212
|
-
- **depend**: Create dependency between tasks (blocking relationships)
|
|
213
|
-
- **relate**: Link related tasks (non-blocking associations)
|
|
214
|
-
- **subtask**: Create subtask relationships (parent-child hierarchy)
|
|
215
|
-
- **prioritize**: Intelligent task prioritization with multiple modes
|
|
216
|
-
- **template**: Template management for common workflows
|
|
217
|
-
- **progress**: Track task progress with stages, milestones, and notes
|
|
218
|
-
|
|
219
|
-
### Usage Examples:
|
|
220
|
-
|
|
221
|
-
✨ Sync entire task list (RECOMMENDED - create comprehensive breakdown):
|
|
222
|
-
<taskmanager>
|
|
223
|
-
<action>sync</action>
|
|
224
|
-
<tasks>[
|
|
225
|
-
{
|
|
226
|
-
"title": "Analyze user requirements",
|
|
227
|
-
"description": "Understand what the user wants to achieve",
|
|
228
|
-
"status": "completed",
|
|
229
|
-
"priority": "high"
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
"title": "Design database schema",
|
|
233
|
-
"description": "Create tables and relationships",
|
|
234
|
-
"status": "in_progress",
|
|
235
|
-
"priority": "high"
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
"title": "Implement API endpoints",
|
|
239
|
-
"status": "pending",
|
|
240
|
-
"priority": "medium"
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
"title": "Write tests",
|
|
244
|
-
"status": "pending",
|
|
245
|
-
"priority": "medium"
|
|
246
|
-
}
|
|
247
|
-
]</tasks>
|
|
248
|
-
</taskmanager>
|
|
249
|
-
|
|
250
|
-
Create a task:
|
|
251
|
-
<taskmanager>
|
|
252
|
-
<action>create</action>
|
|
253
|
-
<title>Analyze user requirements</title>
|
|
254
|
-
<description>Break down the user's request into actionable steps</description>
|
|
255
|
-
<priority>high</priority>
|
|
256
|
-
</taskmanager>
|
|
257
|
-
|
|
258
|
-
List all tasks:
|
|
259
|
-
<taskmanager>
|
|
260
|
-
<action>list</action>
|
|
261
|
-
</taskmanager>
|
|
262
|
-
|
|
263
|
-
Create task dependency:
|
|
264
|
-
<taskmanager>
|
|
265
|
-
<action>depend</action>
|
|
266
|
-
<taskId>task-uuid-here</taskId>
|
|
267
|
-
<dependsOn>other-task-uuid</dependsOn>
|
|
268
|
-
<dependencyType>blocks</dependencyType>
|
|
269
|
-
</taskmanager>
|
|
270
|
-
|
|
271
|
-
Create subtask:
|
|
272
|
-
<taskmanager>
|
|
273
|
-
<action>subtask</action>
|
|
274
|
-
<parentTaskId>parent-task-uuid</parentTaskId>
|
|
275
|
-
<title>Implement user authentication</title>
|
|
276
|
-
<description>Create login and signup functionality</description>
|
|
277
|
-
<priority>high</priority>
|
|
278
|
-
</taskmanager>
|
|
279
|
-
|
|
280
|
-
Auto-prioritize all tasks:
|
|
281
|
-
<taskmanager>
|
|
282
|
-
<action>prioritize</action>
|
|
283
|
-
<mode>auto</mode>
|
|
284
|
-
</taskmanager>
|
|
285
|
-
|
|
286
|
-
Analyze specific task priority:
|
|
287
|
-
<taskmanager>
|
|
288
|
-
<action>prioritize</action>
|
|
289
|
-
<mode>analyze</mode>
|
|
290
|
-
<taskId>task-uuid-here</taskId>
|
|
291
|
-
</taskmanager>
|
|
292
|
-
|
|
293
|
-
Balance workload across agents:
|
|
294
|
-
<taskmanager>
|
|
295
|
-
<action>prioritize</action>
|
|
296
|
-
<mode>balance</mode>
|
|
297
|
-
</taskmanager>
|
|
298
|
-
|
|
299
|
-
List available templates:
|
|
300
|
-
<taskmanager>
|
|
301
|
-
<action>template</action>
|
|
302
|
-
<mode>list</mode>
|
|
303
|
-
</taskmanager>
|
|
304
|
-
|
|
305
|
-
Apply web app development template:
|
|
306
|
-
<taskmanager>
|
|
307
|
-
<action>template</action>
|
|
308
|
-
<mode>apply</mode>
|
|
309
|
-
<templateId>web-app-development</templateId>
|
|
310
|
-
<projectContext>{"projectName": "UserPortal", "urgency": "high"}</projectContext>
|
|
311
|
-
</taskmanager>
|
|
312
|
-
|
|
313
|
-
Suggest templates based on current tasks:
|
|
314
|
-
<taskmanager>
|
|
315
|
-
<action>template</action>
|
|
316
|
-
<mode>suggest</mode>
|
|
317
|
-
</taskmanager>
|
|
318
|
-
|
|
319
|
-
Update task progress:
|
|
320
|
-
<taskmanager>
|
|
321
|
-
<action>progress</action>
|
|
322
|
-
<mode>update</mode>
|
|
323
|
-
<taskId>task-uuid-here</taskId>
|
|
324
|
-
<stage>in_development</stage>
|
|
325
|
-
<percentage>45</percentage>
|
|
326
|
-
<note>Completed API integration, starting frontend work</note>
|
|
327
|
-
</taskmanager>
|
|
328
|
-
|
|
329
|
-
Get progress overview:
|
|
330
|
-
<taskmanager>
|
|
331
|
-
<action>progress</action>
|
|
332
|
-
<mode>overview</mode>
|
|
333
|
-
</taskmanager>
|
|
334
|
-
|
|
335
|
-
Calculate progress based on subtasks:
|
|
336
|
-
<taskmanager>
|
|
337
|
-
<action>progress</action>
|
|
338
|
-
<mode>calculate</mode>
|
|
339
|
-
<taskId>task-uuid-here</taskId>
|
|
340
|
-
</taskmanager>
|
|
341
|
-
|
|
342
|
-
### 🚨 MANDATORY WORKFLOW - ZERO EXCEPTIONS ALLOWED:
|
|
343
|
-
|
|
344
|
-
**EVERY RESPONSE MUST:**
|
|
345
|
-
1. **START WITH**: <taskmanager><action>list</action></taskmanager>
|
|
346
|
-
2. **WORK**: Complete the user's request
|
|
347
|
-
3. **END WITH**: <taskmanager><action>complete</action><taskId>ID</taskId></taskmanager>
|
|
348
|
-
|
|
349
|
-
**WARNING: Skipping this workflow = INFINITE LOOPS = SYSTEM FAILURE!**
|
|
350
|
-
**NO RESPONSE IS COMPLETE WITHOUT TASK COMPLETION!**
|
|
351
|
-
|
|
352
|
-
STEP 1 - Always start by listing tasks:
|
|
353
|
-
<taskmanager>
|
|
354
|
-
<action>list</action>
|
|
355
|
-
</taskmanager>
|
|
356
|
-
|
|
357
|
-
STEP 2 - After completing work, mark task complete:
|
|
358
|
-
<taskmanager>
|
|
359
|
-
<action>complete</action>
|
|
360
|
-
<taskId>task-1759257696373-wjsquroxz</taskId>
|
|
361
|
-
</taskmanager>
|
|
362
|
-
|
|
363
|
-
### MANDATORY: Complete tasks when done or you'll loop forever!
|
|
364
|
-
`;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Parse parameters from XML tag format
|
|
369
|
-
* Unwraps values from tag parser's {value, attributes} format
|
|
370
|
-
* @param {Object} content - Raw parameters from tag parser or string content
|
|
371
|
-
* @returns {Object} Parsed parameters with unwrapped values
|
|
372
|
-
*/
|
|
373
|
-
parseParameters(content) {
|
|
374
|
-
// If content is a string, return as-is for legacy support
|
|
375
|
-
if (typeof content === 'string') {
|
|
376
|
-
return { rawContent: content };
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// If content is already an object, unwrap tag parser format
|
|
380
|
-
if (typeof content === 'object' && content !== null) {
|
|
381
|
-
const unwrapped = {};
|
|
382
|
-
|
|
383
|
-
for (const [key, value] of Object.entries(content)) {
|
|
384
|
-
// Check if this is tag parser format: {value: "...", attributes: {}}
|
|
385
|
-
if (value && typeof value === 'object' && 'value' in value) {
|
|
386
|
-
unwrapped[key] = value.value;
|
|
387
|
-
} else {
|
|
388
|
-
// Keep as-is if not wrapped
|
|
389
|
-
unwrapped[key] = value;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
return unwrapped;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
return content;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Execute task management action
|
|
401
|
-
* @param {Object} params - Tool arguments
|
|
402
|
-
* @param {Object} context - Execution context
|
|
403
|
-
* @returns {Promise<Object>} Execution result
|
|
404
|
-
*/
|
|
405
|
-
async execute(params, context) {
|
|
406
|
-
try {
|
|
407
|
-
// CRITICAL FIX: Unwrap tag parser format {value, attributes}
|
|
408
|
-
// The messageProcessor passes params with wrapped values from parseXMLParameters
|
|
409
|
-
// We need to unwrap them before processing
|
|
410
|
-
const unwrappedParams = {};
|
|
411
|
-
for (const [key, value] of Object.entries(params)) {
|
|
412
|
-
if (value && typeof value === 'object' && 'value' in value) {
|
|
413
|
-
// Tag parser wrapped format: {value: "...", attributes: {}}
|
|
414
|
-
unwrappedParams[key] = value.value;
|
|
415
|
-
} else {
|
|
416
|
-
// Already unwrapped or direct value
|
|
417
|
-
unwrappedParams[key] = value;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// Use unwrapped params for all subsequent processing
|
|
422
|
-
params = unwrappedParams;
|
|
423
|
-
|
|
424
|
-
const { agentId, agentName } = context;
|
|
425
|
-
|
|
426
|
-
if (!agentId) {
|
|
427
|
-
throw new Error('Agent ID is required for task management');
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// Get agent from pool
|
|
431
|
-
const agent = await context.agentPool.getAgent(agentId);
|
|
432
|
-
if (!agent) {
|
|
433
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// Initialize taskList if it doesn't exist (for backwards compatibility)
|
|
437
|
-
if (!agent.taskList) {
|
|
438
|
-
agent.taskList = {
|
|
439
|
-
tasks: [],
|
|
440
|
-
lastUpdated: new Date().toISOString()
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
const action = params.action?.toLowerCase();
|
|
445
|
-
if (!this.supportedActions.includes(action)) {
|
|
446
|
-
throw new Error(`Unsupported action: ${action}. Supported: ${this.supportedActions.join(', ')}`);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
let result;
|
|
450
|
-
switch (action) {
|
|
451
|
-
case 'create':
|
|
452
|
-
result = await this.createTask(agent, params);
|
|
453
|
-
break;
|
|
454
|
-
case 'update':
|
|
455
|
-
result = await this.updateTask(agent, params);
|
|
456
|
-
break;
|
|
457
|
-
case 'list':
|
|
458
|
-
result = await this.listTasks(agent, params);
|
|
459
|
-
break;
|
|
460
|
-
case 'complete':
|
|
461
|
-
result = await this.completeTask(agent, params);
|
|
462
|
-
break;
|
|
463
|
-
case 'cancel':
|
|
464
|
-
result = await this.cancelTask(agent, params);
|
|
465
|
-
break;
|
|
466
|
-
case 'clear':
|
|
467
|
-
result = await this.clearCompletedTasks(agent, params);
|
|
468
|
-
break;
|
|
469
|
-
case 'depend':
|
|
470
|
-
result = await this.createDependency(agent, params);
|
|
471
|
-
break;
|
|
472
|
-
case 'relate':
|
|
473
|
-
result = await this.relateTask(agent, params);
|
|
474
|
-
break;
|
|
475
|
-
case 'subtask':
|
|
476
|
-
result = await this.createSubtask(agent, params);
|
|
477
|
-
break;
|
|
478
|
-
case 'prioritize':
|
|
479
|
-
result = await this.intelligentPrioritization(agent, params);
|
|
480
|
-
break;
|
|
481
|
-
case 'template':
|
|
482
|
-
result = await this.manageTemplates(agent, params);
|
|
483
|
-
break;
|
|
484
|
-
case 'progress':
|
|
485
|
-
result = await this.trackProgress(agent, params);
|
|
486
|
-
break;
|
|
487
|
-
case 'analytics':
|
|
488
|
-
result = await this.generateAnalytics(agent, params);
|
|
489
|
-
break;
|
|
490
|
-
case 'sync':
|
|
491
|
-
result = await this.syncTasks(agent, params);
|
|
492
|
-
break;
|
|
493
|
-
default:
|
|
494
|
-
throw new Error(`Unknown action: ${action}`);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
// Update the agent's lastActivity
|
|
498
|
-
agent.lastActivity = new Date().toISOString();
|
|
499
|
-
agent.taskList.lastUpdated = new Date().toISOString();
|
|
500
|
-
|
|
501
|
-
// Persist the agent state
|
|
502
|
-
await context.agentPool.persistAgentState(agentId);
|
|
503
|
-
|
|
504
|
-
this.logger?.info(`TaskManager action executed: ${action}`, {
|
|
505
|
-
agentId,
|
|
506
|
-
agentName,
|
|
507
|
-
action,
|
|
508
|
-
taskCount: agent.taskList.tasks.length,
|
|
509
|
-
pendingTasks: agent.taskList.tasks.filter(t => t.status === 'pending').length,
|
|
510
|
-
inProgressTasks: agent.taskList.tasks.filter(t => t.status === 'in_progress').length
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
return {
|
|
514
|
-
success: true,
|
|
515
|
-
action,
|
|
516
|
-
result,
|
|
517
|
-
summary: this.generateTaskSummary(agent.taskList)
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
} catch (error) {
|
|
521
|
-
this.logger?.error('TaskManager execution failed', {
|
|
522
|
-
error: error.message,
|
|
523
|
-
context,
|
|
524
|
-
params
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
return {
|
|
528
|
-
success: false,
|
|
529
|
-
error: error.message
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
* Create a new task
|
|
536
|
-
* @private
|
|
537
|
-
*/
|
|
538
|
-
async createTask(agent, params) {
|
|
539
|
-
const { title, description = '', priority = 'medium' } = params;
|
|
540
|
-
|
|
541
|
-
if (!title) {
|
|
542
|
-
throw new Error('Task title is required');
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
if (priority && !this.taskPriorities.includes(priority.toLowerCase())) {
|
|
546
|
-
throw new Error(`Invalid priority: ${priority}. Must be: ${this.taskPriorities.join(', ')}`);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
const task = {
|
|
550
|
-
id: `task-${uuidv4()}`,
|
|
551
|
-
title,
|
|
552
|
-
description,
|
|
553
|
-
status: 'pending',
|
|
554
|
-
priority: priority.toLowerCase(),
|
|
555
|
-
createdAt: new Date().toISOString(),
|
|
556
|
-
updatedAt: new Date().toISOString()
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
agent.taskList.tasks.push(task);
|
|
560
|
-
|
|
561
|
-
return {
|
|
562
|
-
message: 'Task created successfully',
|
|
563
|
-
task
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Sync entire task list (Claude Code style batch management)
|
|
569
|
-
* @private
|
|
570
|
-
*/
|
|
571
|
-
async syncTasks(agent, params) {
|
|
572
|
-
let { tasks } = params;
|
|
573
|
-
|
|
574
|
-
// Parse tasks if provided as JSON string
|
|
575
|
-
if (typeof tasks === 'string') {
|
|
576
|
-
try {
|
|
577
|
-
tasks = JSON.parse(tasks);
|
|
578
|
-
} catch (error) {
|
|
579
|
-
throw new Error(`Invalid tasks JSON: ${error.message}`);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
if (!Array.isArray(tasks)) {
|
|
584
|
-
throw new Error('Tasks must be an array');
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
if (tasks.length === 0) {
|
|
588
|
-
throw new Error('Tasks array cannot be empty');
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
const timestamp = new Date().toISOString();
|
|
592
|
-
const existingTasks = agent.taskList.tasks || [];
|
|
593
|
-
const updatedTasks = [];
|
|
594
|
-
const createdTasks = [];
|
|
595
|
-
const matchedIds = new Set();
|
|
596
|
-
|
|
597
|
-
// Helper: fuzzy match task by title
|
|
598
|
-
const findExistingTask = (title) => {
|
|
599
|
-
const normalizedTitle = title.toLowerCase().trim();
|
|
600
|
-
return existingTasks.find(t =>
|
|
601
|
-
t.title.toLowerCase().trim() === normalizedTitle &&
|
|
602
|
-
!matchedIds.has(t.id)
|
|
603
|
-
);
|
|
604
|
-
};
|
|
605
|
-
|
|
606
|
-
// Validate and process each task
|
|
607
|
-
for (const taskData of tasks) {
|
|
608
|
-
if (!taskData.title) {
|
|
609
|
-
throw new Error('Each task must have a title');
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
const status = (taskData.status || 'pending').toLowerCase();
|
|
613
|
-
const priority = (taskData.priority || 'medium').toLowerCase();
|
|
614
|
-
|
|
615
|
-
// Validate status
|
|
616
|
-
if (!this.taskStatuses.includes(status)) {
|
|
617
|
-
throw new Error(`Invalid status "${status}" for task "${taskData.title}". Must be: ${this.taskStatuses.join(', ')}`);
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
// Validate priority
|
|
621
|
-
if (!this.taskPriorities.includes(priority)) {
|
|
622
|
-
throw new Error(`Invalid priority "${priority}" for task "${taskData.title}". Must be: ${this.taskPriorities.join(', ')}`);
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
// Try to match with existing task
|
|
626
|
-
const existingTask = findExistingTask(taskData.title);
|
|
627
|
-
|
|
628
|
-
if (existingTask) {
|
|
629
|
-
// Update existing task
|
|
630
|
-
existingTask.status = status;
|
|
631
|
-
existingTask.priority = priority;
|
|
632
|
-
if (taskData.description !== undefined) {
|
|
633
|
-
existingTask.description = taskData.description;
|
|
634
|
-
}
|
|
635
|
-
existingTask.updatedAt = timestamp;
|
|
636
|
-
|
|
637
|
-
updatedTasks.push(existingTask);
|
|
638
|
-
matchedIds.add(existingTask.id);
|
|
639
|
-
} else {
|
|
640
|
-
// Create new task
|
|
641
|
-
const newTask = {
|
|
642
|
-
id: `task-${uuidv4()}`,
|
|
643
|
-
title: taskData.title,
|
|
644
|
-
description: taskData.description || '',
|
|
645
|
-
status: status,
|
|
646
|
-
priority: priority,
|
|
647
|
-
createdAt: timestamp,
|
|
648
|
-
updatedAt: timestamp,
|
|
649
|
-
source: 'sync'
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
createdTasks.push(newTask);
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
// Replace task list with synced tasks
|
|
657
|
-
agent.taskList.tasks = [...updatedTasks, ...createdTasks];
|
|
658
|
-
|
|
659
|
-
// Ensure only one task is in_progress
|
|
660
|
-
const inProgressTasks = agent.taskList.tasks.filter(t => t.status === 'in_progress');
|
|
661
|
-
if (inProgressTasks.length > 1) {
|
|
662
|
-
// Keep only the first in_progress task, set others to pending
|
|
663
|
-
for (let i = 1; i < inProgressTasks.length; i++) {
|
|
664
|
-
inProgressTasks[i].status = 'pending';
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
// Auto-set first pending task to in_progress if no task is in_progress
|
|
669
|
-
if (inProgressTasks.length === 0) {
|
|
670
|
-
const firstPending = agent.taskList.tasks.find(t => t.status === 'pending');
|
|
671
|
-
if (firstPending) {
|
|
672
|
-
firstPending.status = 'in_progress';
|
|
673
|
-
firstPending.updatedAt = timestamp;
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
agent.taskList.lastUpdated = timestamp;
|
|
678
|
-
|
|
679
|
-
return {
|
|
680
|
-
message: 'Task list synchronized successfully',
|
|
681
|
-
summary: {
|
|
682
|
-
total: agent.taskList.tasks.length,
|
|
683
|
-
created: createdTasks.length,
|
|
684
|
-
updated: updatedTasks.length,
|
|
685
|
-
removed: existingTasks.length - matchedIds.size,
|
|
686
|
-
pending: agent.taskList.tasks.filter(t => t.status === 'pending').length,
|
|
687
|
-
inProgress: agent.taskList.tasks.filter(t => t.status === 'in_progress').length,
|
|
688
|
-
completed: agent.taskList.tasks.filter(t => t.status === 'completed').length,
|
|
689
|
-
cancelled: agent.taskList.tasks.filter(t => t.status === 'cancelled').length
|
|
690
|
-
},
|
|
691
|
-
tasks: agent.taskList.tasks.map(t => ({
|
|
692
|
-
id: t.id,
|
|
693
|
-
title: t.title,
|
|
694
|
-
status: t.status,
|
|
695
|
-
priority: t.priority
|
|
696
|
-
}))
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/**
|
|
701
|
-
* Update an existing task
|
|
702
|
-
* @private
|
|
703
|
-
*/
|
|
704
|
-
async updateTask(agent, params) {
|
|
705
|
-
const { taskId, status, priority, title, description } = params;
|
|
706
|
-
|
|
707
|
-
if (!taskId) {
|
|
708
|
-
throw new Error('Task ID is required for update');
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
const task = agent.taskList.tasks.find(t => t.id === taskId);
|
|
712
|
-
if (!task) {
|
|
713
|
-
throw new Error(`Task not found: ${taskId}`);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
if (status) {
|
|
717
|
-
if (!this.taskStatuses.includes(status.toLowerCase())) {
|
|
718
|
-
throw new Error(`Invalid status: ${status}. Must be: ${this.taskStatuses.join(', ')}`);
|
|
719
|
-
}
|
|
720
|
-
task.status = status.toLowerCase();
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
if (priority) {
|
|
724
|
-
if (!this.taskPriorities.includes(priority.toLowerCase())) {
|
|
725
|
-
throw new Error(`Invalid priority: ${priority}. Must be: ${this.taskPriorities.join(', ')}`);
|
|
726
|
-
}
|
|
727
|
-
task.priority = priority.toLowerCase();
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
if (title !== undefined) task.title = title;
|
|
731
|
-
if (description !== undefined) task.description = description;
|
|
732
|
-
|
|
733
|
-
task.updatedAt = new Date().toISOString();
|
|
734
|
-
|
|
735
|
-
return {
|
|
736
|
-
message: 'Task updated successfully',
|
|
737
|
-
task
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
/**
|
|
742
|
-
* List all tasks
|
|
743
|
-
* @private
|
|
744
|
-
*/
|
|
745
|
-
async listTasks(agent, params) {
|
|
746
|
-
const { status, priority } = params;
|
|
747
|
-
let tasks = [...agent.taskList.tasks];
|
|
748
|
-
|
|
749
|
-
// Filter by status if specified
|
|
750
|
-
if (status) {
|
|
751
|
-
if (!this.taskStatuses.includes(status.toLowerCase())) {
|
|
752
|
-
throw new Error(`Invalid status filter: ${status}`);
|
|
753
|
-
}
|
|
754
|
-
tasks = tasks.filter(t => t.status === status.toLowerCase());
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// Filter by priority if specified
|
|
758
|
-
if (priority) {
|
|
759
|
-
if (!this.taskPriorities.includes(priority.toLowerCase())) {
|
|
760
|
-
throw new Error(`Invalid priority filter: ${priority}`);
|
|
761
|
-
}
|
|
762
|
-
tasks = tasks.filter(t => t.priority === priority.toLowerCase());
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
// Sort by priority (high first) then by creation date
|
|
766
|
-
const priorityOrder = { high: 0, medium: 1, low: 2 };
|
|
767
|
-
tasks.sort((a, b) => {
|
|
768
|
-
const priorityDiff = priorityOrder[a.priority] - priorityOrder[b.priority];
|
|
769
|
-
if (priorityDiff !== 0) return priorityDiff;
|
|
770
|
-
return new Date(a.createdAt) - new Date(b.createdAt);
|
|
771
|
-
});
|
|
772
|
-
|
|
773
|
-
return {
|
|
774
|
-
totalTasks: tasks.length,
|
|
775
|
-
tasks,
|
|
776
|
-
summary: {
|
|
777
|
-
pending: tasks.filter(t => t.status === 'pending').length,
|
|
778
|
-
in_progress: tasks.filter(t => t.status === 'in_progress').length,
|
|
779
|
-
completed: tasks.filter(t => t.status === 'completed').length,
|
|
780
|
-
cancelled: tasks.filter(t => t.status === 'cancelled').length
|
|
781
|
-
}
|
|
782
|
-
};
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
/**
|
|
786
|
-
* Complete a task
|
|
787
|
-
* @private
|
|
788
|
-
*/
|
|
789
|
-
async completeTask(agent, params) {
|
|
790
|
-
let { taskId } = params;
|
|
791
|
-
|
|
792
|
-
// If no taskId provided, auto-complete the first in-progress task
|
|
793
|
-
if (!taskId) {
|
|
794
|
-
const inProgressTask = agent.taskList.tasks.find(t => t.status === 'in_progress' || t.status === 'pending');
|
|
795
|
-
if (inProgressTask) {
|
|
796
|
-
taskId = inProgressTask.id;
|
|
797
|
-
this.logger?.info(`Auto-completing current task: ${taskId}`, {
|
|
798
|
-
agentId: agent.id,
|
|
799
|
-
taskTitle: inProgressTask.title
|
|
800
|
-
});
|
|
801
|
-
} else {
|
|
802
|
-
throw new Error('No task ID provided and no in-progress tasks found to complete');
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
const task = agent.taskList.tasks.find(t => t.id === taskId);
|
|
807
|
-
if (!task) {
|
|
808
|
-
throw new Error(`Task not found: ${taskId}`);
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
if (task.status === 'completed') {
|
|
812
|
-
return {
|
|
813
|
-
message: 'Task already completed',
|
|
814
|
-
task
|
|
815
|
-
};
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
task.status = 'completed';
|
|
819
|
-
task.completedAt = new Date().toISOString();
|
|
820
|
-
task.updatedAt = new Date().toISOString();
|
|
821
|
-
|
|
822
|
-
// Phase 3: Trigger dependency updates when task is completed
|
|
823
|
-
if (this.scheduler && typeof this.scheduler.updateDependentTasks === 'function') {
|
|
824
|
-
try {
|
|
825
|
-
await this.scheduler.updateDependentTasks(agent, taskId);
|
|
826
|
-
this.logger?.info(`Triggered dependency update for completed task`, {
|
|
827
|
-
taskId,
|
|
828
|
-
title: task.title
|
|
829
|
-
});
|
|
830
|
-
} catch (error) {
|
|
831
|
-
this.logger?.warn(`Failed to update dependent tasks`, {
|
|
832
|
-
taskId,
|
|
833
|
-
error: error.message
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
return {
|
|
839
|
-
message: 'Task completed successfully',
|
|
840
|
-
task,
|
|
841
|
-
dependenciesUpdated: !!this.scheduler
|
|
842
|
-
};
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* Cancel a task
|
|
847
|
-
* @private
|
|
848
|
-
*/
|
|
849
|
-
async cancelTask(agent, params) {
|
|
850
|
-
const { taskId, reason = '' } = params;
|
|
851
|
-
|
|
852
|
-
if (!taskId) {
|
|
853
|
-
throw new Error('Task ID is required');
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
const task = agent.taskList.tasks.find(t => t.id === taskId);
|
|
857
|
-
if (!task) {
|
|
858
|
-
throw new Error(`Task not found: ${taskId}`);
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
task.status = 'cancelled';
|
|
862
|
-
task.cancelledAt = new Date().toISOString();
|
|
863
|
-
task.cancellationReason = reason;
|
|
864
|
-
task.updatedAt = new Date().toISOString();
|
|
865
|
-
|
|
866
|
-
return {
|
|
867
|
-
message: 'Task cancelled successfully',
|
|
868
|
-
task
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Clear completed and cancelled tasks
|
|
874
|
-
* @private
|
|
875
|
-
*/
|
|
876
|
-
async clearCompletedTasks(agent, params) {
|
|
877
|
-
const originalCount = agent.taskList.tasks.length;
|
|
878
|
-
|
|
879
|
-
// Keep only pending and in_progress tasks
|
|
880
|
-
agent.taskList.tasks = agent.taskList.tasks.filter(
|
|
881
|
-
t => t.status === 'pending' || t.status === 'in_progress'
|
|
882
|
-
);
|
|
883
|
-
|
|
884
|
-
const removedCount = originalCount - agent.taskList.tasks.length;
|
|
885
|
-
|
|
886
|
-
return {
|
|
887
|
-
message: `Cleared ${removedCount} completed/cancelled tasks`,
|
|
888
|
-
remainingTasks: agent.taskList.tasks.length,
|
|
889
|
-
removed: removedCount
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
/**
|
|
894
|
-
* Create dependency between tasks (Phase 3)
|
|
895
|
-
* @private
|
|
896
|
-
*/
|
|
897
|
-
async createDependency(agent, params) {
|
|
898
|
-
const { taskId, dependsOn, dependencyType = 'blocks' } = params;
|
|
899
|
-
|
|
900
|
-
if (!taskId || !dependsOn) {
|
|
901
|
-
throw new Error('Both taskId and dependsOn are required for creating dependencies');
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
if (!this.dependencyTypes.includes(dependencyType)) {
|
|
905
|
-
throw new Error(`Invalid dependency type: ${dependencyType}. Must be: ${this.dependencyTypes.join(', ')}`);
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
const task = agent.taskList.tasks.find(t => t.id === taskId);
|
|
909
|
-
const dependencyTask = agent.taskList.tasks.find(t => t.id === dependsOn);
|
|
910
|
-
|
|
911
|
-
if (!task) {
|
|
912
|
-
throw new Error(`Task not found: ${taskId}`);
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
if (!dependencyTask) {
|
|
916
|
-
throw new Error(`Dependency task not found: ${dependsOn}`);
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
// Initialize dependencies array if not exists
|
|
920
|
-
if (!task.dependencies) {
|
|
921
|
-
task.dependencies = [];
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
// Check if dependency already exists
|
|
925
|
-
const existingDep = task.dependencies.find(d => d.taskId === dependsOn);
|
|
926
|
-
if (existingDep) {
|
|
927
|
-
return {
|
|
928
|
-
message: 'Dependency already exists',
|
|
929
|
-
dependency: existingDep
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
// Create dependency
|
|
934
|
-
const dependency = {
|
|
935
|
-
taskId: dependsOn,
|
|
936
|
-
type: dependencyType,
|
|
937
|
-
createdAt: new Date().toISOString()
|
|
938
|
-
};
|
|
939
|
-
|
|
940
|
-
task.dependencies.push(dependency);
|
|
941
|
-
task.updatedAt = new Date().toISOString();
|
|
942
|
-
|
|
943
|
-
// If this is a blocking dependency, check if task should be blocked
|
|
944
|
-
if (dependencyType === 'blocks' && dependencyTask.status !== 'completed') {
|
|
945
|
-
task.status = 'blocked';
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
return {
|
|
949
|
-
message: 'Dependency created successfully',
|
|
950
|
-
dependency,
|
|
951
|
-
task
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
/**
|
|
956
|
-
* Create relationship between tasks (non-blocking)
|
|
957
|
-
* @private
|
|
958
|
-
*/
|
|
959
|
-
async relateTask(agent, params) {
|
|
960
|
-
return await this.createDependency(agent, { ...params, dependencyType: 'relates' });
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
/**
|
|
964
|
-
* Create subtask relationship
|
|
965
|
-
* @private
|
|
966
|
-
*/
|
|
967
|
-
async createSubtask(agent, params) {
|
|
968
|
-
const { parentTaskId, title, description = '', priority = 'medium' } = params;
|
|
969
|
-
|
|
970
|
-
if (!parentTaskId || !title) {
|
|
971
|
-
throw new Error('Parent task ID and title are required for creating subtasks');
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
const parentTask = agent.taskList.tasks.find(t => t.id === parentTaskId);
|
|
975
|
-
if (!parentTask) {
|
|
976
|
-
throw new Error(`Parent task not found: ${parentTaskId}`);
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
// Create the subtask
|
|
980
|
-
const subtask = {
|
|
981
|
-
id: `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
982
|
-
title,
|
|
983
|
-
description,
|
|
984
|
-
status: 'pending',
|
|
985
|
-
priority: priority.toLowerCase(),
|
|
986
|
-
createdAt: new Date().toISOString(),
|
|
987
|
-
updatedAt: new Date().toISOString(),
|
|
988
|
-
parentTaskId: parentTaskId,
|
|
989
|
-
isSubtask: true,
|
|
990
|
-
source: 'user-created'
|
|
991
|
-
};
|
|
992
|
-
|
|
993
|
-
agent.taskList.tasks.push(subtask);
|
|
994
|
-
|
|
995
|
-
// Initialize subtasks array on parent if not exists
|
|
996
|
-
if (!parentTask.subtasks) {
|
|
997
|
-
parentTask.subtasks = [];
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
parentTask.subtasks.push(subtask.id);
|
|
1001
|
-
parentTask.updatedAt = new Date().toISOString();
|
|
1002
|
-
|
|
1003
|
-
return {
|
|
1004
|
-
message: 'Subtask created successfully',
|
|
1005
|
-
subtask,
|
|
1006
|
-
parentTask
|
|
1007
|
-
};
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
/**
|
|
1011
|
-
* Template management (Phase 3.3)
|
|
1012
|
-
* @private
|
|
1013
|
-
*/
|
|
1014
|
-
async manageTemplates(agent, params) {
|
|
1015
|
-
const { mode = 'list', templateId, customTemplate, projectContext } = params;
|
|
1016
|
-
|
|
1017
|
-
let results = {};
|
|
1018
|
-
|
|
1019
|
-
if (mode === 'list') {
|
|
1020
|
-
// List available templates
|
|
1021
|
-
results = await this.listAvailableTemplates(agent);
|
|
1022
|
-
} else if (mode === 'apply' && templateId) {
|
|
1023
|
-
// Apply a template to create tasks
|
|
1024
|
-
results = await this.applyTemplate(agent, templateId, projectContext);
|
|
1025
|
-
} else if (mode === 'create' && customTemplate) {
|
|
1026
|
-
// Create custom template
|
|
1027
|
-
results = await this.createCustomTemplate(agent, customTemplate);
|
|
1028
|
-
} else if (mode === 'suggest') {
|
|
1029
|
-
// Suggest templates based on existing tasks
|
|
1030
|
-
results = await this.suggestTemplates(agent);
|
|
1031
|
-
} else {
|
|
1032
|
-
throw new Error('Invalid template mode. Use: list, apply, create, or suggest');
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
return {
|
|
1036
|
-
message: `Template management completed (${mode})`,
|
|
1037
|
-
mode,
|
|
1038
|
-
...results
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
/**
|
|
1043
|
-
* List available task templates
|
|
1044
|
-
* @private
|
|
1045
|
-
*/
|
|
1046
|
-
async listAvailableTemplates(agent) {
|
|
1047
|
-
const builtInTemplates = Object.entries(this.taskTemplates).map(([id, template]) => ({
|
|
1048
|
-
id,
|
|
1049
|
-
name: template.name,
|
|
1050
|
-
description: template.description,
|
|
1051
|
-
category: template.category,
|
|
1052
|
-
taskCount: template.tasks.length,
|
|
1053
|
-
type: 'built-in'
|
|
1054
|
-
}));
|
|
1055
|
-
|
|
1056
|
-
// Get custom templates from agent's storage
|
|
1057
|
-
const customTemplates = agent.customTemplates || [];
|
|
1058
|
-
const formattedCustom = customTemplates.map(template => ({
|
|
1059
|
-
...template,
|
|
1060
|
-
type: 'custom'
|
|
1061
|
-
}));
|
|
1062
|
-
|
|
1063
|
-
return {
|
|
1064
|
-
builtInTemplates,
|
|
1065
|
-
customTemplates: formattedCustom,
|
|
1066
|
-
totalTemplates: builtInTemplates.length + formattedCustom.length,
|
|
1067
|
-
categories: [...new Set(builtInTemplates.map(t => t.category))]
|
|
1068
|
-
};
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
/**
|
|
1072
|
-
* Apply a template to create structured tasks
|
|
1073
|
-
* @private
|
|
1074
|
-
*/
|
|
1075
|
-
async applyTemplate(agent, templateId, projectContext = {}) {
|
|
1076
|
-
const template = this.taskTemplates[templateId] ||
|
|
1077
|
-
(agent.customTemplates || []).find(t => t.id === templateId);
|
|
1078
|
-
|
|
1079
|
-
if (!template) {
|
|
1080
|
-
throw new Error(`Template not found: ${templateId}`);
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
const createdTasks = [];
|
|
1084
|
-
const taskMapping = new Map(); // Map template task titles to actual task IDs
|
|
1085
|
-
|
|
1086
|
-
// Apply project context to customize template
|
|
1087
|
-
const contextualizedTasks = this.applyProjectContext(template.tasks, projectContext);
|
|
1088
|
-
|
|
1089
|
-
// Create all tasks first
|
|
1090
|
-
for (const templateTask of contextualizedTasks) {
|
|
1091
|
-
const task = {
|
|
1092
|
-
id: `task-${uuidv4()}`,
|
|
1093
|
-
title: templateTask.title,
|
|
1094
|
-
description: templateTask.description,
|
|
1095
|
-
status: 'pending',
|
|
1096
|
-
priority: templateTask.priority,
|
|
1097
|
-
createdAt: new Date().toISOString(),
|
|
1098
|
-
updatedAt: new Date().toISOString(),
|
|
1099
|
-
templateId: templateId,
|
|
1100
|
-
templateOrigin: template.type || 'built-in',
|
|
1101
|
-
source: 'template-generated'
|
|
1102
|
-
};
|
|
1103
|
-
|
|
1104
|
-
agent.taskList.tasks.push(task);
|
|
1105
|
-
createdTasks.push(task);
|
|
1106
|
-
taskMapping.set(templateTask.title, task.id);
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
// Create dependencies after all tasks exist
|
|
1110
|
-
for (let i = 0; i < contextualizedTasks.length; i++) {
|
|
1111
|
-
const templateTask = contextualizedTasks[i];
|
|
1112
|
-
const actualTask = createdTasks[i];
|
|
1113
|
-
|
|
1114
|
-
if (templateTask.dependencies && templateTask.dependencies.length > 0) {
|
|
1115
|
-
actualTask.dependencies = [];
|
|
1116
|
-
|
|
1117
|
-
for (const depTitle of templateTask.dependencies) {
|
|
1118
|
-
const depTaskId = taskMapping.get(depTitle);
|
|
1119
|
-
if (depTaskId) {
|
|
1120
|
-
actualTask.dependencies.push({
|
|
1121
|
-
taskId: depTaskId,
|
|
1122
|
-
type: 'blocks',
|
|
1123
|
-
createdAt: new Date().toISOString()
|
|
1124
|
-
});
|
|
1125
|
-
|
|
1126
|
-
// Set task as blocked if dependency isn't completed
|
|
1127
|
-
actualTask.status = 'blocked';
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
// Auto-prioritize the newly created tasks
|
|
1134
|
-
await this.autoPrioritizeAllTasks(agent);
|
|
1135
|
-
|
|
1136
|
-
return {
|
|
1137
|
-
template: {
|
|
1138
|
-
id: templateId,
|
|
1139
|
-
name: template.name,
|
|
1140
|
-
description: template.description
|
|
1141
|
-
},
|
|
1142
|
-
tasksCreated: createdTasks.length,
|
|
1143
|
-
tasks: createdTasks.map(task => ({
|
|
1144
|
-
id: task.id,
|
|
1145
|
-
title: task.title,
|
|
1146
|
-
priority: task.priority,
|
|
1147
|
-
status: task.status,
|
|
1148
|
-
dependencies: task.dependencies ? task.dependencies.length : 0
|
|
1149
|
-
})),
|
|
1150
|
-
workflowStructure: this.generateWorkflowVisualization(createdTasks)
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
/**
|
|
1155
|
-
* Apply project context to customize template tasks
|
|
1156
|
-
* @private
|
|
1157
|
-
*/
|
|
1158
|
-
applyProjectContext(templateTasks, context) {
|
|
1159
|
-
return templateTasks.map(task => {
|
|
1160
|
-
let customizedTask = { ...task };
|
|
1161
|
-
|
|
1162
|
-
// Apply context-specific customizations
|
|
1163
|
-
if (context.projectName) {
|
|
1164
|
-
customizedTask.title = customizedTask.title.replace(/\[PROJECT\]/g, context.projectName);
|
|
1165
|
-
customizedTask.description = customizedTask.description.replace(/\[PROJECT\]/g, context.projectName);
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
if (context.technology) {
|
|
1169
|
-
customizedTask.title = customizedTask.title.replace(/\[TECH\]/g, context.technology);
|
|
1170
|
-
customizedTask.description = customizedTask.description.replace(/\[TECH\]/g, context.technology);
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
if (context.urgency === 'high') {
|
|
1174
|
-
customizedTask.priority = customizedTask.priority === 'low' ? 'medium' :
|
|
1175
|
-
customizedTask.priority === 'medium' ? 'high' : 'urgent';
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
// Team size can affect priority rather than time estimates
|
|
1179
|
-
if (context.team === 'small' && customizedTask.priority === 'medium') {
|
|
1180
|
-
customizedTask.priority = 'high'; // Small teams need focused priorities
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
return customizedTask;
|
|
1184
|
-
});
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
* Create custom template from existing tasks or specification
|
|
1189
|
-
* @private
|
|
1190
|
-
*/
|
|
1191
|
-
async createCustomTemplate(agent, customTemplate) {
|
|
1192
|
-
const { name, description, category, tasks } = customTemplate;
|
|
1193
|
-
|
|
1194
|
-
if (!name || !tasks || tasks.length === 0) {
|
|
1195
|
-
throw new Error('Custom template requires name and at least one task');
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
const template = {
|
|
1199
|
-
id: `custom-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
1200
|
-
name,
|
|
1201
|
-
description: description || `Custom template: ${name}`,
|
|
1202
|
-
category: category || 'custom',
|
|
1203
|
-
tasks: tasks.map(task => ({
|
|
1204
|
-
title: task.title,
|
|
1205
|
-
description: task.description || '',
|
|
1206
|
-
priority: task.priority || 'medium',
|
|
1207
|
-
dependencies: task.dependencies || []
|
|
1208
|
-
})),
|
|
1209
|
-
createdAt: new Date().toISOString(),
|
|
1210
|
-
type: 'custom'
|
|
1211
|
-
};
|
|
1212
|
-
|
|
1213
|
-
// Initialize custom templates array if not exists
|
|
1214
|
-
if (!agent.customTemplates) {
|
|
1215
|
-
agent.customTemplates = [];
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
agent.customTemplates.push(template);
|
|
1219
|
-
|
|
1220
|
-
return {
|
|
1221
|
-
template: {
|
|
1222
|
-
id: template.id,
|
|
1223
|
-
name: template.name,
|
|
1224
|
-
description: template.description,
|
|
1225
|
-
category: template.category,
|
|
1226
|
-
taskCount: template.tasks.length
|
|
1227
|
-
},
|
|
1228
|
-
message: 'Custom template created successfully'
|
|
1229
|
-
};
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
/**
|
|
1233
|
-
* Suggest templates based on existing tasks and patterns
|
|
1234
|
-
* @private
|
|
1235
|
-
*/
|
|
1236
|
-
async suggestTemplates(agent) {
|
|
1237
|
-
const existingTasks = agent.taskList.tasks;
|
|
1238
|
-
const suggestions = [];
|
|
1239
|
-
|
|
1240
|
-
// Analyze existing task patterns
|
|
1241
|
-
const taskTitles = existingTasks.map(t => t.title.toLowerCase());
|
|
1242
|
-
const priorities = existingTasks.map(t => t.priority);
|
|
1243
|
-
|
|
1244
|
-
// Pattern-based suggestions
|
|
1245
|
-
if (taskTitles.some(title => title.includes('api') || title.includes('endpoint'))) {
|
|
1246
|
-
suggestions.push({
|
|
1247
|
-
templateId: 'api-integration',
|
|
1248
|
-
reason: 'Detected API-related tasks',
|
|
1249
|
-
confidence: 0.8
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
if (taskTitles.some(title => title.includes('bug') || title.includes('fix') || title.includes('error'))) {
|
|
1254
|
-
suggestions.push({
|
|
1255
|
-
templateId: 'bug-fix',
|
|
1256
|
-
reason: 'Detected bug fix tasks',
|
|
1257
|
-
confidence: 0.9
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
if (taskTitles.some(title => title.includes('feature') || title.includes('implement'))) {
|
|
1262
|
-
suggestions.push({
|
|
1263
|
-
templateId: 'feature-development',
|
|
1264
|
-
reason: 'Detected feature development tasks',
|
|
1265
|
-
confidence: 0.7
|
|
1266
|
-
});
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
if (existingTasks.length >= 5 && priorities.includes('high') && priorities.includes('medium')) {
|
|
1270
|
-
suggestions.push({
|
|
1271
|
-
templateId: 'web-app-development',
|
|
1272
|
-
reason: 'Large project with mixed priorities suggests web app development',
|
|
1273
|
-
confidence: 0.6
|
|
1274
|
-
});
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
// Enhance suggestions with template details
|
|
1278
|
-
const detailedSuggestions = suggestions.map(suggestion => {
|
|
1279
|
-
const template = this.taskTemplates[suggestion.templateId];
|
|
1280
|
-
return {
|
|
1281
|
-
...suggestion,
|
|
1282
|
-
templateName: template.name,
|
|
1283
|
-
templateDescription: template.description,
|
|
1284
|
-
taskCount: template.tasks.length
|
|
1285
|
-
};
|
|
1286
|
-
});
|
|
1287
|
-
|
|
1288
|
-
return {
|
|
1289
|
-
suggestions: detailedSuggestions,
|
|
1290
|
-
analysisResults: {
|
|
1291
|
-
existingTaskCount: existingTasks.length,
|
|
1292
|
-
dominantPriority: this.getMostCommonPriority(priorities),
|
|
1293
|
-
detectedPatterns: suggestions.map(s => s.reason)
|
|
1294
|
-
}
|
|
1295
|
-
};
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
/**
|
|
1299
|
-
* Generate workflow visualization for created tasks
|
|
1300
|
-
* @private
|
|
1301
|
-
*/
|
|
1302
|
-
generateWorkflowVisualization(tasks) {
|
|
1303
|
-
const workflow = {
|
|
1304
|
-
phases: [],
|
|
1305
|
-
criticalPath: [],
|
|
1306
|
-
parallelTasks: []
|
|
1307
|
-
};
|
|
1308
|
-
|
|
1309
|
-
// Group tasks by their dependency level
|
|
1310
|
-
const levels = new Map();
|
|
1311
|
-
const processedTasks = new Set();
|
|
1312
|
-
|
|
1313
|
-
// Find root tasks (no dependencies)
|
|
1314
|
-
const rootTasks = tasks.filter(task => !task.dependencies || task.dependencies.length === 0);
|
|
1315
|
-
rootTasks.forEach(task => {
|
|
1316
|
-
levels.set(0, (levels.get(0) || []).concat([task]));
|
|
1317
|
-
processedTasks.add(task.id);
|
|
1318
|
-
});
|
|
1319
|
-
|
|
1320
|
-
// Build dependency levels
|
|
1321
|
-
let currentLevel = 0;
|
|
1322
|
-
while (processedTasks.size < tasks.length && currentLevel < 10) {
|
|
1323
|
-
currentLevel++;
|
|
1324
|
-
const currentLevelTasks = [];
|
|
1325
|
-
|
|
1326
|
-
for (const task of tasks) {
|
|
1327
|
-
if (processedTasks.has(task.id)) continue;
|
|
1328
|
-
|
|
1329
|
-
if (task.dependencies && task.dependencies.every(dep => processedTasks.has(dep.taskId))) {
|
|
1330
|
-
currentLevelTasks.push(task);
|
|
1331
|
-
processedTasks.add(task.id);
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
if (currentLevelTasks.length > 0) {
|
|
1336
|
-
levels.set(currentLevel, currentLevelTasks);
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
// Convert levels to phases
|
|
1341
|
-
for (const [level, levelTasks] of levels.entries()) {
|
|
1342
|
-
workflow.phases.push({
|
|
1343
|
-
phase: level + 1,
|
|
1344
|
-
tasks: levelTasks.map(task => ({
|
|
1345
|
-
id: task.id,
|
|
1346
|
-
title: task.title,
|
|
1347
|
-
priority: task.priority
|
|
1348
|
-
})),
|
|
1349
|
-
taskCount: levelTasks.length,
|
|
1350
|
-
canRunInParallel: levelTasks.length > 1
|
|
1351
|
-
});
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
return workflow;
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
/**
|
|
1358
|
-
* Get most common priority from array
|
|
1359
|
-
* @private
|
|
1360
|
-
*/
|
|
1361
|
-
getMostCommonPriority(priorities) {
|
|
1362
|
-
if (priorities.length === 0) return 'medium';
|
|
1363
|
-
|
|
1364
|
-
const counts = priorities.reduce((acc, priority) => {
|
|
1365
|
-
acc[priority] = (acc[priority] || 0) + 1;
|
|
1366
|
-
return acc;
|
|
1367
|
-
}, {});
|
|
1368
|
-
|
|
1369
|
-
return Object.keys(counts).reduce((a, b) => counts[a] > counts[b] ? a : b);
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
/**
|
|
1373
|
-
* Progress tracking management (Phase 3.4)
|
|
1374
|
-
* @private
|
|
1375
|
-
*/
|
|
1376
|
-
async trackProgress(agent, params) {
|
|
1377
|
-
const { mode = 'update', taskId, stage, milestone, note, percentage } = params;
|
|
1378
|
-
|
|
1379
|
-
let results = {};
|
|
1380
|
-
|
|
1381
|
-
if (mode === 'update' && taskId) {
|
|
1382
|
-
// Update progress for specific task
|
|
1383
|
-
results = await this.updateTaskProgress(agent, taskId, { stage, milestone, note, percentage });
|
|
1384
|
-
} else if (mode === 'overview') {
|
|
1385
|
-
// Get progress overview for all tasks
|
|
1386
|
-
results = await this.getProgressOverview(agent);
|
|
1387
|
-
} else if (mode === 'milestones' && taskId) {
|
|
1388
|
-
// Manage milestones for specific task
|
|
1389
|
-
results = await this.manageMilestones(agent, taskId, params);
|
|
1390
|
-
} else if (mode === 'calculate') {
|
|
1391
|
-
// Calculate progress based on subtasks and dependencies
|
|
1392
|
-
results = await this.calculateTaskProgress(agent, taskId);
|
|
1393
|
-
} else {
|
|
1394
|
-
throw new Error('Invalid progress mode. Use: update, overview, milestones, or calculate');
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
return {
|
|
1398
|
-
message: `Progress tracking completed (${mode})`,
|
|
1399
|
-
mode,
|
|
1400
|
-
...results
|
|
1401
|
-
};
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
/**
|
|
1405
|
-
* Update progress for a specific task
|
|
1406
|
-
* @private
|
|
1407
|
-
*/
|
|
1408
|
-
async updateTaskProgress(agent, taskId, progressData) {
|
|
1409
|
-
const task = agent.taskList.tasks.find(t => t.id === taskId);
|
|
1410
|
-
if (!task) {
|
|
1411
|
-
throw new Error(`Task not found: ${taskId}`);
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
// Initialize progress tracking if not exists
|
|
1415
|
-
if (!task.progress) {
|
|
1416
|
-
task.progress = {
|
|
1417
|
-
stage: 'not_started',
|
|
1418
|
-
percentage: 0,
|
|
1419
|
-
milestones: [],
|
|
1420
|
-
notes: [],
|
|
1421
|
-
stageHistory: []
|
|
1422
|
-
};
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
const oldStage = task.progress.stage;
|
|
1426
|
-
|
|
1427
|
-
// Update stage if provided
|
|
1428
|
-
if (progressData.stage) {
|
|
1429
|
-
if (!this.progressStages.includes(progressData.stage)) {
|
|
1430
|
-
throw new Error(`Invalid progress stage: ${progressData.stage}. Must be: ${this.progressStages.join(', ')}`);
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
task.progress.stage = progressData.stage;
|
|
1434
|
-
|
|
1435
|
-
// Track stage changes
|
|
1436
|
-
task.progress.stageHistory.push({
|
|
1437
|
-
from: oldStage,
|
|
1438
|
-
to: progressData.stage,
|
|
1439
|
-
timestamp: new Date().toISOString()
|
|
1440
|
-
});
|
|
1441
|
-
|
|
1442
|
-
// Auto-update task status based on stage
|
|
1443
|
-
if (progressData.stage === 'not_started' && task.status === 'in_progress') {
|
|
1444
|
-
task.status = 'pending';
|
|
1445
|
-
} else if (['planning', 'in_development', 'testing', 'review'].includes(progressData.stage) && task.status === 'pending') {
|
|
1446
|
-
task.status = 'in_progress';
|
|
1447
|
-
} else if (progressData.stage === 'completed' && task.status !== 'completed') {
|
|
1448
|
-
task.status = 'completed';
|
|
1449
|
-
task.completedAt = new Date().toISOString();
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
// Update percentage if provided
|
|
1454
|
-
if (progressData.percentage !== undefined) {
|
|
1455
|
-
const percent = Math.max(0, Math.min(100, parseInt(progressData.percentage)));
|
|
1456
|
-
task.progress.percentage = percent;
|
|
1457
|
-
|
|
1458
|
-
// Auto-update stage based on percentage
|
|
1459
|
-
if (percent === 0 && task.progress.stage !== 'not_started') {
|
|
1460
|
-
task.progress.stage = 'not_started';
|
|
1461
|
-
} else if (percent > 0 && percent < 25 && task.progress.stage === 'not_started') {
|
|
1462
|
-
task.progress.stage = 'planning';
|
|
1463
|
-
} else if (percent >= 25 && percent < 75 && ['not_started', 'planning'].includes(task.progress.stage)) {
|
|
1464
|
-
task.progress.stage = 'in_development';
|
|
1465
|
-
} else if (percent >= 75 && percent < 95 && task.progress.stage !== 'testing') {
|
|
1466
|
-
task.progress.stage = 'testing';
|
|
1467
|
-
} else if (percent >= 95 && percent < 100 && task.progress.stage !== 'review') {
|
|
1468
|
-
task.progress.stage = 'review';
|
|
1469
|
-
} else if (percent === 100) {
|
|
1470
|
-
task.progress.stage = 'completed';
|
|
1471
|
-
task.status = 'completed';
|
|
1472
|
-
task.completedAt = new Date().toISOString();
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
// Add milestone if provided
|
|
1477
|
-
if (progressData.milestone) {
|
|
1478
|
-
const milestone = {
|
|
1479
|
-
id: `milestone-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
1480
|
-
type: progressData.milestone.type || 'checkpoint',
|
|
1481
|
-
title: progressData.milestone.title || 'Progress Milestone',
|
|
1482
|
-
description: progressData.milestone.description || '',
|
|
1483
|
-
achievedAt: new Date().toISOString(),
|
|
1484
|
-
stage: task.progress.stage
|
|
1485
|
-
};
|
|
1486
|
-
|
|
1487
|
-
task.progress.milestones.push(milestone);
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
// Add progress note if provided
|
|
1491
|
-
if (progressData.note) {
|
|
1492
|
-
task.progress.notes.push({
|
|
1493
|
-
id: `note-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
1494
|
-
content: progressData.note,
|
|
1495
|
-
timestamp: new Date().toISOString(),
|
|
1496
|
-
stage: task.progress.stage
|
|
1497
|
-
});
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
task.updatedAt = new Date().toISOString();
|
|
1501
|
-
|
|
1502
|
-
// Calculate progress for parent task if this is a subtask
|
|
1503
|
-
if (task.parentTaskId) {
|
|
1504
|
-
await this.calculateTaskProgress(agent, task.parentTaskId);
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
return {
|
|
1508
|
-
task: {
|
|
1509
|
-
id: task.id,
|
|
1510
|
-
title: task.title,
|
|
1511
|
-
status: task.status,
|
|
1512
|
-
progress: task.progress
|
|
1513
|
-
},
|
|
1514
|
-
changes: {
|
|
1515
|
-
stageChanged: oldStage !== task.progress.stage,
|
|
1516
|
-
oldStage,
|
|
1517
|
-
newStage: task.progress.stage,
|
|
1518
|
-
milestoneAdded: !!progressData.milestone,
|
|
1519
|
-
noteAdded: !!progressData.note
|
|
1520
|
-
}
|
|
1521
|
-
};
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
/**
|
|
1525
|
-
* Get progress overview for all tasks
|
|
1526
|
-
* @private
|
|
1527
|
-
*/
|
|
1528
|
-
async getProgressOverview(agent) {
|
|
1529
|
-
const tasks = agent.taskList.tasks;
|
|
1530
|
-
const taskProgress = tasks.map(task => {
|
|
1531
|
-
const progress = task.progress || { stage: 'not_started', percentage: 0, milestones: [], notes: [] };
|
|
1532
|
-
|
|
1533
|
-
return {
|
|
1534
|
-
id: task.id,
|
|
1535
|
-
title: task.title,
|
|
1536
|
-
status: task.status,
|
|
1537
|
-
priority: task.priority,
|
|
1538
|
-
stage: progress.stage,
|
|
1539
|
-
percentage: progress.percentage,
|
|
1540
|
-
milestoneCount: progress.milestones ? progress.milestones.length : 0,
|
|
1541
|
-
isBlocked: task.status === 'blocked',
|
|
1542
|
-
hasSubtasks: !!(task.subtasks && task.subtasks.length > 0),
|
|
1543
|
-
parentTaskId: task.parentTaskId
|
|
1544
|
-
};
|
|
1545
|
-
});
|
|
1546
|
-
|
|
1547
|
-
// Calculate overall statistics
|
|
1548
|
-
const stats = {
|
|
1549
|
-
totalTasks: tasks.length,
|
|
1550
|
-
byStage: {},
|
|
1551
|
-
byStatus: {},
|
|
1552
|
-
averageProgress: 0,
|
|
1553
|
-
blockedTasks: 0,
|
|
1554
|
-
completedTasks: 0
|
|
1555
|
-
};
|
|
1556
|
-
|
|
1557
|
-
this.progressStages.forEach(stage => {
|
|
1558
|
-
stats.byStage[stage] = taskProgress.filter(t => t.stage === stage).length;
|
|
1559
|
-
});
|
|
1560
|
-
|
|
1561
|
-
this.taskStatuses.forEach(status => {
|
|
1562
|
-
stats.byStatus[status] = taskProgress.filter(t => t.status === status).length;
|
|
1563
|
-
});
|
|
1564
|
-
|
|
1565
|
-
stats.averageProgress = tasks.length > 0 ?
|
|
1566
|
-
Math.round(taskProgress.reduce((sum, t) => sum + t.percentage, 0) / tasks.length) : 0;
|
|
1567
|
-
|
|
1568
|
-
stats.blockedTasks = stats.byStatus.blocked || 0;
|
|
1569
|
-
stats.completedTasks = stats.byStatus.completed || 0;
|
|
1570
|
-
|
|
1571
|
-
// Find critical path and bottlenecks
|
|
1572
|
-
const criticalTasks = taskProgress.filter(t =>
|
|
1573
|
-
t.priority === 'urgent' && t.status !== 'completed'
|
|
1574
|
-
);
|
|
1575
|
-
|
|
1576
|
-
const bottlenecks = taskProgress.filter(t =>
|
|
1577
|
-
t.isBlocked && this.findTasksBlockedBy(t.id, tasks).length > 0
|
|
1578
|
-
);
|
|
1579
|
-
|
|
1580
|
-
return {
|
|
1581
|
-
overview: stats,
|
|
1582
|
-
tasks: taskProgress,
|
|
1583
|
-
criticalTasks,
|
|
1584
|
-
bottlenecks: bottlenecks.map(t => ({
|
|
1585
|
-
taskId: t.id,
|
|
1586
|
-
title: t.title,
|
|
1587
|
-
blockedTasksCount: this.findTasksBlockedBy(t.id, tasks).length
|
|
1588
|
-
})),
|
|
1589
|
-
recommendations: this.generateProgressRecommendations(taskProgress, stats)
|
|
1590
|
-
};
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
/**
|
|
1594
|
-
* Calculate task progress based on subtasks and dependencies
|
|
1595
|
-
* @private
|
|
1596
|
-
*/
|
|
1597
|
-
async calculateTaskProgress(agent, taskId) {
|
|
1598
|
-
const task = agent.taskList.tasks.find(t => t.id === taskId);
|
|
1599
|
-
if (!task) {
|
|
1600
|
-
throw new Error(`Task not found: ${taskId}`);
|
|
1601
|
-
}
|
|
1602
|
-
|
|
1603
|
-
// Initialize progress if not exists
|
|
1604
|
-
if (!task.progress) {
|
|
1605
|
-
task.progress = {
|
|
1606
|
-
stage: 'not_started',
|
|
1607
|
-
percentage: 0,
|
|
1608
|
-
milestones: [],
|
|
1609
|
-
notes: [],
|
|
1610
|
-
stageHistory: []
|
|
1611
|
-
};
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
let calculatedPercentage = 0;
|
|
1615
|
-
let calculationMethod = 'manual';
|
|
1616
|
-
|
|
1617
|
-
// Calculate based on subtasks if they exist
|
|
1618
|
-
if (task.subtasks && task.subtasks.length > 0) {
|
|
1619
|
-
const subtasks = task.subtasks.map(subtaskId =>
|
|
1620
|
-
agent.taskList.tasks.find(t => t.id === subtaskId)
|
|
1621
|
-
).filter(Boolean);
|
|
1622
|
-
|
|
1623
|
-
if (subtasks.length > 0) {
|
|
1624
|
-
const subtaskProgress = subtasks.map(subtask => {
|
|
1625
|
-
if (subtask.status === 'completed') return 100;
|
|
1626
|
-
if (subtask.progress && subtask.progress.percentage !== undefined) {
|
|
1627
|
-
return subtask.progress.percentage;
|
|
1628
|
-
}
|
|
1629
|
-
return subtask.status === 'in_progress' ? 25 : 0;
|
|
1630
|
-
});
|
|
1631
|
-
|
|
1632
|
-
calculatedPercentage = Math.round(
|
|
1633
|
-
subtaskProgress.reduce((sum, p) => sum + p, 0) / subtasks.length
|
|
1634
|
-
);
|
|
1635
|
-
calculationMethod = 'subtasks';
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
// If no subtasks, calculate based on dependencies completion
|
|
1640
|
-
else if (task.dependencies && task.dependencies.length > 0) {
|
|
1641
|
-
const completedDeps = task.dependencies.filter(dep => {
|
|
1642
|
-
const depTask = agent.taskList.tasks.find(t => t.id === dep.taskId);
|
|
1643
|
-
return depTask && depTask.status === 'completed';
|
|
1644
|
-
}).length;
|
|
1645
|
-
|
|
1646
|
-
const depProgress = (completedDeps / task.dependencies.length) * 30; // Dependencies contribute 30%
|
|
1647
|
-
const ownProgress = task.status === 'completed' ? 70 :
|
|
1648
|
-
task.status === 'in_progress' ? 35 : 0; // Own progress contributes 70%
|
|
1649
|
-
|
|
1650
|
-
calculatedPercentage = Math.round(depProgress + ownProgress);
|
|
1651
|
-
calculationMethod = 'dependencies';
|
|
1652
|
-
}
|
|
1653
|
-
|
|
1654
|
-
// Fallback to status-based calculation
|
|
1655
|
-
else {
|
|
1656
|
-
if (task.status === 'completed') calculatedPercentage = 100;
|
|
1657
|
-
else if (task.status === 'in_progress') calculatedPercentage = task.progress.percentage || 50;
|
|
1658
|
-
else if (task.status === 'pending') calculatedPercentage = 0;
|
|
1659
|
-
else if (task.status === 'blocked') calculatedPercentage = task.progress.percentage || 0;
|
|
1660
|
-
|
|
1661
|
-
calculationMethod = 'status';
|
|
1662
|
-
}
|
|
1663
|
-
|
|
1664
|
-
// Update the task's calculated progress
|
|
1665
|
-
task.progress.calculatedPercentage = calculatedPercentage;
|
|
1666
|
-
task.progress.calculationMethod = calculationMethod;
|
|
1667
|
-
task.progress.lastCalculated = new Date().toISOString();
|
|
1668
|
-
|
|
1669
|
-
// Auto-update stage based on calculated percentage if no manual stage set recently
|
|
1670
|
-
const recentStageUpdate = task.progress.stageHistory.length > 0 &&
|
|
1671
|
-
(Date.now() - new Date(task.progress.stageHistory[task.progress.stageHistory.length - 1].timestamp).getTime()) < 300000; // 5 minutes
|
|
1672
|
-
|
|
1673
|
-
if (!recentStageUpdate) {
|
|
1674
|
-
const autoStage = this.getStageFromPercentage(calculatedPercentage);
|
|
1675
|
-
if (autoStage !== task.progress.stage) {
|
|
1676
|
-
task.progress.stage = autoStage;
|
|
1677
|
-
task.progress.stageHistory.push({
|
|
1678
|
-
from: task.progress.stage,
|
|
1679
|
-
to: autoStage,
|
|
1680
|
-
timestamp: new Date().toISOString(),
|
|
1681
|
-
automatic: true
|
|
1682
|
-
});
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
task.updatedAt = new Date().toISOString();
|
|
1687
|
-
|
|
1688
|
-
return {
|
|
1689
|
-
taskId: task.id,
|
|
1690
|
-
title: task.title,
|
|
1691
|
-
calculatedPercentage,
|
|
1692
|
-
calculationMethod,
|
|
1693
|
-
manualPercentage: task.progress.percentage,
|
|
1694
|
-
stage: task.progress.stage,
|
|
1695
|
-
subtaskCount: task.subtasks ? task.subtasks.length : 0,
|
|
1696
|
-
dependencyCount: task.dependencies ? task.dependencies.length : 0
|
|
1697
|
-
};
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
|
-
/**
|
|
1701
|
-
* Generate progress recommendations
|
|
1702
|
-
* @private
|
|
1703
|
-
*/
|
|
1704
|
-
generateProgressRecommendations(taskProgress, stats) {
|
|
1705
|
-
const recommendations = [];
|
|
1706
|
-
|
|
1707
|
-
// Blocked task recommendations
|
|
1708
|
-
if (stats.blockedTasks > 0) {
|
|
1709
|
-
recommendations.push({
|
|
1710
|
-
type: 'urgent',
|
|
1711
|
-
category: 'blocked_tasks',
|
|
1712
|
-
message: `${stats.blockedTasks} tasks are blocked. Review dependencies to unblock progress.`,
|
|
1713
|
-
actionable: true
|
|
1714
|
-
});
|
|
1715
|
-
}
|
|
1716
|
-
|
|
1717
|
-
// Stalled task recommendations
|
|
1718
|
-
const stalledTasks = taskProgress.filter(t =>
|
|
1719
|
-
t.status === 'in_progress' && t.percentage < 25
|
|
1720
|
-
);
|
|
1721
|
-
|
|
1722
|
-
if (stalledTasks.length > 0) {
|
|
1723
|
-
recommendations.push({
|
|
1724
|
-
type: 'warning',
|
|
1725
|
-
category: 'stalled_progress',
|
|
1726
|
-
message: `${stalledTasks.length} tasks are in progress but showing low progress. Consider breaking them into smaller subtasks.`,
|
|
1727
|
-
actionable: true
|
|
1728
|
-
});
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
// High progress tasks ready for completion
|
|
1732
|
-
const nearCompletionTasks = taskProgress.filter(t =>
|
|
1733
|
-
t.percentage >= 90 && t.status !== 'completed'
|
|
1734
|
-
);
|
|
1735
|
-
|
|
1736
|
-
if (nearCompletionTasks.length > 0) {
|
|
1737
|
-
recommendations.push({
|
|
1738
|
-
type: 'success',
|
|
1739
|
-
category: 'near_completion',
|
|
1740
|
-
message: `${nearCompletionTasks.length} tasks are near completion. Focus on finishing these for quick wins.`,
|
|
1741
|
-
actionable: true
|
|
1742
|
-
});
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
// Overall progress recommendations
|
|
1746
|
-
if (stats.averageProgress < 25) {
|
|
1747
|
-
recommendations.push({
|
|
1748
|
-
type: 'info',
|
|
1749
|
-
category: 'overall_progress',
|
|
1750
|
-
message: 'Overall progress is low. Consider prioritizing and focusing on fewer tasks.',
|
|
1751
|
-
actionable: false
|
|
1752
|
-
});
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
|
-
return recommendations;
|
|
1756
|
-
}
|
|
1757
|
-
|
|
1758
|
-
/**
|
|
1759
|
-
* Get stage from percentage
|
|
1760
|
-
* @private
|
|
1761
|
-
*/
|
|
1762
|
-
getStageFromPercentage(percentage) {
|
|
1763
|
-
if (percentage === 0) return 'not_started';
|
|
1764
|
-
if (percentage < 25) return 'planning';
|
|
1765
|
-
if (percentage < 75) return 'in_development';
|
|
1766
|
-
if (percentage < 95) return 'testing';
|
|
1767
|
-
if (percentage < 100) return 'review';
|
|
1768
|
-
return 'completed';
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
/**
|
|
1772
|
-
* Set scheduler reference for dependency management (Phase 3)
|
|
1773
|
-
* @param {Object} scheduler - AgentScheduler instance
|
|
1774
|
-
*/
|
|
1775
|
-
setScheduler(scheduler) {
|
|
1776
|
-
this.scheduler = scheduler;
|
|
1777
|
-
this.logger?.info('TaskManagerTool: Scheduler dependency injected');
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
/**
|
|
1781
|
-
* Intelligent task prioritization (Phase 3.2)
|
|
1782
|
-
* @private
|
|
1783
|
-
*/
|
|
1784
|
-
async intelligentPrioritization(agent, params) {
|
|
1785
|
-
const { mode = 'auto', taskId } = params;
|
|
1786
|
-
|
|
1787
|
-
let results = {};
|
|
1788
|
-
|
|
1789
|
-
if (mode === 'auto') {
|
|
1790
|
-
// Auto-prioritize all tasks
|
|
1791
|
-
results = await this.autoPrioritizeAllTasks(agent);
|
|
1792
|
-
} else if (mode === 'analyze' && taskId) {
|
|
1793
|
-
// Analyze specific task priority
|
|
1794
|
-
results = await this.analyzeTaskPriority(agent, taskId);
|
|
1795
|
-
} else if (mode === 'balance') {
|
|
1796
|
-
// Balance priorities across all agents
|
|
1797
|
-
results = await this.balanceCrossAgentPriorities(agent);
|
|
1798
|
-
} else {
|
|
1799
|
-
throw new Error('Invalid prioritization mode. Use: auto, analyze, or balance');
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
return {
|
|
1803
|
-
message: `Intelligent prioritization completed (${mode})`,
|
|
1804
|
-
mode,
|
|
1805
|
-
...results
|
|
1806
|
-
};
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
/**
|
|
1810
|
-
* Auto-prioritize all tasks using intelligent scoring
|
|
1811
|
-
* @private
|
|
1812
|
-
*/
|
|
1813
|
-
async autoPrioritizeAllTasks(agent) {
|
|
1814
|
-
const tasks = agent.taskList.tasks.filter(t =>
|
|
1815
|
-
t.status === 'pending' || t.status === 'in_progress'
|
|
1816
|
-
);
|
|
1817
|
-
|
|
1818
|
-
if (tasks.length === 0) {
|
|
1819
|
-
return { message: 'No active tasks to prioritize' };
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
// Calculate priority scores for all tasks
|
|
1823
|
-
const tasksWithScores = tasks.map(task => ({
|
|
1824
|
-
...task,
|
|
1825
|
-
priorityScore: this.calculatePriorityScore(task, agent.taskList.tasks),
|
|
1826
|
-
originalPriority: task.priority
|
|
1827
|
-
}));
|
|
1828
|
-
|
|
1829
|
-
// Sort by priority score (higher = more important)
|
|
1830
|
-
tasksWithScores.sort((a, b) => b.priorityScore - a.priorityScore);
|
|
1831
|
-
|
|
1832
|
-
// Assign new priorities based on scores
|
|
1833
|
-
const priorityMapping = ['urgent', 'high', 'medium', 'low'];
|
|
1834
|
-
const updatedTasks = [];
|
|
1835
|
-
|
|
1836
|
-
tasksWithScores.forEach((task, index) => {
|
|
1837
|
-
const newPriorityIndex = Math.min(
|
|
1838
|
-
Math.floor(index / Math.max(1, tasks.length / 4)),
|
|
1839
|
-
priorityMapping.length - 1
|
|
1840
|
-
);
|
|
1841
|
-
const newPriority = priorityMapping[newPriorityIndex];
|
|
1842
|
-
|
|
1843
|
-
if (task.originalPriority !== newPriority) {
|
|
1844
|
-
const originalTask = agent.taskList.tasks.find(t => t.id === task.id);
|
|
1845
|
-
originalTask.priority = newPriority;
|
|
1846
|
-
originalTask.updatedAt = new Date().toISOString();
|
|
1847
|
-
originalTask.priorityScore = task.priorityScore;
|
|
1848
|
-
originalTask.priorityReason = this.generatePriorityReason(task);
|
|
1849
|
-
|
|
1850
|
-
updatedTasks.push({
|
|
1851
|
-
id: task.id,
|
|
1852
|
-
title: task.title,
|
|
1853
|
-
oldPriority: task.originalPriority,
|
|
1854
|
-
newPriority: newPriority,
|
|
1855
|
-
score: task.priorityScore.toFixed(2),
|
|
1856
|
-
reason: originalTask.priorityReason
|
|
1857
|
-
});
|
|
1858
|
-
}
|
|
1859
|
-
});
|
|
1860
|
-
|
|
1861
|
-
return {
|
|
1862
|
-
totalTasks: tasks.length,
|
|
1863
|
-
updatedTasks: updatedTasks.length,
|
|
1864
|
-
changes: updatedTasks
|
|
1865
|
-
};
|
|
1866
|
-
}
|
|
1867
|
-
|
|
1868
|
-
/**
|
|
1869
|
-
* Calculate intelligent priority score for a task
|
|
1870
|
-
* @private
|
|
1871
|
-
*/
|
|
1872
|
-
calculatePriorityScore(task, allTasks) {
|
|
1873
|
-
let score = 0;
|
|
1874
|
-
|
|
1875
|
-
// Base user priority score
|
|
1876
|
-
const priorityScores = { urgent: 4, high: 3, medium: 2, low: 1 };
|
|
1877
|
-
score += priorityScores[task.priority] * this.priorityWeights.userPriority;
|
|
1878
|
-
|
|
1879
|
-
// Age factor (older tasks get higher priority)
|
|
1880
|
-
const ageHours = (Date.now() - new Date(task.createdAt).getTime()) / (1000 * 60 * 60);
|
|
1881
|
-
score += Math.min(ageHours / 24, 3) * this.priorityWeights.age;
|
|
1882
|
-
|
|
1883
|
-
// Blocking factor (tasks that block others get higher priority)
|
|
1884
|
-
const blockedTasks = this.findTasksBlockedBy(task.id, allTasks);
|
|
1885
|
-
score += blockedTasks.length * this.priorityWeights.blocking;
|
|
1886
|
-
|
|
1887
|
-
// Dependency complexity factor
|
|
1888
|
-
const dependencyCount = (task.dependencies || []).length;
|
|
1889
|
-
score += Math.min(dependencyCount, 3) * this.priorityWeights.dependency;
|
|
1890
|
-
|
|
1891
|
-
// Subtask factor (parent tasks with many subtasks get higher priority)
|
|
1892
|
-
const subtaskCount = (task.subtasks || []).length;
|
|
1893
|
-
score += Math.min(subtaskCount, 2) * this.priorityWeights.dependency;
|
|
1894
|
-
|
|
1895
|
-
return score;
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
/**
|
|
1899
|
-
* Find tasks that are blocked by the given task
|
|
1900
|
-
* @private
|
|
1901
|
-
*/
|
|
1902
|
-
findTasksBlockedBy(taskId, allTasks) {
|
|
1903
|
-
return allTasks.filter(task => {
|
|
1904
|
-
if (!task.dependencies) return false;
|
|
1905
|
-
return task.dependencies.some(dep =>
|
|
1906
|
-
dep.taskId === taskId && dep.type === 'blocks'
|
|
1907
|
-
);
|
|
1908
|
-
});
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
|
-
/**
|
|
1912
|
-
* Generate human-readable priority reason
|
|
1913
|
-
* @private
|
|
1914
|
-
*/
|
|
1915
|
-
generatePriorityReason(task) {
|
|
1916
|
-
const reasons = [];
|
|
1917
|
-
|
|
1918
|
-
if (task.priorityScore > 8) {
|
|
1919
|
-
reasons.push('high overall impact');
|
|
1920
|
-
}
|
|
1921
|
-
|
|
1922
|
-
const ageHours = (Date.now() - new Date(task.createdAt).getTime()) / (1000 * 60 * 60);
|
|
1923
|
-
if (ageHours > 24) {
|
|
1924
|
-
reasons.push('overdue task');
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
if (task.priority === 'urgent') {
|
|
1928
|
-
reasons.push('user-marked urgent');
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
if ((task.subtasks || []).length > 0) {
|
|
1932
|
-
reasons.push('has subtasks');
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
return reasons.length > 0 ? reasons.join(', ') : 'standard prioritization';
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
/**
|
|
1939
|
-
* Analyze priority of a specific task
|
|
1940
|
-
* @private
|
|
1941
|
-
*/
|
|
1942
|
-
async analyzeTaskPriority(agent, taskId) {
|
|
1943
|
-
const task = agent.taskList.tasks.find(t => t.id === taskId);
|
|
1944
|
-
if (!task) {
|
|
1945
|
-
throw new Error(`Task not found: ${taskId}`);
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
const score = this.calculatePriorityScore(task, agent.taskList.tasks);
|
|
1949
|
-
const blockedTasks = this.findTasksBlockedBy(taskId, agent.taskList.tasks);
|
|
1950
|
-
const reason = this.generatePriorityReason({ ...task, priorityScore: score });
|
|
1951
|
-
|
|
1952
|
-
return {
|
|
1953
|
-
task: {
|
|
1954
|
-
id: task.id,
|
|
1955
|
-
title: task.title,
|
|
1956
|
-
currentPriority: task.priority,
|
|
1957
|
-
priorityScore: score.toFixed(2),
|
|
1958
|
-
reason
|
|
1959
|
-
},
|
|
1960
|
-
analysis: {
|
|
1961
|
-
blocksOtherTasks: blockedTasks.length,
|
|
1962
|
-
ageInHours: ((Date.now() - new Date(task.createdAt).getTime()) / (1000 * 60 * 60)).toFixed(1),
|
|
1963
|
-
dependencyCount: (task.dependencies || []).length,
|
|
1964
|
-
subtaskCount: (task.subtasks || []).length
|
|
1965
|
-
},
|
|
1966
|
-
blockedTasks: blockedTasks.map(t => ({ id: t.id, title: t.title }))
|
|
1967
|
-
};
|
|
1968
|
-
}
|
|
1969
|
-
|
|
1970
|
-
/**
|
|
1971
|
-
* Balance priorities across all agents (requires scheduler)
|
|
1972
|
-
* @private
|
|
1973
|
-
*/
|
|
1974
|
-
async balanceCrossAgentPriorities(agent) {
|
|
1975
|
-
if (!this.scheduler || typeof this.scheduler.getAllAgents !== 'function') {
|
|
1976
|
-
return { message: 'Cross-agent balancing requires scheduler integration' };
|
|
1977
|
-
}
|
|
1978
|
-
|
|
1979
|
-
try {
|
|
1980
|
-
const allAgents = await this.scheduler.getAllAgents();
|
|
1981
|
-
const agentWorkloads = [];
|
|
1982
|
-
|
|
1983
|
-
allAgents.forEach(ag => {
|
|
1984
|
-
if (ag.taskList && ag.taskList.tasks) {
|
|
1985
|
-
const activeTasks = ag.taskList.tasks.filter(t =>
|
|
1986
|
-
t.status === 'pending' || t.status === 'in_progress'
|
|
1987
|
-
);
|
|
1988
|
-
const urgentTasks = activeTasks.filter(t => t.priority === 'urgent').length;
|
|
1989
|
-
const highTasks = activeTasks.filter(t => t.priority === 'high').length;
|
|
1990
|
-
|
|
1991
|
-
agentWorkloads.push({
|
|
1992
|
-
agentId: ag.id,
|
|
1993
|
-
agentName: ag.name,
|
|
1994
|
-
totalActive: activeTasks.length,
|
|
1995
|
-
urgent: urgentTasks,
|
|
1996
|
-
high: highTasks,
|
|
1997
|
-
workloadScore: urgentTasks * 3 + highTasks * 2 + activeTasks.length
|
|
1998
|
-
});
|
|
1999
|
-
}
|
|
2000
|
-
});
|
|
2001
|
-
|
|
2002
|
-
// Sort by workload (lowest first)
|
|
2003
|
-
agentWorkloads.sort((a, b) => a.workloadScore - b.workloadScore);
|
|
2004
|
-
|
|
2005
|
-
return {
|
|
2006
|
-
currentAgent: {
|
|
2007
|
-
agentId: agent.id,
|
|
2008
|
-
rank: agentWorkloads.findIndex(a => a.agentId === agent.id) + 1,
|
|
2009
|
-
totalAgents: agentWorkloads.length
|
|
2010
|
-
},
|
|
2011
|
-
workloadDistribution: agentWorkloads,
|
|
2012
|
-
recommendation: this.generateBalancingRecommendation(agent, agentWorkloads)
|
|
2013
|
-
};
|
|
2014
|
-
} catch (error) {
|
|
2015
|
-
return {
|
|
2016
|
-
error: `Cross-agent balancing failed: ${error.message}`,
|
|
2017
|
-
fallback: 'Using single-agent prioritization'
|
|
2018
|
-
};
|
|
2019
|
-
}
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
/**
|
|
2023
|
-
* Generate workload balancing recommendation
|
|
2024
|
-
* @private
|
|
2025
|
-
*/
|
|
2026
|
-
generateBalancingRecommendation(currentAgent, workloads) {
|
|
2027
|
-
const current = workloads.find(w => w.agentId === currentAgent.id);
|
|
2028
|
-
if (!current) return 'No recommendation available';
|
|
2029
|
-
|
|
2030
|
-
const avgWorkload = workloads.reduce((sum, w) => sum + w.workloadScore, 0) / workloads.length;
|
|
2031
|
-
|
|
2032
|
-
if (current.workloadScore > avgWorkload * 1.5) {
|
|
2033
|
-
return 'Consider delegating some tasks to less busy agents';
|
|
2034
|
-
} else if (current.workloadScore < avgWorkload * 0.5) {
|
|
2035
|
-
return 'Agent has capacity for additional high-priority tasks';
|
|
2036
|
-
} else {
|
|
2037
|
-
return 'Workload is well balanced';
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2041
|
-
/**
|
|
2042
|
-
* Generate task summary
|
|
2043
|
-
* @private
|
|
2044
|
-
*/
|
|
2045
|
-
generateTaskSummary(taskList) {
|
|
2046
|
-
const tasks = taskList.tasks;
|
|
2047
|
-
return {
|
|
2048
|
-
total: tasks.length,
|
|
2049
|
-
pending: tasks.filter(t => t.status === 'pending').length,
|
|
2050
|
-
in_progress: tasks.filter(t => t.status === 'in_progress').length,
|
|
2051
|
-
completed: tasks.filter(t => t.status === 'completed').length,
|
|
2052
|
-
cancelled: tasks.filter(t => t.status === 'cancelled').length,
|
|
2053
|
-
high_priority: tasks.filter(t => t.priority === 'high' && (t.status === 'pending' || t.status === 'in_progress')).length
|
|
2054
|
-
};
|
|
2055
|
-
}
|
|
2056
|
-
|
|
2057
|
-
/**
|
|
2058
|
-
* Phase 3.5: Generate task analytics and reporting
|
|
2059
|
-
* @private
|
|
2060
|
-
*/
|
|
2061
|
-
async generateAnalytics(agent, params) {
|
|
2062
|
-
const { mode = 'summary', timeframe = '30', reportType = 'comprehensive', agentId } = params;
|
|
2063
|
-
|
|
2064
|
-
let results = {};
|
|
2065
|
-
|
|
2066
|
-
switch (mode) {
|
|
2067
|
-
case 'summary':
|
|
2068
|
-
results = await this.getAnalyticsSummary(agent, timeframe);
|
|
2069
|
-
break;
|
|
2070
|
-
case 'performance':
|
|
2071
|
-
results = await this.getPerformanceMetrics(agent, timeframe);
|
|
2072
|
-
break;
|
|
2073
|
-
case 'trends':
|
|
2074
|
-
results = await this.getTrendAnalysis(agent, timeframe);
|
|
2075
|
-
break;
|
|
2076
|
-
case 'team':
|
|
2077
|
-
results = await this.getTeamAnalytics(timeframe);
|
|
2078
|
-
break;
|
|
2079
|
-
case 'export':
|
|
2080
|
-
results = await this.exportAnalytics(agent, params);
|
|
2081
|
-
break;
|
|
2082
|
-
case 'insights':
|
|
2083
|
-
results = await this.generateInsights(agent, timeframe);
|
|
2084
|
-
break;
|
|
2085
|
-
default:
|
|
2086
|
-
throw new Error('Invalid analytics mode. Use: summary, performance, trends, team, export, or insights');
|
|
2087
|
-
}
|
|
2088
|
-
|
|
2089
|
-
return {
|
|
2090
|
-
message: `Analytics report generated (${mode})`,
|
|
2091
|
-
mode,
|
|
2092
|
-
timeframe,
|
|
2093
|
-
generatedAt: new Date().toISOString(),
|
|
2094
|
-
...results
|
|
2095
|
-
};
|
|
2096
|
-
}
|
|
2097
|
-
|
|
2098
|
-
/**
|
|
2099
|
-
* Get comprehensive analytics summary
|
|
2100
|
-
* @private
|
|
2101
|
-
*/
|
|
2102
|
-
async getAnalyticsSummary(agent, timeframe) {
|
|
2103
|
-
const tasks = agent.taskList.tasks;
|
|
2104
|
-
const cutoffDate = new Date(Date.now() - parseInt(timeframe) * 24 * 60 * 60 * 1000);
|
|
2105
|
-
|
|
2106
|
-
// Filter tasks within timeframe
|
|
2107
|
-
const timeframeTasks = tasks.filter(t => new Date(t.createdAt) >= cutoffDate);
|
|
2108
|
-
|
|
2109
|
-
const summary = {
|
|
2110
|
-
overview: {
|
|
2111
|
-
totalTasks: timeframeTasks.length,
|
|
2112
|
-
completed: timeframeTasks.filter(t => t.status === 'completed').length,
|
|
2113
|
-
inProgress: timeframeTasks.filter(t => t.status === 'in_progress').length,
|
|
2114
|
-
pending: timeframeTasks.filter(t => t.status === 'pending').length,
|
|
2115
|
-
cancelled: timeframeTasks.filter(t => t.status === 'cancelled').length,
|
|
2116
|
-
blocked: timeframeTasks.filter(t => t.status === 'blocked').length
|
|
2117
|
-
},
|
|
2118
|
-
priorityBreakdown: {
|
|
2119
|
-
urgent: timeframeTasks.filter(t => t.priority === 'urgent').length,
|
|
2120
|
-
high: timeframeTasks.filter(t => t.priority === 'high').length,
|
|
2121
|
-
medium: timeframeTasks.filter(t => t.priority === 'medium').length,
|
|
2122
|
-
low: timeframeTasks.filter(t => t.priority === 'low').length
|
|
2123
|
-
},
|
|
2124
|
-
progressMetrics: this.calculateProgressMetrics(timeframeTasks),
|
|
2125
|
-
dependencyMetrics: this.calculateDependencyMetrics(timeframeTasks),
|
|
2126
|
-
templateUsage: this.calculateTemplateUsage(timeframeTasks)
|
|
2127
|
-
};
|
|
2128
|
-
|
|
2129
|
-
// Calculate completion rate
|
|
2130
|
-
summary.completionRate = summary.overview.totalTasks > 0
|
|
2131
|
-
? Math.round((summary.overview.completed / summary.overview.totalTasks) * 100)
|
|
2132
|
-
: 0;
|
|
2133
|
-
|
|
2134
|
-
// Calculate average task age
|
|
2135
|
-
const activeTasks = timeframeTasks.filter(t => t.status !== 'completed' && t.status !== 'cancelled');
|
|
2136
|
-
summary.averageTaskAge = activeTasks.length > 0
|
|
2137
|
-
? Math.round(activeTasks.reduce((sum, task) => {
|
|
2138
|
-
return sum + (Date.now() - new Date(task.createdAt).getTime()) / (1000 * 60 * 60 * 24);
|
|
2139
|
-
}, 0) / activeTasks.length)
|
|
2140
|
-
: 0;
|
|
2141
|
-
|
|
2142
|
-
return {
|
|
2143
|
-
summary,
|
|
2144
|
-
insights: this.generateSummaryInsights(summary)
|
|
2145
|
-
};
|
|
2146
|
-
}
|
|
2147
|
-
|
|
2148
|
-
/**
|
|
2149
|
-
* Get performance metrics
|
|
2150
|
-
* @private
|
|
2151
|
-
*/
|
|
2152
|
-
async getPerformanceMetrics(agent, timeframe) {
|
|
2153
|
-
const tasks = agent.taskList.tasks;
|
|
2154
|
-
const cutoffDate = new Date(Date.now() - parseInt(timeframe) * 24 * 60 * 60 * 1000);
|
|
2155
|
-
const completedTasks = tasks.filter(t =>
|
|
2156
|
-
t.status === 'completed' &&
|
|
2157
|
-
t.completedAt &&
|
|
2158
|
-
new Date(t.completedAt) >= cutoffDate
|
|
2159
|
-
);
|
|
2160
|
-
|
|
2161
|
-
const metrics = {
|
|
2162
|
-
productivity: {
|
|
2163
|
-
tasksCompleted: completedTasks.length,
|
|
2164
|
-
completionRate: this.calculateCompletionRate(tasks, timeframe),
|
|
2165
|
-
averageCompletionTime: this.calculateAverageCompletionTime(completedTasks),
|
|
2166
|
-
velocityTrend: this.calculateVelocityTrend(tasks, timeframe)
|
|
2167
|
-
},
|
|
2168
|
-
quality: {
|
|
2169
|
-
blockedTasksRate: this.calculateBlockedTasksRate(tasks),
|
|
2170
|
-
cancelledTasksRate: this.calculateCancelledTasksRate(tasks, timeframe),
|
|
2171
|
-
reworkRate: this.calculateReworkRate(tasks, timeframe)
|
|
2172
|
-
},
|
|
2173
|
-
efficiency: {
|
|
2174
|
-
priorityAccuracy: this.calculatePriorityAccuracy(completedTasks),
|
|
2175
|
-
dependencyHandling: this.calculateDependencyEfficiency(tasks),
|
|
2176
|
-
progressConsistency: this.calculateProgressConsistency(tasks)
|
|
2177
|
-
}
|
|
2178
|
-
};
|
|
2179
|
-
|
|
2180
|
-
return {
|
|
2181
|
-
metrics,
|
|
2182
|
-
recommendations: this.generatePerformanceRecommendations(metrics)
|
|
2183
|
-
};
|
|
2184
|
-
}
|
|
2185
|
-
|
|
2186
|
-
/**
|
|
2187
|
-
* Get trend analysis
|
|
2188
|
-
* @private
|
|
2189
|
-
*/
|
|
2190
|
-
async getTrendAnalysis(agent, timeframe) {
|
|
2191
|
-
const tasks = agent.taskList.tasks;
|
|
2192
|
-
const days = parseInt(timeframe);
|
|
2193
|
-
const trends = {
|
|
2194
|
-
daily: this.calculateDailyTrends(tasks, days),
|
|
2195
|
-
weekly: this.calculateWeeklyTrends(tasks, days),
|
|
2196
|
-
priorityTrends: this.calculatePriorityTrends(tasks, days),
|
|
2197
|
-
progressTrends: this.calculateProgressTrends(tasks, days)
|
|
2198
|
-
};
|
|
2199
|
-
|
|
2200
|
-
return {
|
|
2201
|
-
trends,
|
|
2202
|
-
forecasts: this.generateForecasts(trends),
|
|
2203
|
-
patterns: this.identifyPatterns(trends)
|
|
2204
|
-
};
|
|
2205
|
-
}
|
|
2206
|
-
|
|
2207
|
-
/**
|
|
2208
|
-
* Get team-wide analytics (across all agents)
|
|
2209
|
-
* @private
|
|
2210
|
-
*/
|
|
2211
|
-
async getTeamAnalytics(timeframe) {
|
|
2212
|
-
if (!this.scheduler || !this.scheduler.getAllAgents) {
|
|
2213
|
-
throw new Error('Team analytics requires scheduler with getAllAgents method');
|
|
2214
|
-
}
|
|
2215
|
-
|
|
2216
|
-
const allAgents = await this.scheduler.getAllAgents();
|
|
2217
|
-
const cutoffDate = new Date(Date.now() - parseInt(timeframe) * 24 * 60 * 60 * 1000);
|
|
2218
|
-
|
|
2219
|
-
const teamData = {
|
|
2220
|
-
agents: [],
|
|
2221
|
-
aggregatedMetrics: {
|
|
2222
|
-
totalTasks: 0,
|
|
2223
|
-
totalCompleted: 0,
|
|
2224
|
-
averageWorkload: 0,
|
|
2225
|
-
topPerformers: [],
|
|
2226
|
-
bottlenecks: []
|
|
2227
|
-
}
|
|
2228
|
-
};
|
|
2229
|
-
|
|
2230
|
-
// Analyze each agent
|
|
2231
|
-
for (const agent of allAgents) {
|
|
2232
|
-
if (!agent.taskList || !agent.taskList.tasks) continue;
|
|
2233
|
-
|
|
2234
|
-
const tasks = agent.taskList.tasks;
|
|
2235
|
-
const timeframeTasks = tasks.filter(t => new Date(t.createdAt) >= cutoffDate);
|
|
2236
|
-
|
|
2237
|
-
const agentMetrics = {
|
|
2238
|
-
agentId: agent.id,
|
|
2239
|
-
agentName: agent.name,
|
|
2240
|
-
totalTasks: timeframeTasks.length,
|
|
2241
|
-
completed: timeframeTasks.filter(t => t.status === 'completed').length,
|
|
2242
|
-
pending: timeframeTasks.filter(t => t.status === 'pending').length,
|
|
2243
|
-
inProgress: timeframeTasks.filter(t => t.status === 'in_progress').length,
|
|
2244
|
-
workloadScore: this.calculateWorkloadScore(tasks),
|
|
2245
|
-
completionRate: timeframeTasks.length > 0
|
|
2246
|
-
? Math.round((timeframeTasks.filter(t => t.status === 'completed').length / timeframeTasks.length) * 100)
|
|
2247
|
-
: 0
|
|
2248
|
-
};
|
|
2249
|
-
|
|
2250
|
-
teamData.agents.push(agentMetrics);
|
|
2251
|
-
teamData.aggregatedMetrics.totalTasks += agentMetrics.totalTasks;
|
|
2252
|
-
teamData.aggregatedMetrics.totalCompleted += agentMetrics.completed;
|
|
2253
|
-
}
|
|
2254
|
-
|
|
2255
|
-
// Calculate team-level metrics
|
|
2256
|
-
teamData.aggregatedMetrics.teamCompletionRate = teamData.aggregatedMetrics.totalTasks > 0
|
|
2257
|
-
? Math.round((teamData.aggregatedMetrics.totalCompleted / teamData.aggregatedMetrics.totalTasks) * 100)
|
|
2258
|
-
: 0;
|
|
2259
|
-
|
|
2260
|
-
teamData.aggregatedMetrics.averageWorkload = teamData.agents.length > 0
|
|
2261
|
-
? Math.round(teamData.agents.reduce((sum, a) => sum + a.workloadScore, 0) / teamData.agents.length)
|
|
2262
|
-
: 0;
|
|
2263
|
-
|
|
2264
|
-
// Identify top performers and bottlenecks
|
|
2265
|
-
teamData.aggregatedMetrics.topPerformers = teamData.agents
|
|
2266
|
-
.filter(a => a.completionRate >= 80)
|
|
2267
|
-
.sort((a, b) => b.completionRate - a.completionRate)
|
|
2268
|
-
.slice(0, 3);
|
|
2269
|
-
|
|
2270
|
-
teamData.aggregatedMetrics.bottlenecks = teamData.agents
|
|
2271
|
-
.filter(a => a.workloadScore > teamData.aggregatedMetrics.averageWorkload * 1.5)
|
|
2272
|
-
.sort((a, b) => b.workloadScore - a.workloadScore);
|
|
2273
|
-
|
|
2274
|
-
return {
|
|
2275
|
-
teamAnalytics: teamData,
|
|
2276
|
-
workloadDistribution: this.analyzeWorkloadDistribution(teamData.agents),
|
|
2277
|
-
collaborationMetrics: this.analyzeCollaborationMetrics(allAgents)
|
|
2278
|
-
};
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
/**
|
|
2282
|
-
* Export analytics data
|
|
2283
|
-
* @private
|
|
2284
|
-
*/
|
|
2285
|
-
async exportAnalytics(agent, params) {
|
|
2286
|
-
const { format = 'json', includeRawData = false, timeframe = '30' } = params;
|
|
2287
|
-
|
|
2288
|
-
const analyticsData = {
|
|
2289
|
-
metadata: {
|
|
2290
|
-
agentId: agent.id,
|
|
2291
|
-
agentName: agent.name,
|
|
2292
|
-
exportedAt: new Date().toISOString(),
|
|
2293
|
-
timeframe: `${timeframe} days`,
|
|
2294
|
-
format
|
|
2295
|
-
},
|
|
2296
|
-
summary: await this.getAnalyticsSummary(agent, timeframe),
|
|
2297
|
-
performance: await this.getPerformanceMetrics(agent, timeframe),
|
|
2298
|
-
trends: await this.getTrendAnalysis(agent, timeframe)
|
|
2299
|
-
};
|
|
2300
|
-
|
|
2301
|
-
if (includeRawData) {
|
|
2302
|
-
const cutoffDate = new Date(Date.now() - parseInt(timeframe) * 24 * 60 * 60 * 1000);
|
|
2303
|
-
analyticsData.rawData = {
|
|
2304
|
-
tasks: agent.taskList.tasks.filter(t => new Date(t.createdAt) >= cutoffDate)
|
|
2305
|
-
};
|
|
2306
|
-
}
|
|
2307
|
-
|
|
2308
|
-
let exportedData;
|
|
2309
|
-
switch (format.toLowerCase()) {
|
|
2310
|
-
case 'json':
|
|
2311
|
-
exportedData = JSON.stringify(analyticsData, null, 2);
|
|
2312
|
-
break;
|
|
2313
|
-
case 'csv':
|
|
2314
|
-
exportedData = this.convertToCSV(analyticsData);
|
|
2315
|
-
break;
|
|
2316
|
-
case 'summary':
|
|
2317
|
-
exportedData = this.generateTextSummary(analyticsData);
|
|
2318
|
-
break;
|
|
2319
|
-
default:
|
|
2320
|
-
throw new Error('Invalid export format. Use: json, csv, or summary');
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2323
|
-
return {
|
|
2324
|
-
exportData: exportedData,
|
|
2325
|
-
format,
|
|
2326
|
-
size: exportedData.length,
|
|
2327
|
-
records: analyticsData.rawData ? analyticsData.rawData.tasks.length : 0
|
|
2328
|
-
};
|
|
2329
|
-
}
|
|
2330
|
-
|
|
2331
|
-
/**
|
|
2332
|
-
* Generate actionable insights
|
|
2333
|
-
* @private
|
|
2334
|
-
*/
|
|
2335
|
-
async generateInsights(agent, timeframe) {
|
|
2336
|
-
const summary = await this.getAnalyticsSummary(agent, timeframe);
|
|
2337
|
-
const performance = await this.getPerformanceMetrics(agent, timeframe);
|
|
2338
|
-
const trends = await this.getTrendAnalysis(agent, timeframe);
|
|
2339
|
-
|
|
2340
|
-
const insights = {
|
|
2341
|
-
productivity: this.generateProductivityInsights(summary, performance, trends),
|
|
2342
|
-
workflow: this.generateWorkflowInsights(summary, performance, trends),
|
|
2343
|
-
optimization: this.generateOptimizationInsights(summary, performance, trends),
|
|
2344
|
-
predictions: this.generatePredictions(trends)
|
|
2345
|
-
};
|
|
2346
|
-
|
|
2347
|
-
return {
|
|
2348
|
-
insights,
|
|
2349
|
-
actionItems: this.generateActionItems(insights),
|
|
2350
|
-
priorities: this.generatePriorityRecommendations(insights)
|
|
2351
|
-
};
|
|
2352
|
-
}
|
|
2353
|
-
|
|
2354
|
-
// Helper methods for analytics calculations
|
|
2355
|
-
|
|
2356
|
-
calculateProgressMetrics(tasks) {
|
|
2357
|
-
const tasksWithProgress = tasks.filter(t => t.progress);
|
|
2358
|
-
if (tasksWithProgress.length === 0) return { averageProgress: 0, stageDistribution: {} };
|
|
2359
|
-
|
|
2360
|
-
const averageProgress = Math.round(
|
|
2361
|
-
tasksWithProgress.reduce((sum, t) => sum + (t.progress.percentage || 0), 0) / tasksWithProgress.length
|
|
2362
|
-
);
|
|
2363
|
-
|
|
2364
|
-
const stageDistribution = {};
|
|
2365
|
-
this.progressStages.forEach(stage => {
|
|
2366
|
-
stageDistribution[stage] = tasksWithProgress.filter(t => t.progress.stage === stage).length;
|
|
2367
|
-
});
|
|
2368
|
-
|
|
2369
|
-
return { averageProgress, stageDistribution };
|
|
2370
|
-
}
|
|
2371
|
-
|
|
2372
|
-
calculateDependencyMetrics(tasks) {
|
|
2373
|
-
const tasksWithDeps = tasks.filter(t => t.dependencies && t.dependencies.length > 0);
|
|
2374
|
-
const blockedTasks = tasks.filter(t => t.status === 'blocked').length;
|
|
2375
|
-
|
|
2376
|
-
return {
|
|
2377
|
-
tasksWithDependencies: tasksWithDeps.length,
|
|
2378
|
-
averageDependencies: tasksWithDeps.length > 0
|
|
2379
|
-
? Math.round(tasksWithDeps.reduce((sum, t) => sum + t.dependencies.length, 0) / tasksWithDeps.length)
|
|
2380
|
-
: 0,
|
|
2381
|
-
blockedTasks,
|
|
2382
|
-
dependencyChainLength: this.calculateMaxDependencyChain(tasks)
|
|
2383
|
-
};
|
|
2384
|
-
}
|
|
2385
|
-
|
|
2386
|
-
calculateTemplateUsage(tasks) {
|
|
2387
|
-
const templateTasks = tasks.filter(t => t.source === 'template-generated');
|
|
2388
|
-
const templateDistribution = {};
|
|
2389
|
-
|
|
2390
|
-
templateTasks.forEach(t => {
|
|
2391
|
-
const templateId = t.templateId || 'unknown';
|
|
2392
|
-
templateDistribution[templateId] = (templateDistribution[templateId] || 0) + 1;
|
|
2393
|
-
});
|
|
2394
|
-
|
|
2395
|
-
return {
|
|
2396
|
-
totalTemplateGenerated: templateTasks.length,
|
|
2397
|
-
templateDistribution,
|
|
2398
|
-
templateEfficiency: this.calculateTemplateEfficiency(templateTasks)
|
|
2399
|
-
};
|
|
2400
|
-
}
|
|
2401
|
-
|
|
2402
|
-
calculateCompletionRate(tasks, timeframe) {
|
|
2403
|
-
const cutoffDate = new Date(Date.now() - parseInt(timeframe) * 24 * 60 * 60 * 1000);
|
|
2404
|
-
const timeframeTasks = tasks.filter(t => new Date(t.createdAt) >= cutoffDate);
|
|
2405
|
-
|
|
2406
|
-
return timeframeTasks.length > 0
|
|
2407
|
-
? Math.round((timeframeTasks.filter(t => t.status === 'completed').length / timeframeTasks.length) * 100)
|
|
2408
|
-
: 0;
|
|
2409
|
-
}
|
|
2410
|
-
|
|
2411
|
-
calculateAverageCompletionTime(completedTasks) {
|
|
2412
|
-
if (completedTasks.length === 0) return 0;
|
|
2413
|
-
|
|
2414
|
-
const completionTimes = completedTasks.map(task => {
|
|
2415
|
-
const created = new Date(task.createdAt);
|
|
2416
|
-
const completed = new Date(task.completedAt);
|
|
2417
|
-
return (completed - created) / (1000 * 60 * 60 * 24); // days
|
|
2418
|
-
});
|
|
2419
|
-
|
|
2420
|
-
return Math.round(completionTimes.reduce((sum, time) => sum + time, 0) / completionTimes.length * 10) / 10;
|
|
2421
|
-
}
|
|
2422
|
-
|
|
2423
|
-
generateSummaryInsights(summary) {
|
|
2424
|
-
const insights = [];
|
|
2425
|
-
|
|
2426
|
-
if (summary.completionRate < 50) {
|
|
2427
|
-
insights.push('Completion rate is below 50%. Consider reviewing task prioritization and blocking issues.');
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
if (summary.averageTaskAge > 7) {
|
|
2431
|
-
insights.push(`Tasks are aging (avg: ${summary.averageTaskAge} days). Focus on completing older tasks.`);
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
|
-
if (summary.priorityBreakdown.urgent > summary.overview.totalTasks * 0.3) {
|
|
2435
|
-
insights.push('High proportion of urgent tasks. Consider better planning and early issue identification.');
|
|
2436
|
-
}
|
|
2437
|
-
|
|
2438
|
-
return insights;
|
|
2439
|
-
}
|
|
2440
|
-
|
|
2441
|
-
generatePerformanceRecommendations(metrics) {
|
|
2442
|
-
const recommendations = [];
|
|
2443
|
-
|
|
2444
|
-
if (metrics.productivity.completionRate < 70) {
|
|
2445
|
-
recommendations.push('Focus on improving task completion rate through better time management');
|
|
2446
|
-
}
|
|
2447
|
-
|
|
2448
|
-
if (metrics.quality.blockedTasksRate > 20) {
|
|
2449
|
-
recommendations.push('High blocked task rate - review dependency management and resource allocation');
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
|
-
if (metrics.efficiency.priorityAccuracy < 60) {
|
|
2453
|
-
recommendations.push('Improve priority setting accuracy by reviewing completed task outcomes');
|
|
2454
|
-
}
|
|
2455
|
-
|
|
2456
|
-
return recommendations;
|
|
2457
|
-
}
|
|
2458
|
-
|
|
2459
|
-
// Additional helper methods for complex calculations
|
|
2460
|
-
calculateWorkloadScore(tasks) {
|
|
2461
|
-
const activeTasks = tasks.filter(t => t.status === 'pending' || t.status === 'in_progress');
|
|
2462
|
-
const urgentCount = activeTasks.filter(t => t.priority === 'urgent').length;
|
|
2463
|
-
const highCount = activeTasks.filter(t => t.priority === 'high').length;
|
|
2464
|
-
|
|
2465
|
-
return urgentCount * 3 + highCount * 2 + activeTasks.length;
|
|
2466
|
-
}
|
|
2467
|
-
|
|
2468
|
-
calculateMaxDependencyChain(tasks) {
|
|
2469
|
-
// Simple implementation - returns the maximum number of dependencies for any task
|
|
2470
|
-
return Math.max(0, ...tasks.map(t => (t.dependencies ? t.dependencies.length : 0)));
|
|
2471
|
-
}
|
|
2472
|
-
|
|
2473
|
-
calculateTemplateEfficiency(templateTasks) {
|
|
2474
|
-
if (templateTasks.length === 0) return 100;
|
|
2475
|
-
const completedTemplateProps = templateTasks.filter(t => t.status === 'completed').length;
|
|
2476
|
-
return Math.round((completedTemplateProps / templateTasks.length) * 100);
|
|
2477
|
-
}
|
|
2478
|
-
|
|
2479
|
-
calculateVelocityTrend(tasks, timeframe) {
|
|
2480
|
-
// Simple velocity calculation based on completed tasks in timeframe
|
|
2481
|
-
const cutoffDate = new Date(Date.now() - parseInt(timeframe) * 24 * 60 * 60 * 1000);
|
|
2482
|
-
const completedInTimeframe = tasks.filter(t =>
|
|
2483
|
-
t.status === 'completed' &&
|
|
2484
|
-
t.completedAt &&
|
|
2485
|
-
new Date(t.completedAt) >= cutoffDate
|
|
2486
|
-
).length;
|
|
2487
|
-
|
|
2488
|
-
return Math.round((completedInTimeframe / parseInt(timeframe)) * 7); // tasks per week
|
|
2489
|
-
}
|
|
2490
|
-
|
|
2491
|
-
calculateBlockedTasksRate(tasks) {
|
|
2492
|
-
const activeTasks = tasks.filter(t => t.status !== 'completed' && t.status !== 'cancelled');
|
|
2493
|
-
if (activeTasks.length === 0) return 0;
|
|
2494
|
-
const blockedTasks = tasks.filter(t => t.status === 'blocked').length;
|
|
2495
|
-
return Math.round((blockedTasks / activeTasks.length) * 100);
|
|
2496
|
-
}
|
|
2497
|
-
|
|
2498
|
-
calculateCancelledTasksRate(tasks, timeframe) {
|
|
2499
|
-
const cutoffDate = new Date(Date.now() - parseInt(timeframe) * 24 * 60 * 60 * 1000);
|
|
2500
|
-
const timeframeTasks = tasks.filter(t => new Date(t.createdAt) >= cutoffDate);
|
|
2501
|
-
if (timeframeTasks.length === 0) return 0;
|
|
2502
|
-
const cancelledTasks = timeframeTasks.filter(t => t.status === 'cancelled').length;
|
|
2503
|
-
return Math.round((cancelledTasks / timeframeTasks.length) * 100);
|
|
2504
|
-
}
|
|
2505
|
-
|
|
2506
|
-
calculateReworkRate(tasks, timeframe) {
|
|
2507
|
-
// Simple implementation - tasks that moved back to earlier progress stages
|
|
2508
|
-
const cutoffDate = new Date(Date.now() - parseInt(timeframe) * 24 * 60 * 60 * 1000);
|
|
2509
|
-
const timeframeTasks = tasks.filter(t => new Date(t.createdAt) >= cutoffDate);
|
|
2510
|
-
const tasksWithRework = timeframeTasks.filter(t =>
|
|
2511
|
-
t.progress &&
|
|
2512
|
-
t.progress.stageHistory &&
|
|
2513
|
-
t.progress.stageHistory.some(h =>
|
|
2514
|
-
this.progressStages.indexOf(h.to) < this.progressStages.indexOf(h.from)
|
|
2515
|
-
)
|
|
2516
|
-
).length;
|
|
2517
|
-
|
|
2518
|
-
return timeframeTasks.length > 0 ? Math.round((tasksWithRework / timeframeTasks.length) * 100) : 0;
|
|
2519
|
-
}
|
|
2520
|
-
|
|
2521
|
-
calculatePriorityAccuracy(completedTasks) {
|
|
2522
|
-
if (completedTasks.length === 0) return 100;
|
|
2523
|
-
// Simple heuristic: assume urgent/high priority tasks completed faster were accurate
|
|
2524
|
-
const fastCompletedUrgentHigh = completedTasks.filter(t => {
|
|
2525
|
-
if (!['urgent', 'high'].includes(t.priority)) return false;
|
|
2526
|
-
const created = new Date(t.createdAt);
|
|
2527
|
-
const completed = new Date(t.completedAt);
|
|
2528
|
-
const daysToComplete = (completed - created) / (1000 * 60 * 60 * 24);
|
|
2529
|
-
return daysToComplete <= 3; // completed within 3 days
|
|
2530
|
-
}).length;
|
|
2531
|
-
|
|
2532
|
-
const totalUrgentHigh = completedTasks.filter(t => ['urgent', 'high'].includes(t.priority)).length;
|
|
2533
|
-
return totalUrgentHigh > 0 ? Math.round((fastCompletedUrgentHigh / totalUrgentHigh) * 100) : 100;
|
|
2534
|
-
}
|
|
2535
|
-
|
|
2536
|
-
calculateDependencyEfficiency(tasks) {
|
|
2537
|
-
const tasksWithDeps = tasks.filter(t => t.dependencies && t.dependencies.length > 0);
|
|
2538
|
-
if (tasksWithDeps.length === 0) return 100;
|
|
2539
|
-
|
|
2540
|
-
const efficientTasks = tasksWithDeps.filter(t => t.status !== 'blocked').length;
|
|
2541
|
-
return Math.round((efficientTasks / tasksWithDeps.length) * 100);
|
|
2542
|
-
}
|
|
2543
|
-
|
|
2544
|
-
calculateProgressConsistency(tasks) {
|
|
2545
|
-
const tasksWithProgress = tasks.filter(t => t.progress && t.progress.percentage !== undefined);
|
|
2546
|
-
if (tasksWithProgress.length === 0) return 100;
|
|
2547
|
-
|
|
2548
|
-
// Simple heuristic: tasks with progress matching their stage
|
|
2549
|
-
const consistentTasks = tasksWithProgress.filter(t => {
|
|
2550
|
-
const stage = t.progress.stage;
|
|
2551
|
-
const percentage = t.progress.percentage;
|
|
2552
|
-
|
|
2553
|
-
if (stage === 'not_started' && percentage === 0) return true;
|
|
2554
|
-
if (stage === 'planning' && percentage > 0 && percentage < 25) return true;
|
|
2555
|
-
if (stage === 'in_development' && percentage >= 25 && percentage < 75) return true;
|
|
2556
|
-
if (stage === 'testing' && percentage >= 75 && percentage < 95) return true;
|
|
2557
|
-
if (stage === 'review' && percentage >= 95 && percentage < 100) return true;
|
|
2558
|
-
if (stage === 'completed' && percentage === 100) return true;
|
|
2559
|
-
|
|
2560
|
-
return false;
|
|
2561
|
-
}).length;
|
|
2562
|
-
|
|
2563
|
-
return Math.round((consistentTasks / tasksWithProgress.length) * 100);
|
|
2564
|
-
}
|
|
2565
|
-
|
|
2566
|
-
calculateDailyTrends(tasks, days) {
|
|
2567
|
-
const trends = [];
|
|
2568
|
-
for (let i = 0; i < days; i++) {
|
|
2569
|
-
const date = new Date(Date.now() - i * 24 * 60 * 60 * 1000);
|
|
2570
|
-
const dayStart = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
2571
|
-
const dayEnd = new Date(dayStart.getTime() + 24 * 60 * 60 * 1000);
|
|
2572
|
-
|
|
2573
|
-
const dayTasks = tasks.filter(t => {
|
|
2574
|
-
const created = new Date(t.createdAt);
|
|
2575
|
-
return created >= dayStart && created < dayEnd;
|
|
2576
|
-
});
|
|
2577
|
-
|
|
2578
|
-
trends.unshift({
|
|
2579
|
-
date: dayStart.toISOString().split('T')[0],
|
|
2580
|
-
created: dayTasks.length,
|
|
2581
|
-
completed: dayTasks.filter(t => t.status === 'completed').length
|
|
2582
|
-
});
|
|
2583
|
-
}
|
|
2584
|
-
return trends;
|
|
2585
|
-
}
|
|
2586
|
-
|
|
2587
|
-
calculateWeeklyTrends(tasks, days) {
|
|
2588
|
-
const weeks = Math.ceil(days / 7);
|
|
2589
|
-
const trends = [];
|
|
2590
|
-
|
|
2591
|
-
for (let i = 0; i < weeks; i++) {
|
|
2592
|
-
const weekStart = new Date(Date.now() - (i + 1) * 7 * 24 * 60 * 60 * 1000);
|
|
2593
|
-
const weekEnd = new Date(Date.now() - i * 7 * 24 * 60 * 60 * 1000);
|
|
2594
|
-
|
|
2595
|
-
const weekTasks = tasks.filter(t => {
|
|
2596
|
-
const created = new Date(t.createdAt);
|
|
2597
|
-
return created >= weekStart && created < weekEnd;
|
|
2598
|
-
});
|
|
2599
|
-
|
|
2600
|
-
trends.unshift({
|
|
2601
|
-
week: `Week ${weeks - i}`,
|
|
2602
|
-
created: weekTasks.length,
|
|
2603
|
-
completed: weekTasks.filter(t => t.status === 'completed').length
|
|
2604
|
-
});
|
|
2605
|
-
}
|
|
2606
|
-
return trends;
|
|
2607
|
-
}
|
|
2608
|
-
|
|
2609
|
-
calculatePriorityTrends(tasks, days) {
|
|
2610
|
-
const cutoffDate = new Date(Date.now() - days * 24 * 60 * 60 * 1000);
|
|
2611
|
-
const timeframeTasks = tasks.filter(t => new Date(t.createdAt) >= cutoffDate);
|
|
2612
|
-
|
|
2613
|
-
return {
|
|
2614
|
-
urgent: timeframeTasks.filter(t => t.priority === 'urgent').length,
|
|
2615
|
-
high: timeframeTasks.filter(t => t.priority === 'high').length,
|
|
2616
|
-
medium: timeframeTasks.filter(t => t.priority === 'medium').length,
|
|
2617
|
-
low: timeframeTasks.filter(t => t.priority === 'low').length
|
|
2618
|
-
};
|
|
2619
|
-
}
|
|
2620
|
-
|
|
2621
|
-
calculateProgressTrends(tasks, days) {
|
|
2622
|
-
const cutoffDate = new Date(Date.now() - days * 24 * 60 * 60 * 1000);
|
|
2623
|
-
const timeframeTasks = tasks.filter(t => new Date(t.createdAt) >= cutoffDate);
|
|
2624
|
-
const tasksWithProgress = timeframeTasks.filter(t => t.progress);
|
|
2625
|
-
|
|
2626
|
-
const stageTrends = {};
|
|
2627
|
-
this.progressStages.forEach(stage => {
|
|
2628
|
-
stageTrends[stage] = tasksWithProgress.filter(t => t.progress.stage === stage).length;
|
|
2629
|
-
});
|
|
2630
|
-
|
|
2631
|
-
return stageTrends;
|
|
2632
|
-
}
|
|
2633
|
-
|
|
2634
|
-
generateForecasts(trends) {
|
|
2635
|
-
return {
|
|
2636
|
-
predictedCompletions: this.predictFutureCompletions(trends.daily),
|
|
2637
|
-
workloadForecast: this.predictWorkloadTrend(trends.weekly),
|
|
2638
|
-
priorityShift: this.predictPriorityShift(trends.priorityTrends)
|
|
2639
|
-
};
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
identifyPatterns(trends) {
|
|
2643
|
-
return {
|
|
2644
|
-
peakDays: this.identifyPeakActivityDays(trends.daily),
|
|
2645
|
-
cyclicalPatterns: this.identifyCyclicalPatterns(trends.weekly),
|
|
2646
|
-
priorityPatterns: this.identifyPriorityPatterns(trends.priorityTrends)
|
|
2647
|
-
};
|
|
2648
|
-
}
|
|
2649
|
-
|
|
2650
|
-
// Simplified implementations for missing complex methods
|
|
2651
|
-
predictFutureCompletions(dailyTrends) {
|
|
2652
|
-
if (dailyTrends.length < 7) return 'Insufficient data';
|
|
2653
|
-
const recentAvg = dailyTrends.slice(-7).reduce((sum, day) => sum + day.completed, 0) / 7;
|
|
2654
|
-
return `${Math.round(recentAvg)} tasks/day predicted`;
|
|
2655
|
-
}
|
|
2656
|
-
|
|
2657
|
-
predictWorkloadTrend(weeklyTrends) {
|
|
2658
|
-
if (weeklyTrends.length < 2) return 'Stable';
|
|
2659
|
-
const recent = weeklyTrends[weeklyTrends.length - 1].created;
|
|
2660
|
-
const previous = weeklyTrends[weeklyTrends.length - 2].created;
|
|
2661
|
-
const change = ((recent - previous) / previous) * 100;
|
|
2662
|
-
|
|
2663
|
-
if (change > 20) return 'Increasing workload';
|
|
2664
|
-
if (change < -20) return 'Decreasing workload';
|
|
2665
|
-
return 'Stable workload';
|
|
2666
|
-
}
|
|
2667
|
-
|
|
2668
|
-
predictPriorityShift(priorityTrends) {
|
|
2669
|
-
const total = Object.values(priorityTrends).reduce((sum, count) => sum + count, 0);
|
|
2670
|
-
if (total === 0) return 'No priority data';
|
|
2671
|
-
|
|
2672
|
-
const urgentPercent = (priorityTrends.urgent / total) * 100;
|
|
2673
|
-
if (urgentPercent > 30) return 'High urgent task ratio - plan for capacity';
|
|
2674
|
-
return 'Balanced priority distribution';
|
|
2675
|
-
}
|
|
2676
|
-
|
|
2677
|
-
identifyPeakActivityDays(dailyTrends) {
|
|
2678
|
-
const maxCreated = Math.max(...dailyTrends.map(d => d.created));
|
|
2679
|
-
return dailyTrends.filter(d => d.created === maxCreated).map(d => d.date);
|
|
2680
|
-
}
|
|
2681
|
-
|
|
2682
|
-
identifyCyclicalPatterns(weeklyTrends) {
|
|
2683
|
-
if (weeklyTrends.length < 4) return 'Insufficient data for pattern analysis';
|
|
2684
|
-
return 'Weekly patterns detected - further analysis available';
|
|
2685
|
-
}
|
|
2686
|
-
|
|
2687
|
-
identifyPriorityPatterns(priorityTrends) {
|
|
2688
|
-
const total = Object.values(priorityTrends).reduce((sum, count) => sum + count, 0);
|
|
2689
|
-
if (total === 0) return 'No priority patterns';
|
|
2690
|
-
|
|
2691
|
-
const dominant = Object.entries(priorityTrends).reduce((max, [priority, count]) =>
|
|
2692
|
-
count > max.count ? { priority, count } : max, { priority: '', count: 0 }
|
|
2693
|
-
);
|
|
2694
|
-
|
|
2695
|
-
return `${dominant.priority} priority tasks dominate (${Math.round((dominant.count / total) * 100)}%)`;
|
|
2696
|
-
}
|
|
2697
|
-
|
|
2698
|
-
generateProductivityInsights(summary, performance, trends) {
|
|
2699
|
-
const insights = [];
|
|
2700
|
-
|
|
2701
|
-
if (performance.metrics.productivity.completionRate > 80) {
|
|
2702
|
-
insights.push('High productivity - excellent task completion rate');
|
|
2703
|
-
} else if (performance.metrics.productivity.completionRate < 50) {
|
|
2704
|
-
insights.push('Low productivity - focus on task completion strategies');
|
|
2705
|
-
}
|
|
2706
|
-
|
|
2707
|
-
if (summary.summary.averageTaskAge > 10) {
|
|
2708
|
-
insights.push('Tasks are aging significantly - prioritize older tasks');
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
return insights;
|
|
2712
|
-
}
|
|
2713
|
-
|
|
2714
|
-
generateWorkflowInsights(summary, performance, trends) {
|
|
2715
|
-
const insights = [];
|
|
2716
|
-
|
|
2717
|
-
if (summary.summary.dependencyMetrics.blockedTasks > 3) {
|
|
2718
|
-
insights.push('Multiple blocked tasks - review dependency management');
|
|
2719
|
-
}
|
|
2720
|
-
|
|
2721
|
-
if (summary.summary.templateUsage.totalTemplateGenerated > summary.summary.overview.totalTasks * 0.5) {
|
|
2722
|
-
insights.push('Heavy template usage - consider workflow optimization');
|
|
2723
|
-
}
|
|
2724
|
-
|
|
2725
|
-
return insights;
|
|
2726
|
-
}
|
|
2727
|
-
|
|
2728
|
-
generateOptimizationInsights(summary, performance, trends) {
|
|
2729
|
-
const insights = [];
|
|
2730
|
-
|
|
2731
|
-
if (performance.metrics.efficiency.priorityAccuracy < 70) {
|
|
2732
|
-
insights.push('Priority setting needs improvement - review task urgency assessment');
|
|
2733
|
-
}
|
|
2734
|
-
|
|
2735
|
-
if (performance.metrics.quality.blockedTasksRate > 15) {
|
|
2736
|
-
insights.push('High blocked task rate - optimize dependency planning');
|
|
2737
|
-
}
|
|
2738
|
-
|
|
2739
|
-
return insights;
|
|
2740
|
-
}
|
|
2741
|
-
|
|
2742
|
-
generatePredictions(trends) {
|
|
2743
|
-
return [
|
|
2744
|
-
trends.forecasts.predictedCompletions,
|
|
2745
|
-
trends.forecasts.workloadForecast,
|
|
2746
|
-
trends.forecasts.priorityShift
|
|
2747
|
-
];
|
|
2748
|
-
}
|
|
2749
|
-
|
|
2750
|
-
generateActionItems(insights) {
|
|
2751
|
-
const allInsights = [
|
|
2752
|
-
...insights.productivity,
|
|
2753
|
-
...insights.workflow,
|
|
2754
|
-
...insights.optimization
|
|
2755
|
-
];
|
|
2756
|
-
|
|
2757
|
-
return allInsights.map((insight, index) => ({
|
|
2758
|
-
id: `action-${index + 1}`,
|
|
2759
|
-
description: insight,
|
|
2760
|
-
priority: insight.includes('urgent') || insight.includes('critical') ? 'high' : 'medium',
|
|
2761
|
-
category: insight.includes('productivity') ? 'productivity' :
|
|
2762
|
-
insight.includes('workflow') ? 'workflow' : 'optimization'
|
|
2763
|
-
}));
|
|
2764
|
-
}
|
|
2765
|
-
|
|
2766
|
-
generatePriorityRecommendations(insights) {
|
|
2767
|
-
const recommendations = [];
|
|
2768
|
-
|
|
2769
|
-
if (insights.productivity.some(i => i.includes('Low productivity'))) {
|
|
2770
|
-
recommendations.push({
|
|
2771
|
-
priority: 'urgent',
|
|
2772
|
-
action: 'Focus on task completion strategies',
|
|
2773
|
-
impact: 'high'
|
|
2774
|
-
});
|
|
2775
|
-
}
|
|
2776
|
-
|
|
2777
|
-
if (insights.workflow.some(i => i.includes('blocked tasks'))) {
|
|
2778
|
-
recommendations.push({
|
|
2779
|
-
priority: 'high',
|
|
2780
|
-
action: 'Review and resolve task dependencies',
|
|
2781
|
-
impact: 'medium'
|
|
2782
|
-
});
|
|
2783
|
-
}
|
|
2784
|
-
|
|
2785
|
-
return recommendations;
|
|
2786
|
-
}
|
|
2787
|
-
|
|
2788
|
-
analyzeWorkloadDistribution(agents) {
|
|
2789
|
-
if (agents.length === 0) return { balance: 'No agents', distribution: [] };
|
|
2790
|
-
|
|
2791
|
-
const workloads = agents.map(a => a.workloadScore);
|
|
2792
|
-
const avg = workloads.reduce((sum, w) => sum + w, 0) / workloads.length;
|
|
2793
|
-
const maxDeviation = Math.max(...workloads.map(w => Math.abs(w - avg)));
|
|
2794
|
-
|
|
2795
|
-
return {
|
|
2796
|
-
balance: maxDeviation > avg * 0.5 ? 'Unbalanced' : 'Balanced',
|
|
2797
|
-
distribution: agents.map(a => ({
|
|
2798
|
-
agent: a.agentName,
|
|
2799
|
-
workload: a.workloadScore,
|
|
2800
|
-
deviation: Math.round(((a.workloadScore - avg) / avg) * 100)
|
|
2801
|
-
}))
|
|
2802
|
-
};
|
|
2803
|
-
}
|
|
2804
|
-
|
|
2805
|
-
analyzeCollaborationMetrics(allAgents) {
|
|
2806
|
-
return {
|
|
2807
|
-
totalAgents: allAgents.length,
|
|
2808
|
-
activeAgents: allAgents.filter(a => a.taskList && a.taskList.tasks.length > 0).length,
|
|
2809
|
-
collaborationScore: Math.round(Math.random() * 100) // Simplified - would analyze shared dependencies
|
|
2810
|
-
};
|
|
2811
|
-
}
|
|
2812
|
-
|
|
2813
|
-
convertToCSV(analyticsData) {
|
|
2814
|
-
// Simplified CSV export
|
|
2815
|
-
const headers = ['Metric', 'Value'];
|
|
2816
|
-
const rows = [
|
|
2817
|
-
['Total Tasks', analyticsData.summary.summary.overview.totalTasks],
|
|
2818
|
-
['Completed Tasks', analyticsData.summary.summary.overview.completed],
|
|
2819
|
-
['Completion Rate', `${analyticsData.summary.summary.completionRate}%`],
|
|
2820
|
-
['Average Task Age', `${analyticsData.summary.summary.averageTaskAge} days`]
|
|
2821
|
-
];
|
|
2822
|
-
|
|
2823
|
-
return [headers, ...rows].map(row => row.join(',')).join('\n');
|
|
2824
|
-
}
|
|
2825
|
-
|
|
2826
|
-
generateTextSummary(analyticsData) {
|
|
2827
|
-
const summary = analyticsData.summary.summary;
|
|
2828
|
-
return `
|
|
2829
|
-
Analytics Summary
|
|
2830
|
-
================
|
|
2831
|
-
Total Tasks: ${summary.overview.totalTasks}
|
|
2832
|
-
Completed: ${summary.overview.completed} (${summary.completionRate}%)
|
|
2833
|
-
In Progress: ${summary.overview.inProgress}
|
|
2834
|
-
Pending: ${summary.overview.pending}
|
|
2835
|
-
Average Task Age: ${summary.averageTaskAge} days
|
|
2836
|
-
|
|
2837
|
-
Key Insights:
|
|
2838
|
-
${analyticsData.summary.insights.map(insight => `- ${insight}`).join('\n')}
|
|
2839
|
-
`.trim();
|
|
2840
|
-
}
|
|
2841
|
-
|
|
2842
|
-
/**
|
|
2843
|
-
* Format tool result for display
|
|
2844
|
-
* @param {Object} result - Tool execution result
|
|
2845
|
-
* @returns {string} Formatted result
|
|
2846
|
-
*/
|
|
2847
|
-
formatResult(result) {
|
|
2848
|
-
if (!result.success) {
|
|
2849
|
-
return `TaskManager Error: ${result.error}`;
|
|
2850
|
-
}
|
|
2851
|
-
|
|
2852
|
-
const lines = [`TaskManager: ${result.action} completed`];
|
|
2853
|
-
|
|
2854
|
-
if (result.result.task) {
|
|
2855
|
-
lines.push(`Task: [${result.result.task.status}] ${result.result.task.title} (${result.result.task.id})`);
|
|
2856
|
-
}
|
|
2857
|
-
|
|
2858
|
-
if (result.result.tasks) {
|
|
2859
|
-
lines.push(`Found ${result.result.tasks.length} tasks:`);
|
|
2860
|
-
result.result.tasks.forEach(task => {
|
|
2861
|
-
lines.push(` - [${task.status}] ${task.title} (Priority: ${task.priority})`);
|
|
2862
|
-
});
|
|
2863
|
-
}
|
|
2864
|
-
|
|
2865
|
-
if (result.summary) {
|
|
2866
|
-
lines.push(`Summary: ${result.summary.pending} pending, ${result.summary.in_progress} in progress, ${result.summary.completed} completed`);
|
|
2867
|
-
}
|
|
2868
|
-
|
|
2869
|
-
return lines.join('\n');
|
|
2870
|
-
}
|
|
2871
|
-
}
|
|
2872
|
-
|
|
2873
|
-
export default TaskManagerTool;
|
|
1
|
+
const a0_0x358c72=a0_0x411c;(function(_0x1ed050,_0x4f4d97){const _0x18dfda=a0_0x411c,_0x1c72ea=_0x1ed050();while(!![]){try{const _0x476308=parseInt(_0x18dfda(0x289))/0x1*(-parseInt(_0x18dfda(0x1a4))/0x2)+-parseInt(_0x18dfda(0x1df))/0x3*(-parseInt(_0x18dfda(0x24b))/0x4)+-parseInt(_0x18dfda(0x2aa))/0x5*(-parseInt(_0x18dfda(0x18f))/0x6)+parseInt(_0x18dfda(0x172))/0x7+parseInt(_0x18dfda(0x1ad))/0x8*(-parseInt(_0x18dfda(0x265))/0x9)+-parseInt(_0x18dfda(0x1fe))/0xa+parseInt(_0x18dfda(0x22d))/0xb;if(_0x476308===_0x4f4d97)break;else _0x1c72ea['push'](_0x1c72ea['shift']());}catch(_0x1c7bfa){_0x1c72ea['push'](_0x1c72ea['shift']());}}}(a0_0x9cd7,0xe32b8));function a0_0x9cd7(){const _0x5d2481=['sw5PDgLHBgL6zsbWCM9Qzwn0ihn0CNvJDhvYzsWGy29UzMLNDxjLihrVB2XZlcbHBMqGCgXHBIbHCMnOAxrLy3r1CMu','u3LZDgvTyxrPyYbHChbYB2fJAcb0BYbPzgvUDgLMEwLUzYbHBMqGzML4Aw5Nigj1z3m','DgvTCgXHDgvvC2fNzq','DgvTCgXHDgvjza','Aw5JBhvKzxm','ChjPB3jPDhLcCMvHA2rVD24','ANnVBG','yxbWBhLuzw1WBgf0zq','C3vJy2vZCW','yNvPBhqTAw4','Dg9gAxHLza','y29TCgXLDgvuyxnR','z2vUzxjHDgvqzxjMB3jTyw5JzvjLy29TBwvUzgf0Aw9UCW','DxnLCI1JCMvHDgvK','icaTifS','mtm4mdzlqM1PAhu','sw1WBgvTzw50ifjfu1qGqvbjigvUzhbVAw50CYbHBMqGyNvZAw5LC3mGBg9NAwm','ihrHC2TZoG','vgvZDgLUzYaMierVy3vTzw50yxrPB24','u3vTBwfYEtOG','sw1WCM92zsbWCMLVCML0EsbZzxr0Aw5NigfJy3vYywn5igj5ihjLDMLLD2LUzYbJB21WBgv0zwqGDgfZAYbVDxrJB21LCW','y3jLyxrLq3vZDg9TvgvTCgXHDgu','rwfJAcb0yxnRig11C3qGAgf2zsbHihrPDgXL','Aw5MBW','q3vZDg9TihrLBxbSyxrLoIa','C2nOzwr1BgvY','Aw5Fzgv2zwXVCg1LBNq','vgvZDcbMAxGGyw5KihzLCMLMEsbUBYbYzwDYzxnZAw9UCYbPBNrYB2r1y2vK','CxvHBgL0Eq','z2vUzxjHDgvpChrPBwL6yxrPB25jBNnPz2H0CW','AgLNAa','ChjPB3jPDhLxzwLNAhrZ','CgfYzw50vgfZA0LK','z2vUzxjHDgvxB3jRzMXVD0LUC2LNAhrZ','DgfZA1bYAw9YAxrPzxm','yw5HBhL6zq','mJGYuKLlwMXZ','uhjVz3jLC3mGDhjHy2TPBMCGy29TCgXLDgvKicG','AwrLBNrPzNLqCMLVCML0EvbHDhrLCM5Z','sw1WBgvTzw50ihjVyNvZDcbLCNjVCIbOyw5KBgLUzYbHBMqGCMv0CNKGBwvJAgfUAxnTCW','DxjNzw5JEq','sgLNAcbIBg9JA2vKihrHC2SGCMf0zsaTig9WDgLTAxPLigrLCgvUzgvUy3KGCgXHBM5PBMC','vgfZA3mGyxjYyxKGy2fUBM90igjLigvTChr5','DgvJAg5VBg9NEq','y2fSy3vSyxrL','mJC1mZm2u2DWBNLf','ChjLzgLJDfDVCMTSB2fKvhjLBMq','yxzLCMfNzvDVCMTSB2fK','z2vUzxjHDgvqCMLVCML0EvjLyxnVBG','CM91BMq','yMXVy2TLza','BMfTzq','DxjNzw50','tg93ihbYB2r1y3rPDML0EsaTigzVy3vZig9UihrHC2SGy29TCgXLDgLVBIbZDhjHDgvNAwvZ','D2vIlwfWCc1KzxzLBg9WBwvUDa','yxbPlwLUDgvNCMf0Aw9U','q29UC2LKzxiGzgvSzwDHDgLUzYbZB21LihrHC2TZihrVigXLC3mGyNvZEsbHz2vUDhm','ChjLzgLJDez1DhvYzunVBxbSzxrPB25Z','z2v0vgLTzq','zgvWzw5K','ChjPB3jPDhLby2n1CMfJEq','AwrLBNrPzNLqzwfRqwn0AxzPDhLeyxLZ','yxzLCMfNzvrHC2Tbz2u','CMvSyxrL','yMXVy2TPBMC','ihrHC2TZigfYzsbUzwfYignVBxbSzxrPB24UiezVy3vZig9UigzPBMLZAgLUzYb0AgvZzsbMB3iGCxvPy2SGD2LUCY4','Dg90ywXuzw1WBgf0zuDLBMvYyxrLza','CMv2Awv3','y29UDMvYDfrVq1nw','CMvWBgfJzq','sgLNAcb1CMDLBNqGDgfZAYbYyxrPBYaTihbSyw4GzM9YignHCgfJAxr5','q2XLyxjLzca','qMfJA2vUzcbjBxbSzw1LBNrHDgLVBG','z2v0tw9UDgG','DxbKyxrLvgfZAW','CMvZDwX0','lIbnDxn0igjLoIa','BgLZDfrHC2TZ','z2v0vgvHBufUywX5DgLJCW','zxjYB3i','zMvHDhvYzs1KzxzLBg9WBwvUDa','vgfZAYb0AxrSzsbPCYbYzxf1AxjLza','y2fSy3vSyxrLuhjVz3jLC3nuCMvUzhm','qNvNiezPEcbxB3jRzMXVDW','C29YDa','q3jVC3mTywDLBNqGyMfSyw5JAw5NigzHAwXLzdOG','y3jLyxrLzef0','ignVBxbSzxrLza','z2vUzxjHDgvby3rPB25jDgvTCW','zxzLCNK','BM93','DgfZA1rLBxbSyxrLCW','iIbMB3iGDgfZAYaI','CgvYy2vUDgfNzq','C3vIC3rY','mtC1ogzWy1zoua','BM90zs0','z2vUzxjHDgvgB3jLy2fZDhm','z2vUzxjHDgvuyxnRu3vTBwfYEq','vgfZAYb1CgrHDgvKihn1y2nLC3nMDwXSEq','BM90zq','Bwv0CMLJCW','vgvTCgXHDguGBM90igzVDw5KoIa','y3vZDg9Tlq','BwLSzxn0B25LCW','y3jLyxrL','yMXVy2TLzfrHC2TZ','ChjPB3jPDhLty29Yzq','yxbWBhK','y2fSy3vSyxrLuhjPB3jPDhLty29Yzq','DgvZDgLUzW','y291BNq','AwrLBNrPzNLdEwnSAwnHBfbHDhrLCM5Z','y2fSy3vSyxrLzfbLCMnLBNrHz2u','z2v0ugvYzM9YBwfUy2vnzxrYAwnZ','Aw5FChjVz3jLC3m','sw1WBgvTzw50iefqssbRzxKGBwfUywDLBwvUDcbHBMqGyxv0AgvUDgLJyxrPB24GzMXVDW','vgvHBsbHBMfSExrPy3mGCMvXDwLYzxmGC2nOzwr1BgvYihDPDgGGz2v0qwXSqwDLBNrZig1LDgHVza','Bg93','vgvZDcbPBNrLz3jHDgLVBIb3AxrOihzHCMLVDxmGC2nLBMfYAw9ZigfUzcbLzgDLignHC2vZ','z2v0qw5HBhL0AwnZu3vTBwfYEq','BwvKAxvT','uhjPB3jPDhKGC2v0DgLUzYbUzwvKCYbPBxbYB3zLBwvUDcaTihjLDMLLDYb0yxnRihvYz2vUy3KGyxnZzxnZBwvUDa','zMLUza','B2jQzwn0','CMf3rgf0yq','mti2odKZotbAtMzttMG','y2fSy3vSyxrLq2fUy2vSBgvKvgfZA3nsyxrL','ChjVz3jLC3m','vgvTCgXHDguGBwfUywDLBwvUDcbJB21WBgv0zwqGka','ywDLBNroyw1L','vgvZDgLUzYaMifzHBgLKyxrPB24','DMfSDwu','Aw5qCM9NCMvZCW','tM8GChjPB3jPDhKGzgf0yq','vgfZA01HBMfNzxi6ia','y3jLyxrLvgfZAW','rgvWzw5Kzw5JEsbJCMvHDgvKihn1y2nLC3nMDwXSEq','Bwf4','zMLSDgvY','y29TCgXLDgvKqxq','DhLWzq','sgLNAcbIBg9JA2vKihrHC2SGCMf0zsaTihjLDMLLDYbKzxbLBMrLBMn5ig1HBMfNzw1LBNqGyw5KihjLC291CMnLigfSBg9JyxrPB24','y2fSy3vSyxrLrgfPBhLuCMvUzhm','yMXVy2TLzfrHC2TZuMf0zq','rgvZAwDUihn5C3rLBsbHCMnOAxrLy3r1CMuGyw5KihvZzxiGAw50zxjMywnL','Dg9ju09tDhjPBMC','C3vWCg9YDgvKqwn0Aw9UCW','ChjPB3jPDgL6zq','C29Tzq','C21HBgW','CMfUzg9T','sgLNAcbWCM9KDwn0AxzPDhKGlsbLEgnLBgXLBNqGDgfZAYbJB21WBgv0Aw9UihjHDgu','sw5ZDwzMAwnPzw50igrHDge','C3rHz2viAxn0B3j5','vgfZA01HBMfNzxiGrxjYB3i6ia','yw5HBhL0AwnZ','ihrHC2TZl2rHEsbWCMvKAwn0zwq','ihbYAw9YAxr5ihrHC2TZigrVBwLUyxrLicG','uMv2Awv3igfUzcbYzxnVBhzLihrHC2SGzgvWzw5Kzw5JAwvZ','C3LUyW','AM9PBG','C3rHDhvZ','C3rYAw5NAwz5','ChjVz3jLC3ntDgfNzxm','y2fSy3vSyxrLuhjVz3jLC3ndB25ZAxn0zw5JEq','BgLZDa','z2vUzxjHDgvtDw1Tyxj5sw5ZAwDODhm','z2v0uhjVz3jLC3npDMvYDMLLDW','y2fSy3vSyxrLtwf4rgvWzw5Kzw5JEunOywLU','Dg9WugvYzM9YBwvYCW','y2fUy2vSBgvKqxq','C3rHBMrHCMqGChjPB3jPDgL6yxrPB24','mte2odq2odr4wLHWteO','D29YA2zSB3C','y2fSy3vSyxrLuhjPB3jPDhLby2n1CMfJEq','D2fYBG','qwDLBNqGAgfZignHCgfJAxr5igzVCIbHzgrPDgLVBMfSigHPz2GTChjPB3jPDhKGDgfZA3m','y2fSy3vSyxrLv29YA2XVywrty29Yzq','y2XLyxi','vgfZAYbUB3qGzM91BMq6ia','CgfYzw50','C2v0','cIaGica','ChjPB3jPDhLuCMvUzhm','vgfZAYbTyw5Hz2vTzw50ihrVB2WGzM9Yig9Yz2fUAxPPBMCGyw5KihrYywnRAw5NihDVCMS','igrHExmkcKTLEsbjBNnPz2H0CZOk','DhjLBMrZ','y3vZDg9T','qwDLBNqGBM90igzVDw5KoIa','twv0CMLJ','CgfYC2vqyxjHBwv0zxjZ','y2fSy3vSyxrPB25nzxrOB2q','CMvHC29U','ywDLBNrjza','y2fSy3vSyxrLrgvWzw5Kzw5JEuvMzMLJAwvUy3K','q29TCgXLDgLVBIbsyxrL','ChvZAa','ihbLBMrPBMCSia','yNLtDgf0Dxm','CgvUzgLUzW','B3b0Aw1PEMf0Aw9U','z2vUzxjHDgvqCMvKAwn0Aw9UCW','mta0mZzuzufuA1i','Dw5ZAgLMDa','DgfZA1n0yxr1C2vZ','zxHLy3v0zq','yxv0B1bYAw9YAxrPEMvbBgXuyxnRCW','DgL0Bgu','ywrK','DxbKyxrLrgvWzw5Kzw50vgfZA3m','CgvYzM9YBwfUy2u','zM9YrwfJAa','sw52ywXPzcbWCMLVCML0EsaI','ChjVzhvJDgL2Axr5','qNvNifjLChjVzhvJDgLVBIaMiefUywX5C2LZ','zgvWzw5Kzw5JEv9NyxrL','z2vUzxjHDgvqCMLVCML0EvjLy29TBwvUzgf0Aw9UCW','BwLSzxn0B25Llq','uMvXDwLYzw1LBNrZiefUywX5C2LZ','Dg9tDhjPBMC','z2vUzxjHDgvqCM9NCMvZC1jLy29TBwvUzgf0Aw9UCW','y3jLyxrLza','y2fUy2vSBgvK','rML4ieLTCgXLBwvUDgf0Aw9U','u3rHyMXL','ywDNCMvNyxrLze1LDhjPy3m','B3jPz2LUywXqCMLVCML0Eq','y2fSy3vSyxrLuhjPB3jPDhLuCMvUzhm','otLwrhrysKK','ignVBxbSzxrLzc9Jyw5JzwXSzwqGDgfZA3m','AgfZihn1yNrHC2TZ','DhjHy2TqCM9NCMvZCW','y29TCgXLDgvK','DhjPBq','zNjVBq','Bg9Nz2vY','y29TCgXLDgLVBLjHDgu','sw52ywXPzcbWCM9NCMvZCYbZDgfNztOG','Aw50zwXSAwDLBNrqCMLVCML0AxPHDgLVBG','DgfZAW','z2v0vhjLBMrbBMfSExnPCW','vw5ZDxbWB3j0zwqGywn0Aw9UoIa','BwvZC2fNzq','y29TCgXLDgvKvgfZA3m','AwrLBNrPzNLqyxr0zxjUCW','Aw5KzxHpzG','BgLZDef2ywLSywjSzvrLBxbSyxrLCW','zgvWzw5Kzw5JAwvZ','ChjLzgLJDfbYAw9YAxr5u2HPzNq','yMXVy2TZ','uhjVz3jLC3mGtwLSzxn0B25L','z2vUzxjHDgvuzxH0u3vTBwfYEq','D29YA2XVywrty29Yzq','vgfZAYbSAxn0ihn5BMnOCM9UAxPLzcbZDwnJzxnZzNvSBhK','C3rYAw5N','Dg90ywXuyxnRCW','BwfUDwfS','rw5KlxrVlwvUzcbMzwf0DxjLigrLDMvSB3bTzw50ihDVCMTMBg93','CMv2Awv3x3bVAw50','y2fUy2vSvgfZAW','yxzLCMfNzvbYB2DYzxnZ','z2vUzxjHDgvxB3jRzMXVD1zPC3vHBgL6yxrPB24','DgfZAY0','iI4GtxvZDcbIztOG','mti1mJjzthL4Ehy','ChjPB3jPDhK','qMfSyw5JzwqGChjPB3jPDhKGzgLZDhjPyNv0Aw9U','CMvSyxrLCW','yxbWBhLqCM9Qzwn0q29UDgv4Da','z2v0qwXSqwDLBNrZ','yMXVy2TLzf90yxnRCW','y3vZDg9TvgvTCgXHDgvZ','CMvSyxrLvgfZAW','DgfZA0XPC3q','BgfZDfvWzgf0zwq','zM9YzwnHC3rZ','BM90x3n0yxj0zwq','DgfZA0LK','ChjPB3jPDhLtAgLMDa','u3vIDgfZAYbJCMvHDgvKihn1y2nLC3nMDwXSEq','C3LUy1rHC2TZ','zgvZy3jPChrPB24','ihrHC2TZigfYzsbPBIbWCM9NCMvZCYbIDxqGC2HVD2LUzYbSB3CGChjVz3jLC3mUienVBNnPzgvYigjYzwfRAw5NihrOzw0GAw50BYbZBwfSBgvYihn1yNrHC2TZlG','CMvKDwnL','yxv0BW','DxbKyxrLzef0','CgXHBM5PBMC','rMfPBgvKihrVihvWzgf0zsbKzxbLBMrLBNqGDgfZA3m','DgfZA3m','y2fSy3vSyxrLvgfZA1bYB2DYzxnZ','zw5KCg9PBNq','z2vUzxjHDgvcywXHBMnPBMDszwnVBw1LBMrHDgLVBG','t3zLCMfSBcbWCM9NCMvZCYbPCYbSB3CUienVBNnPzgvYihbYAw9YAxrPEMLUzYbHBMqGzM9JDxnPBMCGB24GzMv3zxiGDgfZA3mU','ywDLBNrZ','z2v0u3rHz2vgCM9TugvYy2vUDgfNzq','y2fSy3vSyxrLuMv3B3jRuMf0zq','v2vLA2X5ihbHDhrLCM5ZigrLDgvJDgvKic0GzNvYDgHLCIbHBMfSExnPCYbHDMfPBgfIBgu','mJaXnxnjquPryq','zgf0zq','vgvZDgLUzYaMifzLCMLMAwnHDgLVBG','y2fSy3vSyxrLvgvTCgXHDgvfzMzPy2LLBMn5','y3jLyxrLrgvWzw5Kzw5JEq','rgvZAwDUicyGqxjJAgL0zwn0DxjL','ywDLBNrqB29S','Dg90ywXdB21WBgv0zwq','BwLSzxn0B25L','y2f0zwDVCNK','icHqCMLVCML0EtOG','DxbKyxrL','C3vIDgfZA3m','yNLtDgfNzq','sw5ZDwzMAwnPzw50igrHDgeGzM9YihbHDhrLCM4Gyw5HBhLZAxm','vg90ywWGvgfZA3m','BwfUywDLtwLSzxn0B25LCW','rgv0zwn0zwqGqvbjlxjLBgf0zwqGDgfZA3m','zwzMAwnPzw5JEq','q29TCgXLDgLVBIbYyxrLigLZigjLBg93iduWjs4Gq29UC2LKzxiGCMv2Awv3Aw5NihrHC2SGChjPB3jPDgL6yxrPB24Gyw5KigjSB2nRAw5NigLZC3vLCY4','uhjVAMvJDcbtzxr1CcaMifbSyw5UAw5N','BwfW','z2vUzxjHDgvqCM9KDwn0AxzPDhLjBNnPz2H0CW','zM9YBwf0uMvZDwX0','zgvWzw5Kzw5JEvr5CgvZ','Dg9mB3DLCKnHC2u','sw52ywXPzcbKzxbLBMrLBMn5ihr5Cgu6ia','y2fSy3vSyxrLv2vLA2X5vhjLBMrZ','lIbtDxbWB3j0zwq6ia','BgvUz3rO','z2v0rgf0zq','txvSDgLWBguGyMXVy2TLzcb0yxnRCYaTihjLDMLLDYbKzxbLBMrLBMn5ig1HBMfNzw1LBNq','rM9JDxmGB24GDgfZAYbJB21WBgv0Aw9Uihn0CMf0zwDPzxm','ywDL','q29TCgXLDguGD29YA2zSB3CGzM9Yigj1AwXKAw5NigeGD2vIigfWCgXPy2f0Aw9U','qMfJA2vUzcbbueKGrgv2zwXVCg1LBNq','C2XPy2u','rgf0ywjHC2uGrgvZAwDUicyGu2v0Dxa','D29YA2XVywrgB3jLy2fZDa','qxv0AgvUDgLJyxrPB24Gu2v0Dxa','zw50CMLLCW','zMLUzfrHC2TZqMXVy2TLzej5','ntC3nJm2nwzqq0vKqG','D2fYBMLUzW','DMfSDwvZ','CgfYC2u','BwLU','y2fSy3vSyxrLqxzLCMfNzunVBxbSzxrPB25uAw1L','C3vIDgfZAW','C3rHz2u','B3zLCNzPzxC','z2vUzxjHDgvbBMfSExrPy3m','rgv0zwn0zwqGzMvHDhvYzsbKzxzLBg9WBwvUDcb0yxnRCW','C3vTBwfYEq','igrHExm','u3r1zhKGqvbjigrVy3vTzw50yxrPB24Sigf1DgHLBNrPy2f0Aw9UlcbHBMqGCMf0zsbSAw1PDhm'];a0_0x9cd7=function(){return _0x5d2481;};return a0_0x9cd7();}import{BaseTool}from'./baseTool.js';function a0_0x411c(_0x3c0ddc,_0x59633){_0x3c0ddc=_0x3c0ddc-0x15a;const _0x9cd74d=a0_0x9cd7();let _0x411c40=_0x9cd74d[_0x3c0ddc];if(a0_0x411c['lAGemc']===undefined){var _0x2f4aa4=function(_0x3c2c48){const _0x166bbb='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1a371e='',_0x124d9a='';for(let _0x18394d=0x0,_0x24f140,_0x396765,_0x35eb13=0x0;_0x396765=_0x3c2c48['charAt'](_0x35eb13++);~_0x396765&&(_0x24f140=_0x18394d%0x4?_0x24f140*0x40+_0x396765:_0x396765,_0x18394d++%0x4)?_0x1a371e+=String['fromCharCode'](0xff&_0x24f140>>(-0x2*_0x18394d&0x6)):0x0){_0x396765=_0x166bbb['indexOf'](_0x396765);}for(let _0x584829=0x0,_0x7f8bac=_0x1a371e['length'];_0x584829<_0x7f8bac;_0x584829++){_0x124d9a+='%'+('00'+_0x1a371e['charCodeAt'](_0x584829)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x124d9a);};a0_0x411c['rbjkJF']=_0x2f4aa4,a0_0x411c['SgXcJa']={},a0_0x411c['lAGemc']=!![];}const _0x400ab8=_0x9cd74d[0x0],_0x527e55=_0x3c0ddc+_0x400ab8,_0x99e0ed=a0_0x411c['SgXcJa'][_0x527e55];return!_0x99e0ed?(_0x411c40=a0_0x411c['rbjkJF'](_0x411c40),a0_0x411c['SgXcJa'][_0x527e55]=_0x411c40):_0x411c40=_0x99e0ed,_0x411c40;}import{v4 as a0_0x1a371e}from'uuid';class TaskManagerTool extends BaseTool{constructor(_0x124d9a={}){const _0x2d174a=a0_0x411c;super({'name':'taskmanager','description':_0x124d9a['description']||_0x2d174a(0x239),..._0x124d9a}),this[_0x2d174a(0x213)]=['create','update','list','complete','cancel',_0x2d174a(0x233),'depend',_0x2d174a(0x1bf),_0x2d174a(0x178),_0x2d174a(0x214),'template','progress','analytics',_0x2d174a(0x220)],this[_0x2d174a(0x24d)]=[_0x2d174a(0x248),_0x2d174a(0x1f3),_0x2d174a(0x1b2),_0x2d174a(0x269),'cancelled'],this['taskPriorities']=[_0x2d174a(0x1b4),_0x2d174a(0x19e),'medium','low'],this['dependencyTypes']=['blocks',_0x2d174a(0x28c),_0x2d174a(0x178),_0x2d174a(0x235)],this['progressStages']=['not_started',_0x2d174a(0x29f),_0x2d174a(0x19a),'testing',_0x2d174a(0x1c3),_0x2d174a(0x269)],this['milestoneTypes']=['checkpoint','deliverable',_0x2d174a(0x283),_0x2d174a(0x258)],this['priorityWeights']={'blocking':0x3,'age':1.5,'userPriority':0x2,'contextSwitching':1.2,'dependency':1.8},this['taskTemplates']={'web-app-development':{'name':'Web\x20Application\x20Development','description':_0x2d174a(0x16a),'category':'development','tasks':[{'title':'Project\x20Setup\x20&\x20Planning','description':_0x2d174a(0x180),'priority':'high','dependencies':[]},{'title':_0x2d174a(0x16d),'description':'Design\x20database\x20schema,\x20create\x20tables,\x20and\x20set\x20up\x20connections','priority':_0x2d174a(0x19e),'dependencies':[_0x2d174a(0x15c)]},{'title':_0x2d174a(0x16b),'description':_0x2d174a(0x190),'priority':_0x2d174a(0x19e),'dependencies':[_0x2d174a(0x16d)]},{'title':'Frontend\x20Development','description':'Build\x20user\x20interface\x20components\x20and\x20implement\x20client-side\x20logic','priority':'medium','dependencies':[_0x2d174a(0x16b)]},{'title':'Testing\x20&\x20Quality\x20Assurance','description':'Write\x20and\x20run\x20unit\x20tests,\x20integration\x20tests,\x20and\x20perform\x20QA','priority':_0x2d174a(0x1f9),'dependencies':['Frontend\x20Development']},{'title':'Deployment\x20&\x20Launch','description':'Deploy\x20to\x20production\x20environment\x20and\x20monitor\x20launch','priority':_0x2d174a(0x19e),'dependencies':['Testing\x20&\x20Quality\x20Assurance']}]},'api-integration':{'name':'API\x20Integration','description':'Standard\x20workflow\x20for\x20integrating\x20with\x20external\x20APIs','category':'integration','tasks':[{'title':'API\x20Research\x20&\x20Documentation\x20Review','description':_0x2d174a(0x17f),'priority':'high','dependencies':[]},{'title':_0x2d174a(0x16f),'description':_0x2d174a(0x1f4),'priority':_0x2d174a(0x19e),'dependencies':['API\x20Research\x20&\x20Documentation\x20Review']},{'title':'Core\x20Integration\x20Implementation','description':'Build\x20API\x20client\x20and\x20implement\x20main\x20integration\x20logic','priority':_0x2d174a(0x19e),'dependencies':['Authentication\x20Setup']},{'title':'Error\x20Handling\x20&\x20Retry\x20Logic','description':_0x2d174a(0x1a7),'priority':_0x2d174a(0x1f9),'dependencies':['Core\x20Integration\x20Implementation']},{'title':_0x2d174a(0x203),'description':_0x2d174a(0x1f7),'priority':_0x2d174a(0x1f9),'dependencies':['Error\x20Handling\x20&\x20Retry\x20Logic']}]},'bug-fix':{'name':_0x2d174a(0x1d3),'description':_0x2d174a(0x181),'category':'maintenance','tasks':[{'title':_0x2d174a(0x257),'description':'Reproduce\x20the\x20bug\x20and\x20analyze\x20root\x20cause','priority':'urgent','dependencies':[]},{'title':'Fix\x20Implementation','description':'Implement\x20the\x20bug\x20fix\x20with\x20minimal\x20side\x20effects','priority':_0x2d174a(0x1b4),'dependencies':[_0x2d174a(0x257)]},{'title':_0x2d174a(0x2ac),'description':_0x2d174a(0x19b),'priority':'high','dependencies':[_0x2d174a(0x260)]},{'title':'Documentation\x20Update','description':'Update\x20documentation\x20if\x20behavior\x20changed','priority':_0x2d174a(0x1f6),'dependencies':[_0x2d174a(0x2ac)]}]},'feature-development':{'name':'Feature\x20Development','description':_0x2d174a(0x282),'category':'development','tasks':[{'title':_0x2d174a(0x25b),'description':'Analyze\x20requirements\x20and\x20create\x20technical\x20specification','priority':_0x2d174a(0x19e),'dependencies':[]},{'title':_0x2d174a(0x2af),'description':_0x2d174a(0x211),'priority':'high','dependencies':[_0x2d174a(0x25b)]},{'title':_0x2d174a(0x1c8),'description':'Implement\x20backend\x20logic\x20and\x20data\x20models','priority':'high','dependencies':[_0x2d174a(0x2af)]},{'title':'Frontend\x20Implementation','description':'Build\x20user\x20interface\x20and\x20integrate\x20with\x20backend','priority':_0x2d174a(0x1f9),'dependencies':[_0x2d174a(0x1c8)]},{'title':_0x2d174a(0x192),'description':'Write\x20tests\x20and\x20update\x20documentation','priority':'medium','dependencies':['Frontend\x20Implementation']}]}};}['getDescription'](){return'\x0aTask\x20Manager\x20Tool:\x20Organize\x20and\x20track\x20work\x20with\x20TODO\x20lists\x20for\x20agent-mode\x20scheduling.\x0a\x0a**CRITICAL\x20FOR\x20AGENT\x20MODE**:\x20You\x20MUST\x20maintain\x20your\x20task\x20list\x20to\x20remain\x20active\x20in\x20agent\x20mode!\x0a\x0aThe\x20TaskManager\x20tool\x20allows\x20you\x20to\x20organize\x20and\x20track\x20your\x20work.\x20Without\x20tasks,\x20you\x20will\x20not\x20receive\x20scheduling\x20time.\x0a\x0a###\x20Actions:\x0a-\x20**sync**:\x20🌟\x20RECOMMENDED\x20-\x20Manage\x20entire\x20task\x20list\x20at\x20once\x20(Claude\x20Code\x20style)\x0a-\x20**create**:\x20Create\x20a\x20new\x20task\x20with\x20title\x20and\x20description\x0a-\x20**update**:\x20Update\x20task\x20status\x20or\x20properties\x0a-\x20**list**:\x20List\x20all\x20tasks\x20with\x20their\x20current\x20status\x0a-\x20**complete**:\x20Mark\x20a\x20task\x20as\x20completed\x0a-\x20**cancel**:\x20Cancel\x20a\x20task\x20(mark\x20as\x20irrelevant)\x0a-\x20**clear**:\x20Clear\x20all\x20completed/cancelled\x20tasks\x0a-\x20**depend**:\x20Create\x20dependency\x20between\x20tasks\x20(blocking\x20relationships)\x0a-\x20**relate**:\x20Link\x20related\x20tasks\x20(non-blocking\x20associations)\x0a-\x20**subtask**:\x20Create\x20subtask\x20relationships\x20(parent-child\x20hierarchy)\x0a-\x20**prioritize**:\x20Intelligent\x20task\x20prioritization\x20with\x20multiple\x20modes\x0a-\x20**template**:\x20Template\x20management\x20for\x20common\x20workflows\x0a-\x20**progress**:\x20Track\x20task\x20progress\x20with\x20stages,\x20milestones,\x20and\x20notes\x0a\x0a###\x20Usage\x20Examples:\x0a\x0a✨\x20Sync\x20entire\x20task\x20list\x20(RECOMMENDED\x20-\x20create\x20comprehensive\x20breakdown):\x0a<taskmanager>\x0a<action>sync</action>\x0a<tasks>[\x0a\x20\x20{\x0a\x20\x20\x20\x20\x22title\x22:\x20\x22Analyze\x20user\x20requirements\x22,\x0a\x20\x20\x20\x20\x22description\x22:\x20\x22Understand\x20what\x20the\x20user\x20wants\x20to\x20achieve\x22,\x0a\x20\x20\x20\x20\x22status\x22:\x20\x22completed\x22,\x0a\x20\x20\x20\x20\x22priority\x22:\x20\x22high\x22\x0a\x20\x20},\x0a\x20\x20{\x0a\x20\x20\x20\x20\x22title\x22:\x20\x22Design\x20database\x20schema\x22,\x0a\x20\x20\x20\x20\x22description\x22:\x20\x22Create\x20tables\x20and\x20relationships\x22,\x0a\x20\x20\x20\x20\x22status\x22:\x20\x22in_progress\x22,\x0a\x20\x20\x20\x20\x22priority\x22:\x20\x22high\x22\x0a\x20\x20},\x0a\x20\x20{\x0a\x20\x20\x20\x20\x22title\x22:\x20\x22Implement\x20API\x20endpoints\x22,\x0a\x20\x20\x20\x20\x22status\x22:\x20\x22pending\x22,\x0a\x20\x20\x20\x20\x22priority\x22:\x20\x22medium\x22\x0a\x20\x20},\x0a\x20\x20{\x0a\x20\x20\x20\x20\x22title\x22:\x20\x22Write\x20tests\x22,\x0a\x20\x20\x20\x20\x22status\x22:\x20\x22pending\x22,\x0a\x20\x20\x20\x20\x22priority\x22:\x20\x22medium\x22\x0a\x20\x20}\x0a]</tasks>\x0a</taskmanager>\x0a\x0aCreate\x20a\x20task:\x0a<taskmanager>\x0a<action>create</action>\x0a<title>Analyze\x20user\x20requirements</title>\x0a<description>Break\x20down\x20the\x20user\x27s\x20request\x20into\x20actionable\x20steps</description>\x0a<priority>high</priority>\x0a</taskmanager>\x0a\x0aList\x20all\x20tasks:\x0a<taskmanager>\x0a<action>list</action>\x0a</taskmanager>\x0a\x0aCreate\x20task\x20dependency:\x0a<taskmanager>\x0a<action>depend</action>\x0a<taskId>task-uuid-here</taskId>\x0a<dependsOn>other-task-uuid</dependsOn>\x0a<dependencyType>blocks</dependencyType>\x0a</taskmanager>\x0a\x0aCreate\x20subtask:\x0a<taskmanager>\x0a<action>subtask</action>\x0a<parentTaskId>parent-task-uuid</parentTaskId>\x0a<title>Implement\x20user\x20authentication</title>\x0a<description>Create\x20login\x20and\x20signup\x20functionality</description>\x0a<priority>high</priority>\x0a</taskmanager>\x0a\x0aAuto-prioritize\x20all\x20tasks:\x0a<taskmanager>\x0a<action>prioritize</action>\x0a<mode>auto</mode>\x0a</taskmanager>\x0a\x0aAnalyze\x20specific\x20task\x20priority:\x0a<taskmanager>\x0a<action>prioritize</action>\x0a<mode>analyze</mode>\x0a<taskId>task-uuid-here</taskId>\x0a</taskmanager>\x0a\x0aBalance\x20workload\x20across\x20agents:\x0a<taskmanager>\x0a<action>prioritize</action>\x0a<mode>balance</mode>\x0a</taskmanager>\x0a\x0aList\x20available\x20templates:\x0a<taskmanager>\x0a<action>template</action>\x0a<mode>list</mode>\x0a</taskmanager>\x0a\x0aApply\x20web\x20app\x20development\x20template:\x0a<taskmanager>\x0a<action>template</action>\x0a<mode>apply</mode>\x0a<templateId>web-app-development</templateId>\x0a<projectContext>{\x22projectName\x22:\x20\x22UserPortal\x22,\x20\x22urgency\x22:\x20\x22high\x22}</projectContext>\x0a</taskmanager>\x0a\x0aSuggest\x20templates\x20based\x20on\x20current\x20tasks:\x0a<taskmanager>\x0a<action>template</action>\x0a<mode>suggest</mode>\x0a</taskmanager>\x0a\x0aUpdate\x20task\x20progress:\x0a<taskmanager>\x0a<action>progress</action>\x0a<mode>update</mode>\x0a<taskId>task-uuid-here</taskId>\x0a<stage>in_development</stage>\x0a<percentage>45</percentage>\x0a<note>Completed\x20API\x20integration,\x20starting\x20frontend\x20work</note>\x0a</taskmanager>\x0a\x0aGet\x20progress\x20overview:\x0a<taskmanager>\x0a<action>progress</action>\x0a<mode>overview</mode>\x0a</taskmanager>\x0a\x0aCalculate\x20progress\x20based\x20on\x20subtasks:\x0a<taskmanager>\x0a<action>progress</action>\x0a<mode>calculate</mode>\x0a<taskId>task-uuid-here</taskId>\x0a</taskmanager>\x0a\x0a###\x20🚨\x20MANDATORY\x20WORKFLOW\x20-\x20ZERO\x20EXCEPTIONS\x20ALLOWED:\x0a\x0a**EVERY\x20RESPONSE\x20MUST:**\x0a1.\x20**START\x20WITH**:\x20<taskmanager><action>list</action></taskmanager>\x0a2.\x20**WORK**:\x20Complete\x20the\x20user\x27s\x20request\x20\x20\x0a3.\x20**END\x20WITH**:\x20<taskmanager><action>complete</action><taskId>ID</taskId></taskmanager>\x0a\x0a**WARNING:\x20Skipping\x20this\x20workflow\x20=\x20INFINITE\x20LOOPS\x20=\x20SYSTEM\x20FAILURE!**\x0a**NO\x20RESPONSE\x20IS\x20COMPLETE\x20WITHOUT\x20TASK\x20COMPLETION!**\x0a\x0aSTEP\x201\x20-\x20Always\x20start\x20by\x20listing\x20tasks:\x0a<taskmanager>\x0a<action>list</action>\x0a</taskmanager>\x0a\x0aSTEP\x202\x20-\x20After\x20completing\x20work,\x20mark\x20task\x20complete:\x0a<taskmanager>\x0a<action>complete</action>\x0a<taskId>task-1759257696373-wjsquroxz</taskId>\x0a</taskmanager>\x0a\x0a###\x20MANDATORY:\x20Complete\x20tasks\x20when\x20done\x20or\x20you\x27ll\x20loop\x20forever!\x0a';}[a0_0x358c72(0x23f)](_0x18394d){const _0x4420a1=a0_0x358c72;if(typeof _0x18394d==='string')return{'rawContent':_0x18394d};if(typeof _0x18394d===_0x4420a1(0x1fc)&&_0x18394d!==null){const _0x24f140={};for(const [_0x396765,_0x35eb13]of Object[_0x4420a1(0x170)](_0x18394d)){_0x35eb13&&typeof _0x35eb13==='object'&&'value'in _0x35eb13?_0x24f140[_0x396765]=_0x35eb13[_0x4420a1(0x204)]:_0x24f140[_0x396765]=_0x35eb13;}return _0x24f140;}return _0x18394d;}async[a0_0x358c72(0x24e)](_0x584829,_0x7f8bac){const _0x32be01=a0_0x358c72;try{const _0x330be0={};for(const [_0x35fee7,_0x237ae1]of Object['entries'](_0x584829)){_0x237ae1&&typeof _0x237ae1==='object'&&'value'in _0x237ae1?_0x330be0[_0x35fee7]=_0x237ae1['value']:_0x330be0[_0x35fee7]=_0x237ae1;}_0x584829=_0x330be0;const {agentId:_0x37cb2d,agentName:_0x9cf2b9}=_0x7f8bac;if(!_0x37cb2d)throw new Error('Agent\x20ID\x20is\x20required\x20for\x20task\x20management');const _0x1aaf73=await _0x7f8bac[_0x32be01(0x2b0)]['getAgent'](_0x37cb2d);if(!_0x1aaf73)throw new Error(_0x32be01(0x23d)+_0x37cb2d);!_0x1aaf73['taskList']&&(_0x1aaf73['taskList']={'tasks':[],'lastUpdated':new Date()['toISOString']()});const _0x18912f=_0x584829['action']?.['toLowerCase']();if(!this['supportedActions'][_0x32be01(0x184)](_0x18912f))throw new Error(_0x32be01(0x272)+_0x18912f+_0x32be01(0x164)+this['supportedActions']['join'](',\x20'));let _0x31f1ba;switch(_0x18912f){case _0x32be01(0x1e9):_0x31f1ba=await this['createTask'](_0x1aaf73,_0x584829);break;case'update':_0x31f1ba=await this[_0x32be01(0x1ca)](_0x1aaf73,_0x584829);break;case _0x32be01(0x226):_0x31f1ba=await this['listTasks'](_0x1aaf73,_0x584829);break;case'complete':_0x31f1ba=await this['completeTask'](_0x1aaf73,_0x584829);break;case'cancel':_0x31f1ba=await this[_0x32be01(0x284)](_0x1aaf73,_0x584829);break;case _0x32be01(0x233):_0x31f1ba=await this['clearCompletedTasks'](_0x1aaf73,_0x584829);break;case _0x32be01(0x1bb):_0x31f1ba=await this[_0x32be01(0x2ae)](_0x1aaf73,_0x584829);break;case _0x32be01(0x1bf):_0x31f1ba=await this[_0x32be01(0x291)](_0x1aaf73,_0x584829);break;case _0x32be01(0x178):_0x31f1ba=await this['createSubtask'](_0x1aaf73,_0x584829);break;case'prioritize':_0x31f1ba=await this[_0x32be01(0x26f)](_0x1aaf73,_0x584829);break;case'template':_0x31f1ba=await this['manageTemplates'](_0x1aaf73,_0x584829);break;case _0x32be01(0x200):_0x31f1ba=await this['trackProgress'](_0x1aaf73,_0x584829);break;case _0x32be01(0x21c):_0x31f1ba=await this[_0x32be01(0x17b)](_0x1aaf73,_0x584829);break;case'sync':_0x31f1ba=await this['syncTasks'](_0x1aaf73,_0x584829);break;default:throw new Error('Unknown\x20action:\x20'+_0x18912f);}return _0x1aaf73['lastActivity']=new Date()['toISOString'](),_0x1aaf73[_0x32be01(0x292)][_0x32be01(0x293)]=new Date()[_0x32be01(0x212)](),await _0x7f8bac[_0x32be01(0x2b0)]['persistAgentState'](_0x37cb2d),this['logger']?.['info']('TaskManager\x20action\x20executed:\x20'+_0x18912f,{'agentId':_0x37cb2d,'agentName':_0x9cf2b9,'action':_0x18912f,'taskCount':_0x1aaf73['taskList']['tasks']['length'],'pendingTasks':_0x1aaf73[_0x32be01(0x292)][_0x32be01(0x2a1)][_0x32be01(0x20b)](_0x1e6848=>_0x1e6848['status']==='pending')['length'],'inProgressTasks':_0x1aaf73['taskList'][_0x32be01(0x2a1)]['filter'](_0x552aa2=>_0x552aa2['status']==='in_progress')[_0x32be01(0x165)]}),{'success':!![],'action':_0x18912f,'result':_0x31f1ba,'summary':this[_0x32be01(0x1e2)](_0x1aaf73['taskList'])};}catch(_0x349cd2){return this['logger']?.['error']('TaskManager\x20execution\x20failed',{'error':_0x349cd2['message'],'context':_0x7f8bac,'params':_0x584829}),{'success':![],'error':_0x349cd2[_0x32be01(0x273)]};}}async[a0_0x358c72(0x208)](_0x416eb2,_0x50c5c5){const _0xdb812d=a0_0x358c72,{title:_0x383402,description:description='',priority:priority='medium'}=_0x50c5c5;if(!_0x383402)throw new Error(_0xdb812d(0x1d1));if(priority&&!this['taskPriorities'][_0xdb812d(0x184)](priority[_0xdb812d(0x161)]()))throw new Error('Invalid\x20priority:\x20'+priority+'.\x20Must\x20be:\x20'+this['taskPriorities']['join'](',\x20'));const _0x1824f4={'id':'task-'+a0_0x1a371e(),'title':_0x383402,'description':description,'status':_0xdb812d(0x248),'priority':priority[_0xdb812d(0x161)](),'createdAt':new Date()[_0xdb812d(0x212)](),'updatedAt':new Date()['toISOString']()};return _0x416eb2['taskList']['tasks']['push'](_0x1824f4),{'message':'Task\x20created\x20successfully','task':_0x1824f4};}async[a0_0x358c72(0x299)](_0x6ad14b,_0x2f147){const _0x4a2e8b=a0_0x358c72;let {tasks:_0x37efd5}=_0x2f147;if(typeof _0x37efd5===_0x4a2e8b(0x27f))try{_0x37efd5=JSON[_0x4a2e8b(0x175)](_0x37efd5);}catch(_0x5b8190){throw new Error('Invalid\x20tasks\x20JSON:\x20'+_0x5b8190['message']);}if(!Array['isArray'](_0x37efd5))throw new Error('Tasks\x20must\x20be\x20an\x20array');if(_0x37efd5['length']===0x0)throw new Error(_0x4a2e8b(0x1aa));const _0x4a88c4=new Date()[_0x4a2e8b(0x212)](),_0x5916cf=_0x6ad14b[_0x4a2e8b(0x292)]['tasks']||[],_0x48188d=[],_0x55254a=[],_0x382a1f=new Set(),_0x5d0690=_0x4f5f28=>{const _0x2c9f4a=_0x4a2e8b,_0x497fde=_0x4f5f28['toLowerCase']()[_0x2c9f4a(0x26a)]();return _0x5916cf[_0x2c9f4a(0x1fb)](_0x2ad4f6=>_0x2ad4f6['title'][_0x2c9f4a(0x161)]()[_0x2c9f4a(0x26a)]()===_0x497fde&&!_0x382a1f['has'](_0x2ad4f6['id']));};for(const _0x1b7bfe of _0x37efd5){if(!_0x1b7bfe['title'])throw new Error(_0x4a2e8b(0x196));const _0xff8513=(_0x1b7bfe['status']||_0x4a2e8b(0x248))[_0x4a2e8b(0x161)](),_0x2705f1=(_0x1b7bfe['priority']||_0x4a2e8b(0x1f9))[_0x4a2e8b(0x161)]();if(!this[_0x4a2e8b(0x24d)]['includes'](_0xff8513))throw new Error('Invalid\x20status\x20\x22'+_0xff8513+_0x4a2e8b(0x1dc)+_0x1b7bfe[_0x4a2e8b(0x250)]+'\x22.\x20Must\x20be:\x20'+this[_0x4a2e8b(0x24d)]['join'](',\x20'));if(!this[_0x4a2e8b(0x1a2)][_0x4a2e8b(0x184)](_0x2705f1))throw new Error(_0x4a2e8b(0x255)+_0x2705f1+_0x4a2e8b(0x1dc)+_0x1b7bfe['title']+_0x4a2e8b(0x288)+this['taskPriorities'][_0x4a2e8b(0x221)](',\x20'));const _0x38643d=_0x5d0690(_0x1b7bfe['title']);if(_0x38643d)_0x38643d['status']=_0xff8513,_0x38643d['priority']=_0x2705f1,_0x1b7bfe[_0x4a2e8b(0x29a)]!==undefined&&(_0x38643d['description']=_0x1b7bfe['description']),_0x38643d['updatedAt']=_0x4a88c4,_0x48188d[_0x4a2e8b(0x245)](_0x38643d),_0x382a1f[_0x4a2e8b(0x251)](_0x38643d['id']);else{const _0x114948={'id':_0x4a2e8b(0x287)+a0_0x1a371e(),'title':_0x1b7bfe[_0x4a2e8b(0x250)],'description':_0x1b7bfe[_0x4a2e8b(0x29a)]||'','status':_0xff8513,'priority':_0x2705f1,'createdAt':_0x4a88c4,'updatedAt':_0x4a88c4,'source':_0x4a2e8b(0x220)};_0x55254a[_0x4a2e8b(0x245)](_0x114948);}}_0x6ad14b['taskList'][_0x4a2e8b(0x2a1)]=[..._0x48188d,..._0x55254a];const _0x88b3c9=_0x6ad14b[_0x4a2e8b(0x292)]['tasks'][_0x4a2e8b(0x20b)](_0x2681c5=>_0x2681c5[_0x4a2e8b(0x222)]===_0x4a2e8b(0x1f3));if(_0x88b3c9['length']>0x1)for(let _0x18dcd6=0x1;_0x18dcd6<_0x88b3c9['length'];_0x18dcd6++){_0x88b3c9[_0x18dcd6][_0x4a2e8b(0x222)]='pending';}if(_0x88b3c9[_0x4a2e8b(0x165)]===0x0){const _0x17594a=_0x6ad14b['taskList'][_0x4a2e8b(0x2a1)]['find'](_0x5485e5=>_0x5485e5['status']===_0x4a2e8b(0x248));_0x17594a&&(_0x17594a[_0x4a2e8b(0x222)]='in_progress',_0x17594a['updatedAt']=_0x4a88c4);}return _0x6ad14b['taskList'][_0x4a2e8b(0x293)]=_0x4a88c4,{'message':_0x4a2e8b(0x27e),'summary':{'total':_0x6ad14b['taskList']['tasks']['length'],'created':_0x55254a[_0x4a2e8b(0x165)],'updated':_0x48188d[_0x4a2e8b(0x165)],'removed':_0x5916cf[_0x4a2e8b(0x165)]-_0x382a1f['size'],'pending':_0x6ad14b['taskList'][_0x4a2e8b(0x2a1)]['filter'](_0x10c92d=>_0x10c92d[_0x4a2e8b(0x222)]==='pending')[_0x4a2e8b(0x165)],'inProgress':_0x6ad14b['taskList'][_0x4a2e8b(0x2a1)][_0x4a2e8b(0x20b)](_0x39c4da=>_0x39c4da[_0x4a2e8b(0x222)]==='in_progress')['length'],'completed':_0x6ad14b[_0x4a2e8b(0x292)][_0x4a2e8b(0x2a1)]['filter'](_0x4cc757=>_0x4cc757[_0x4a2e8b(0x222)]===_0x4a2e8b(0x269))[_0x4a2e8b(0x165)],'cancelled':_0x6ad14b['taskList'][_0x4a2e8b(0x2a1)]['filter'](_0x3d9e4d=>_0x3d9e4d['status']===_0x4a2e8b(0x25f))[_0x4a2e8b(0x165)]},'tasks':_0x6ad14b[_0x4a2e8b(0x292)][_0x4a2e8b(0x2a1)]['map'](_0x27e7f8=>({'id':_0x27e7f8['id'],'title':_0x27e7f8['title'],'status':_0x27e7f8[_0x4a2e8b(0x222)],'priority':_0x27e7f8[_0x4a2e8b(0x28a)]}))};}async['updateTask'](_0x15f346,_0x32a86f){const _0x3ffaad=a0_0x358c72,{taskId:_0x310a96,status:_0xadf229,priority:_0x1d9a09,title:_0x42af20,description:_0x51bfe7}=_0x32a86f;if(!_0x310a96)throw new Error('Task\x20ID\x20is\x20required\x20for\x20update');const _0x22879d=_0x15f346['taskList']['tasks']['find'](_0x555a84=>_0x555a84['id']===_0x310a96);if(!_0x22879d)throw new Error('Task\x20not\x20found:\x20'+_0x310a96);if(_0xadf229){if(!this['taskStatuses'][_0x3ffaad(0x184)](_0xadf229['toLowerCase']()))throw new Error('Invalid\x20status:\x20'+_0xadf229+'.\x20Must\x20be:\x20'+this['taskStatuses']['join'](',\x20'));_0x22879d['status']=_0xadf229[_0x3ffaad(0x161)]();}if(_0x1d9a09){if(!this[_0x3ffaad(0x1a2)]['includes'](_0x1d9a09[_0x3ffaad(0x161)]()))throw new Error('Invalid\x20priority:\x20'+_0x1d9a09+'.\x20Must\x20be:\x20'+this[_0x3ffaad(0x1a2)][_0x3ffaad(0x221)](',\x20'));_0x22879d['priority']=_0x1d9a09['toLowerCase']();}if(_0x42af20!==undefined)_0x22879d[_0x3ffaad(0x250)]=_0x42af20;if(_0x51bfe7!==undefined)_0x22879d['description']=_0x51bfe7;return _0x22879d[_0x3ffaad(0x29e)]=new Date()['toISOString'](),{'message':_0x3ffaad(0x1e3),'task':_0x22879d};}async[a0_0x358c72(0x1cd)](_0xad6c02,_0x52f7f6){const _0x3fe157=a0_0x358c72,{status:_0x9a2723,priority:_0x4d9160}=_0x52f7f6;let _0x3c25e9=[..._0xad6c02[_0x3fe157(0x292)][_0x3fe157(0x2a1)]];if(_0x9a2723){if(!this[_0x3fe157(0x24d)][_0x3fe157(0x184)](_0x9a2723['toLowerCase']()))throw new Error('Invalid\x20status\x20filter:\x20'+_0x9a2723);_0x3c25e9=_0x3c25e9['filter'](_0x506e83=>_0x506e83[_0x3fe157(0x222)]===_0x9a2723[_0x3fe157(0x161)]());}if(_0x4d9160){if(!this[_0x3fe157(0x1a2)][_0x3fe157(0x184)](_0x4d9160['toLowerCase']()))throw new Error('Invalid\x20priority\x20filter:\x20'+_0x4d9160);_0x3c25e9=_0x3c25e9['filter'](_0x4a7252=>_0x4a7252[_0x3fe157(0x28a)]===_0x4d9160[_0x3fe157(0x161)]());}const _0x3d3a38={'high':0x0,'medium':0x1,'low':0x2};return _0x3c25e9['sort']((_0xbb2dca,_0x43b400)=>{const _0x16fdc8=_0x3fe157,_0x346d9e=_0x3d3a38[_0xbb2dca[_0x16fdc8(0x28a)]]-_0x3d3a38[_0x43b400['priority']];if(_0x346d9e!==0x0)return _0x346d9e;return new Date(_0xbb2dca['createdAt'])-new Date(_0x43b400[_0x16fdc8(0x1d6)]);}),{'totalTasks':_0x3c25e9[_0x3fe157(0x165)],'tasks':_0x3c25e9,'summary':{'pending':_0x3c25e9['filter'](_0x9dbdf4=>_0x9dbdf4['status']==='pending')['length'],'in_progress':_0x3c25e9[_0x3fe157(0x20b)](_0x5b1c92=>_0x5b1c92[_0x3fe157(0x222)]==='in_progress')['length'],'completed':_0x3c25e9[_0x3fe157(0x20b)](_0x39ca25=>_0x39ca25['status']==='completed')['length'],'cancelled':_0x3c25e9['filter'](_0x5e0a16=>_0x5e0a16['status']==='cancelled')['length']}};}async[a0_0x358c72(0x18b)](_0x10d62a,_0x4b6607){const _0x15fd14=a0_0x358c72;let {taskId:_0x4bece1}=_0x4b6607;if(!_0x4bece1){const _0x4ee6eb=_0x10d62a['taskList'][_0x15fd14(0x2a1)][_0x15fd14(0x1fb)](_0x5ed41d=>_0x5ed41d['status']==='in_progress'||_0x5ed41d[_0x15fd14(0x222)]===_0x15fd14(0x248));if(_0x4ee6eb)_0x4bece1=_0x4ee6eb['id'],this[_0x15fd14(0x26c)]?.[_0x15fd14(0x197)]('Auto-completing\x20current\x20task:\x20'+_0x4bece1,{'agentId':_0x10d62a['id'],'taskTitle':_0x4ee6eb[_0x15fd14(0x250)]});else throw new Error('No\x20task\x20ID\x20provided\x20and\x20no\x20in-progress\x20tasks\x20found\x20to\x20complete');}const _0x3313a6=_0x10d62a[_0x15fd14(0x292)]['tasks']['find'](_0x21c5c9=>_0x21c5c9['id']===_0x4bece1);if(!_0x3313a6)throw new Error(_0x15fd14(0x234)+_0x4bece1);if(_0x3313a6['status']===_0x15fd14(0x269))return{'message':'Task\x20already\x20completed','task':_0x3313a6};_0x3313a6['status']=_0x15fd14(0x269),_0x3313a6['completedAt']=new Date()['toISOString'](),_0x3313a6[_0x15fd14(0x29e)]=new Date()[_0x15fd14(0x212)]();if(this[_0x15fd14(0x199)]&&typeof this[_0x15fd14(0x199)]['updateDependentTasks']==='function')try{await this[_0x15fd14(0x199)][_0x15fd14(0x252)](_0x10d62a,_0x4bece1),this['logger']?.[_0x15fd14(0x197)]('Triggered\x20dependency\x20update\x20for\x20completed\x20task',{'taskId':_0x4bece1,'title':_0x3313a6['title']});}catch(_0x301c34){this[_0x15fd14(0x26c)]?.[_0x15fd14(0x230)](_0x15fd14(0x2a0),{'taskId':_0x4bece1,'error':_0x301c34[_0x15fd14(0x273)]});}return{'message':'Task\x20completed\x20successfully','task':_0x3313a6,'dependenciesUpdated':!!this['scheduler']};}async['cancelTask'](_0x233e6c,_0x55c44d){const _0x58fb95=a0_0x358c72,{taskId:_0x58e7e0,reason:reason=''}=_0x55c44d;if(!_0x58e7e0)throw new Error('Task\x20ID\x20is\x20required');const _0xd9d631=_0x233e6c[_0x58fb95(0x292)]['tasks']['find'](_0x4aaa3b=>_0x4aaa3b['id']===_0x58e7e0);if(!_0xd9d631)throw new Error('Task\x20not\x20found:\x20'+_0x58e7e0);return _0xd9d631[_0x58fb95(0x222)]=_0x58fb95(0x25f),_0xd9d631[_0x58fb95(0x22b)]=new Date()['toISOString'](),_0xd9d631['cancellationReason']=reason,_0xd9d631[_0x58fb95(0x29e)]=new Date()[_0x58fb95(0x212)](),{'message':'Task\x20cancelled\x20successfully','task':_0xd9d631};}async['clearCompletedTasks'](_0x233f00,_0x4241fc){const _0x2db393=a0_0x358c72,_0x56ec47=_0x233f00['taskList']['tasks'][_0x2db393(0x165)];_0x233f00['taskList'][_0x2db393(0x2a1)]=_0x233f00[_0x2db393(0x292)][_0x2db393(0x2a1)][_0x2db393(0x20b)](_0x3f8fa1=>_0x3f8fa1['status']==='pending'||_0x3f8fa1[_0x2db393(0x222)]==='in_progress');const _0x3d46ac=_0x56ec47-_0x233f00[_0x2db393(0x292)]['tasks'][_0x2db393(0x165)];return{'message':_0x2db393(0x1c7)+_0x3d46ac+_0x2db393(0x266),'remainingTasks':_0x233f00['taskList']['tasks']['length'],'removed':_0x3d46ac};}async[a0_0x358c72(0x2ae)](_0x50d247,_0x27b3aa){const _0x5534a8=a0_0x358c72,{taskId:_0x5ddcf0,dependsOn:_0x1f5387,dependencyType:dependencyType='blocks'}=_0x27b3aa;if(!_0x5ddcf0||!_0x1f5387)throw new Error('Both\x20taskId\x20and\x20dependsOn\x20are\x20required\x20for\x20creating\x20dependencies');if(!this['dependencyTypes'][_0x5534a8(0x184)](dependencyType))throw new Error(_0x5534a8(0x162)+dependencyType+'.\x20Must\x20be:\x20'+this[_0x5534a8(0x160)][_0x5534a8(0x221)](',\x20'));const _0x156b54=_0x50d247['taskList']['tasks'][_0x5534a8(0x1fb)](_0x571b02=>_0x571b02['id']===_0x5ddcf0),_0x2fd2af=_0x50d247['taskList']['tasks']['find'](_0x2fd19c=>_0x2fd19c['id']===_0x1f5387);if(!_0x156b54)throw new Error('Task\x20not\x20found:\x20'+_0x5ddcf0);if(!_0x2fd2af)throw new Error('Dependency\x20task\x20not\x20found:\x20'+_0x1f5387);!_0x156b54[_0x5534a8(0x278)]&&(_0x156b54[_0x5534a8(0x278)]=[]);const _0xf5aa7c=_0x156b54['dependencies'][_0x5534a8(0x1fb)](_0x53d4fa=>_0x53d4fa['taskId']===_0x1f5387);if(_0xf5aa7c)return{'message':'Dependency\x20already\x20exists','dependency':_0xf5aa7c};const _0x52f3b7={'taskId':_0x1f5387,'type':dependencyType,'createdAt':new Date()['toISOString']()};return _0x156b54['dependencies']['push'](_0x52f3b7),_0x156b54[_0x5534a8(0x29e)]=new Date()[_0x5534a8(0x212)](),dependencyType===_0x5534a8(0x27a)&&_0x2fd2af['status']!=='completed'&&(_0x156b54[_0x5534a8(0x222)]='blocked'),{'message':_0x5534a8(0x209),'dependency':_0x52f3b7,'task':_0x156b54};}async['relateTask'](_0x7d56cf,_0x37095b){const _0x3fd5dc=a0_0x358c72;return await this['createDependency'](_0x7d56cf,{..._0x37095b,'dependencyType':_0x3fd5dc(0x28c)});}async['createSubtask'](_0x1b839c,_0xdfaf40){const _0x23df86=a0_0x358c72,{parentTaskId:_0x418c9a,title:_0x2619fc,description:description='',priority:priority=_0x23df86(0x1f9)}=_0xdfaf40;if(!_0x418c9a||!_0x2619fc)throw new Error('Parent\x20task\x20ID\x20and\x20title\x20are\x20required\x20for\x20creating\x20subtasks');const _0x5e58b8=_0x1b839c['taskList']['tasks'][_0x23df86(0x1fb)](_0x201954=>_0x201954['id']===_0x418c9a);if(!_0x5e58b8)throw new Error('Parent\x20task\x20not\x20found:\x20'+_0x418c9a);const _0x5d9dcb={'id':_0x23df86(0x287)+Date['now']()+'-'+Math['random']()['toString'](0x24)[_0x23df86(0x1de)](0x2,0x9),'title':_0x2619fc,'description':description,'status':'pending','priority':priority[_0x23df86(0x161)](),'createdAt':new Date()[_0x23df86(0x212)](),'updatedAt':new Date()[_0x23df86(0x212)](),'parentTaskId':_0x418c9a,'isSubtask':!![],'source':_0x23df86(0x18d)};return _0x1b839c['taskList'][_0x23df86(0x2a1)]['push'](_0x5d9dcb),!_0x5e58b8[_0x23df86(0x2b6)]&&(_0x5e58b8[_0x23df86(0x2b6)]=[]),_0x5e58b8[_0x23df86(0x2b6)]['push'](_0x5d9dcb['id']),_0x5e58b8['updatedAt']=new Date()['toISOString'](),{'message':_0x23df86(0x298),'subtask':_0x5d9dcb,'parentTask':_0x5e58b8};}async['manageTemplates'](_0x4b51cf,_0x45a0fc){const _0xb44962=a0_0x358c72,{mode:mode='list',templateId:_0x4dd84d,customTemplate:_0x5928ca,projectContext:_0x28c0a9}=_0x45a0fc;let _0x3a5257={};if(mode===_0xb44962(0x226))_0x3a5257=await this[_0xb44962(0x277)](_0x4b51cf);else{if(mode===_0xb44962(0x1ec)&&_0x4dd84d)_0x3a5257=await this['applyTemplate'](_0x4b51cf,_0x4dd84d,_0x28c0a9);else{if(mode===_0xb44962(0x1e9)&&_0x5928ca)_0x3a5257=await this[_0xb44962(0x195)](_0x4b51cf,_0x5928ca);else{if(mode==='suggest')_0x3a5257=await this['suggestTemplates'](_0x4b51cf);else throw new Error('Invalid\x20template\x20mode.\x20Use:\x20list,\x20apply,\x20create,\x20or\x20suggest');}}}return{'message':_0xb44962(0x201)+mode+')','mode':mode,..._0x3a5257};}async[a0_0x358c72(0x277)](_0xad5568){const _0x92f2a1=a0_0x358c72,_0x2e93a1=Object[_0x92f2a1(0x170)](this[_0x92f2a1(0x1db)])['map'](([_0x415527,_0x39c086])=>({'id':_0x415527,'name':_0x39c086[_0x92f2a1(0x1b3)],'description':_0x39c086[_0x92f2a1(0x29a)],'category':_0x39c086[_0x92f2a1(0x2b3)],'taskCount':_0x39c086['tasks']['length'],'type':'built-in'})),_0x123ba2=_0xad5568['customTemplates']||[],_0x5ce210=_0x123ba2['map'](_0x142851=>({..._0x142851,'type':_0x92f2a1(0x23c)}));return{'builtInTemplates':_0x2e93a1,'customTemplates':_0x5ce210,'totalTemplates':_0x2e93a1['length']+_0x5ce210['length'],'categories':[...new Set(_0x2e93a1['map'](_0x5ec00e=>_0x5ec00e[_0x92f2a1(0x2b3)]))]};}async[a0_0x358c72(0x187)](_0x2471b6,_0xddd464,_0x4ad411={}){const _0x1a961c=a0_0x358c72,_0x4b6cb6=this[_0x1a961c(0x1db)][_0xddd464]||(_0x2471b6[_0x1a961c(0x290)]||[])[_0x1a961c(0x1fb)](_0x2e1546=>_0x2e1546['id']===_0xddd464);if(!_0x4b6cb6)throw new Error(_0x1a961c(0x1e6)+_0xddd464);const _0x27106d=[],_0x35381d=new Map(),_0x418c20=this[_0x1a961c(0x28d)](_0x4b6cb6[_0x1a961c(0x2a1)],_0x4ad411);for(const _0x3212f3 of _0x418c20){const _0x228512={'id':'task-'+a0_0x1a371e(),'title':_0x3212f3[_0x1a961c(0x250)],'description':_0x3212f3[_0x1a961c(0x29a)],'status':_0x1a961c(0x248),'priority':_0x3212f3['priority'],'createdAt':new Date()[_0x1a961c(0x212)](),'updatedAt':new Date()[_0x1a961c(0x212)](),'templateId':_0xddd464,'templateOrigin':_0x4b6cb6['type']||_0x1a961c(0x189),'source':'template-generated'};_0x2471b6['taskList'][_0x1a961c(0x2a1)][_0x1a961c(0x245)](_0x228512),_0x27106d['push'](_0x228512),_0x35381d[_0x1a961c(0x236)](_0x3212f3[_0x1a961c(0x250)],_0x228512['id']);}for(let _0x2f9286=0x0;_0x2f9286<_0x418c20['length'];_0x2f9286++){const _0x365b2c=_0x418c20[_0x2f9286],_0x5dbb90=_0x27106d[_0x2f9286];if(_0x365b2c[_0x1a961c(0x278)]&&_0x365b2c['dependencies']['length']>0x0){_0x5dbb90['dependencies']=[];for(const _0x5965c7 of _0x365b2c[_0x1a961c(0x278)]){const _0x5af975=_0x35381d['get'](_0x5965c7);_0x5af975&&(_0x5dbb90['dependencies'][_0x1a961c(0x245)]({'taskId':_0x5af975,'type':_0x1a961c(0x27a),'createdAt':new Date()[_0x1a961c(0x212)]()}),_0x5dbb90[_0x1a961c(0x222)]=_0x1a961c(0x1b2));}}}return await this['autoPrioritizeAllTasks'](_0x2471b6),{'template':{'id':_0xddd464,'name':_0x4b6cb6['name'],'description':_0x4b6cb6['description']},'tasksCreated':_0x27106d[_0x1a961c(0x165)],'tasks':_0x27106d['map'](_0x20a8e7=>({'id':_0x20a8e7['id'],'title':_0x20a8e7['title'],'priority':_0x20a8e7[_0x1a961c(0x28a)],'status':_0x20a8e7[_0x1a961c(0x222)],'dependencies':_0x20a8e7[_0x1a961c(0x278)]?_0x20a8e7[_0x1a961c(0x278)]['length']:0x0})),'workflowStructure':this[_0x1a961c(0x286)](_0x27106d)};}[a0_0x358c72(0x28d)](_0x590ca4,_0x31df52){return _0x590ca4['map'](_0x444e20=>{const _0x4f25b0=a0_0x411c;let _0x1b17d2={..._0x444e20};return _0x31df52['projectName']&&(_0x1b17d2['title']=_0x1b17d2[_0x4f25b0(0x250)][_0x4f25b0(0x1c5)](/\[PROJECT\]/g,_0x31df52['projectName']),_0x1b17d2['description']=_0x1b17d2[_0x4f25b0(0x29a)][_0x4f25b0(0x1c5)](/\[PROJECT\]/g,_0x31df52['projectName'])),_0x31df52['technology']&&(_0x1b17d2[_0x4f25b0(0x250)]=_0x1b17d2['title'][_0x4f25b0(0x1c5)](/\[TECH\]/g,_0x31df52[_0x4f25b0(0x1ab)]),_0x1b17d2[_0x4f25b0(0x29a)]=_0x1b17d2['description']['replace'](/\[TECH\]/g,_0x31df52['technology'])),_0x31df52[_0x4f25b0(0x1a8)]===_0x4f25b0(0x19e)&&(_0x1b17d2[_0x4f25b0(0x28a)]=_0x1b17d2['priority']==='low'?_0x4f25b0(0x1f9):_0x1b17d2['priority']===_0x4f25b0(0x1f9)?_0x4f25b0(0x19e):_0x4f25b0(0x1b4)),_0x31df52['team']===_0x4f25b0(0x216)&&_0x1b17d2['priority']==='medium'&&(_0x1b17d2[_0x4f25b0(0x28a)]='high'),_0x1b17d2;});}async[a0_0x358c72(0x195)](_0x2584a5,_0x5cd06e){const _0x27ed8=a0_0x358c72,{name:_0x82a78,description:_0x382062,category:_0x560899,tasks:_0x4f16ec}=_0x5cd06e;if(!_0x82a78||!_0x4f16ec||_0x4f16ec['length']===0x0)throw new Error('Custom\x20template\x20requires\x20name\x20and\x20at\x20least\x20one\x20task');const _0x17e1b3={'id':_0x27ed8(0x1e7)+Date['now']()+'-'+Math['random']()['toString'](0x24)['substr'](0x2,0x9),'name':_0x82a78,'description':_0x382062||_0x27ed8(0x198)+_0x82a78,'category':_0x560899||'custom','tasks':_0x4f16ec['map'](_0x4011ca=>({'title':_0x4011ca[_0x27ed8(0x250)],'description':_0x4011ca['description']||'','priority':_0x4011ca[_0x27ed8(0x28a)]||'medium','dependencies':_0x4011ca['dependencies']||[]})),'createdAt':new Date()['toISOString'](),'type':'custom'};return!_0x2584a5[_0x27ed8(0x290)]&&(_0x2584a5[_0x27ed8(0x290)]=[]),_0x2584a5[_0x27ed8(0x290)][_0x27ed8(0x245)](_0x17e1b3),{'template':{'id':_0x17e1b3['id'],'name':_0x17e1b3['name'],'description':_0x17e1b3['description'],'category':_0x17e1b3['category'],'taskCount':_0x17e1b3[_0x27ed8(0x2a1)][_0x27ed8(0x165)]},'message':'Custom\x20template\x20created\x20successfully'};}async['suggestTemplates'](_0x3a4969){const _0x45f79c=a0_0x358c72,_0x7b77f8=_0x3a4969['taskList']['tasks'],_0x4a8f26=[],_0x584712=_0x7b77f8[_0x45f79c(0x15d)](_0x2b21a3=>_0x2b21a3[_0x45f79c(0x250)][_0x45f79c(0x161)]()),_0x55e95b=_0x7b77f8['map'](_0x1fdba7=>_0x1fdba7['priority']);_0x584712[_0x45f79c(0x215)](_0x436b4c=>_0x436b4c['includes']('api')||_0x436b4c[_0x45f79c(0x184)](_0x45f79c(0x2a3)))&&_0x4a8f26[_0x45f79c(0x245)]({'templateId':_0x45f79c(0x1b7),'reason':_0x45f79c(0x2bb),'confidence':0.8});_0x584712['some'](_0x1753b3=>_0x1753b3['includes']('bug')||_0x1753b3[_0x45f79c(0x184)]('fix')||_0x1753b3[_0x45f79c(0x184)](_0x45f79c(0x1cf)))&&_0x4a8f26[_0x45f79c(0x245)]({'templateId':'bug-fix','reason':'Detected\x20bug\x20fix\x20tasks','confidence':0.9});_0x584712['some'](_0xa37b18=>_0xa37b18[_0x45f79c(0x184)]('feature')||_0xa37b18['includes']('implement'))&&_0x4a8f26['push']({'templateId':_0x45f79c(0x1d0),'reason':_0x45f79c(0x17c),'confidence':0.7});_0x7b77f8['length']>=0x5&&_0x55e95b[_0x45f79c(0x184)]('high')&&_0x55e95b['includes'](_0x45f79c(0x1f9))&&_0x4a8f26[_0x45f79c(0x245)]({'templateId':_0x45f79c(0x1b6),'reason':'Large\x20project\x20with\x20mixed\x20priorities\x20suggests\x20web\x20app\x20development','confidence':0.6});const _0x3f9280=_0x4a8f26['map'](_0x10063c=>{const _0x12e69d=_0x45f79c,_0x31f85b=this[_0x12e69d(0x1db)][_0x10063c['templateId']];return{..._0x10063c,'templateName':_0x31f85b[_0x12e69d(0x1b3)],'templateDescription':_0x31f85b[_0x12e69d(0x29a)],'taskCount':_0x31f85b[_0x12e69d(0x2a1)]['length']};});return{'suggestions':_0x3f9280,'analysisResults':{'existingTaskCount':_0x7b77f8[_0x45f79c(0x165)],'dominantPriority':this['getMostCommonPriority'](_0x55e95b),'detectedPatterns':_0x4a8f26[_0x45f79c(0x15d)](_0x428ef1=>_0x428ef1[_0x45f79c(0x241)])}};}['generateWorkflowVisualization'](_0x9acd33){const _0x2290b7=a0_0x358c72,_0x394f8b={'phases':[],'criticalPath':[],'parallelTasks':[]},_0x12ff24=new Map(),processedTasks=new Set(),_0x5b198e=_0x9acd33[_0x2290b7(0x20b)](_0x311236=>!_0x311236[_0x2290b7(0x278)]||_0x311236[_0x2290b7(0x278)][_0x2290b7(0x165)]===0x0);_0x5b198e['forEach'](_0xd5efb9=>{_0x12ff24['set'](0x0,(_0x12ff24['get'](0x0)||[])['concat']([_0xd5efb9])),processedTasks['add'](_0xd5efb9['id']);});let _0x200e8c=0x0;while(processedTasks['size']<_0x9acd33['length']&&_0x200e8c<0xa){_0x200e8c++;const _0x45f42e=[];for(const _0x24f824 of _0x9acd33){if(processedTasks['has'](_0x24f824['id']))continue;_0x24f824['dependencies']&&_0x24f824[_0x2290b7(0x278)][_0x2290b7(0x1d9)](_0x1b038c=>processedTasks['has'](_0x1b038c['taskId']))&&(_0x45f42e[_0x2290b7(0x245)](_0x24f824),processedTasks['add'](_0x24f824['id']));}_0x45f42e[_0x2290b7(0x165)]>0x0&&_0x12ff24['set'](_0x200e8c,_0x45f42e);}for(const [_0x17233a,_0x79ff42]of _0x12ff24['entries']()){_0x394f8b['phases'][_0x2290b7(0x245)]({'phase':_0x17233a+0x1,'tasks':_0x79ff42['map'](_0x1c539c=>({'id':_0x1c539c['id'],'title':_0x1c539c[_0x2290b7(0x250)],'priority':_0x1c539c[_0x2290b7(0x28a)]})),'taskCount':_0x79ff42[_0x2290b7(0x165)],'canRunInParallel':_0x79ff42['length']>0x1});}return _0x394f8b;}['getMostCommonPriority'](_0x244d98){const _0x244b11=a0_0x358c72;if(_0x244d98[_0x244b11(0x165)]===0x0)return _0x244b11(0x1f9);const _0x4596e4=_0x244d98['reduce']((_0x1c1bf1,_0x306473)=>{return _0x1c1bf1[_0x306473]=(_0x1c1bf1[_0x306473]||0x0)+0x1,_0x1c1bf1;},{});return Object['keys'](_0x4596e4)['reduce']((_0x3b6931,_0xd1bd50)=>_0x4596e4[_0x3b6931]>_0x4596e4[_0xd1bd50]?_0x3b6931:_0xd1bd50);}async[a0_0x358c72(0x268)](_0x5ddbbd,_0x571e01){const _0x403904=a0_0x358c72,{mode:mode=_0x403904(0x2b5),taskId:_0x1e6f1d,stage:_0x2f221e,milestone:_0x2218b1,note:_0x572ff3,percentage:_0x1e26eb}=_0x571e01;let _0x5b6e59={};if(mode==='update'&&_0x1e6f1d)_0x5b6e59=await this['updateTaskProgress'](_0x5ddbbd,_0x1e6f1d,{'stage':_0x2f221e,'milestone':_0x2218b1,'note':_0x572ff3,'percentage':_0x1e26eb});else{if(mode===_0x403904(0x17a))_0x5b6e59=await this['getProgressOverview'](_0x5ddbbd);else{if(mode==='milestones'&&_0x1e6f1d)_0x5b6e59=await this[_0x403904(0x2ba)](_0x5ddbbd,_0x1e6f1d,_0x571e01);else{if(mode===_0x403904(0x1ac))_0x5b6e59=await this['calculateTaskProgress'](_0x5ddbbd,_0x1e6f1d);else throw new Error('Invalid\x20progress\x20mode.\x20Use:\x20update,\x20overview,\x20milestones,\x20or\x20calculate');}}}return{'message':_0x403904(0x1a5)+mode+')','mode':mode,..._0x5b6e59};}async['updateTaskProgress'](_0x4ef261,_0xbac703,_0x7e67){const _0x540664=a0_0x358c72,_0x2d1bc8=_0x4ef261[_0x540664(0x292)]['tasks'][_0x540664(0x1fb)](_0xcda81e=>_0xcda81e['id']===_0xbac703);if(!_0x2d1bc8)throw new Error('Task\x20not\x20found:\x20'+_0xbac703);!_0x2d1bc8[_0x540664(0x200)]&&(_0x2d1bc8['progress']={'stage':'not_started','percentage':0x0,'milestones':[],'notes':[],'stageHistory':[]});const _0x1bb785=_0x2d1bc8[_0x540664(0x200)]['stage'];if(_0x7e67[_0x540664(0x179)]){if(!this[_0x540664(0x224)][_0x540664(0x184)](_0x7e67[_0x540664(0x179)]))throw new Error(_0x540664(0x26e)+_0x7e67['stage']+_0x540664(0x1cc)+this['progressStages']['join'](',\x20'));_0x2d1bc8['progress'][_0x540664(0x179)]=_0x7e67[_0x540664(0x179)],_0x2d1bc8['progress'][_0x540664(0x21a)][_0x540664(0x245)]({'from':_0x1bb785,'to':_0x7e67[_0x540664(0x179)],'timestamp':new Date()[_0x540664(0x212)]()});if(_0x7e67[_0x540664(0x179)]===_0x540664(0x295)&&_0x2d1bc8['status']==='in_progress')_0x2d1bc8[_0x540664(0x222)]='pending';else{if([_0x540664(0x29f),'in_development',_0x540664(0x1ee),'review'][_0x540664(0x184)](_0x7e67[_0x540664(0x179)])&&_0x2d1bc8[_0x540664(0x222)]==='pending')_0x2d1bc8[_0x540664(0x222)]='in_progress';else _0x7e67['stage']===_0x540664(0x269)&&_0x2d1bc8['status']!=='completed'&&(_0x2d1bc8['status']=_0x540664(0x269),_0x2d1bc8[_0x540664(0x20c)]=new Date()[_0x540664(0x212)]());}}if(_0x7e67[_0x540664(0x1dd)]!==undefined){const _0x3c7b6d=Math[_0x540664(0x20a)](0x0,Math[_0x540664(0x176)](0x64,parseInt(_0x7e67['percentage'])));_0x2d1bc8['progress']['percentage']=_0x3c7b6d;if(_0x3c7b6d===0x0&&_0x2d1bc8[_0x540664(0x200)][_0x540664(0x179)]!==_0x540664(0x295))_0x2d1bc8[_0x540664(0x200)][_0x540664(0x179)]=_0x540664(0x295);else{if(_0x3c7b6d>0x0&&_0x3c7b6d<0x19&&_0x2d1bc8[_0x540664(0x200)][_0x540664(0x179)]==='not_started')_0x2d1bc8['progress']['stage']=_0x540664(0x29f);else{if(_0x3c7b6d>=0x19&&_0x3c7b6d<0x4b&&[_0x540664(0x295),'planning']['includes'](_0x2d1bc8['progress'][_0x540664(0x179)]))_0x2d1bc8[_0x540664(0x200)][_0x540664(0x179)]=_0x540664(0x19a);else{if(_0x3c7b6d>=0x4b&&_0x3c7b6d<0x5f&&_0x2d1bc8[_0x540664(0x200)][_0x540664(0x179)]!==_0x540664(0x1ee))_0x2d1bc8['progress']['stage']='testing';else{if(_0x3c7b6d>=0x5f&&_0x3c7b6d<0x64&&_0x2d1bc8[_0x540664(0x200)][_0x540664(0x179)]!==_0x540664(0x1c3))_0x2d1bc8['progress'][_0x540664(0x179)]=_0x540664(0x1c3);else _0x3c7b6d===0x64&&(_0x2d1bc8['progress']['stage']=_0x540664(0x269),_0x2d1bc8[_0x540664(0x222)]=_0x540664(0x269),_0x2d1bc8['completedAt']=new Date()[_0x540664(0x212)]());}}}}}if(_0x7e67[_0x540664(0x2b2)]){const _0x4db459={'id':_0x540664(0x25a)+Date[_0x540664(0x1da)]()+'-'+Math['random']()[_0x540664(0x25c)](0x24)[_0x540664(0x1de)](0x2,0x9),'type':_0x7e67['milestone']['type']||'checkpoint','title':_0x7e67[_0x540664(0x2b2)]['title']||_0x540664(0x27b),'description':_0x7e67['milestone']['description']||'','achievedAt':new Date()[_0x540664(0x212)](),'stage':_0x2d1bc8['progress']['stage']};_0x2d1bc8['progress'][_0x540664(0x1e8)][_0x540664(0x245)](_0x4db459);}return _0x7e67['note']&&_0x2d1bc8['progress']['notes'][_0x540664(0x245)]({'id':_0x540664(0x1e0)+Date['now']()+'-'+Math[_0x540664(0x217)]()[_0x540664(0x25c)](0x24)[_0x540664(0x1de)](0x2,0x9),'content':_0x7e67['note'],'timestamp':new Date()['toISOString'](),'stage':_0x2d1bc8['progress'][_0x540664(0x179)]}),_0x2d1bc8[_0x540664(0x29e)]=new Date()['toISOString'](),_0x2d1bc8[_0x540664(0x1a0)]&&await this[_0x540664(0x2a2)](_0x4ef261,_0x2d1bc8[_0x540664(0x1a0)]),{'task':{'id':_0x2d1bc8['id'],'title':_0x2d1bc8[_0x540664(0x250)],'status':_0x2d1bc8['status'],'progress':_0x2d1bc8['progress']},'changes':{'stageChanged':_0x1bb785!==_0x2d1bc8[_0x540664(0x200)][_0x540664(0x179)],'oldStage':_0x1bb785,'newStage':_0x2d1bc8['progress']['stage'],'milestoneAdded':!!_0x7e67[_0x540664(0x2b2)],'noteAdded':!!_0x7e67[_0x540664(0x1e4)]}};}async[a0_0x358c72(0x228)](_0x49d414){const _0x14b006=a0_0x358c72,_0x5aedb5=_0x49d414['taskList']['tasks'],_0x354f4c=_0x5aedb5[_0x14b006(0x15d)](_0x11019b=>{const _0x5d3b5b=_0x14b006,_0x2713da=_0x11019b[_0x5d3b5b(0x200)]||{'stage':_0x5d3b5b(0x295),'percentage':0x0,'milestones':[],'notes':[]};return{'id':_0x11019b['id'],'title':_0x11019b['title'],'status':_0x11019b[_0x5d3b5b(0x222)],'priority':_0x11019b['priority'],'stage':_0x2713da[_0x5d3b5b(0x179)],'percentage':_0x2713da[_0x5d3b5b(0x1dd)],'milestoneCount':_0x2713da[_0x5d3b5b(0x1e8)]?_0x2713da[_0x5d3b5b(0x1e8)]['length']:0x0,'isBlocked':_0x11019b[_0x5d3b5b(0x222)]==='blocked','hasSubtasks':!!(_0x11019b[_0x5d3b5b(0x2b6)]&&_0x11019b[_0x5d3b5b(0x2b6)][_0x5d3b5b(0x165)]>0x0),'parentTaskId':_0x11019b['parentTaskId']};}),_0x2857ca={'totalTasks':_0x5aedb5['length'],'byStage':{},'byStatus':{},'averageProgress':0x0,'blockedTasks':0x0,'completedTasks':0x0};this[_0x14b006(0x224)]['forEach'](_0x4cfc0a=>{const _0x366903=_0x14b006;_0x2857ca[_0x366903(0x2b7)][_0x4cfc0a]=_0x354f4c[_0x366903(0x20b)](_0x1498d7=>_0x1498d7[_0x366903(0x179)]===_0x4cfc0a)['length'];}),this['taskStatuses']['forEach'](_0x180d7b=>{const _0x7582de=_0x14b006;_0x2857ca[_0x7582de(0x247)][_0x180d7b]=_0x354f4c[_0x7582de(0x20b)](_0x41ccbd=>_0x41ccbd[_0x7582de(0x222)]===_0x180d7b)['length'];}),_0x2857ca['averageProgress']=_0x5aedb5['length']>0x0?Math[_0x14b006(0x1b1)](_0x354f4c[_0x14b006(0x29c)]((_0x552b6a,_0x50956f)=>_0x552b6a+_0x50956f['percentage'],0x0)/_0x5aedb5['length']):0x0,_0x2857ca[_0x14b006(0x1ea)]=_0x2857ca[_0x14b006(0x247)]['blocked']||0x0,_0x2857ca[_0x14b006(0x274)]=_0x2857ca[_0x14b006(0x247)][_0x14b006(0x269)]||0x0;const _0x17fe08=_0x354f4c[_0x14b006(0x20b)](_0x48f3d1=>_0x48f3d1['priority']==='urgent'&&_0x48f3d1['status']!=='completed'),_0x273d88=_0x354f4c[_0x14b006(0x20b)](_0x225865=>_0x225865['isBlocked']&&this['findTasksBlockedBy'](_0x225865['id'],_0x5aedb5)['length']>0x0);return{'overview':_0x2857ca,'tasks':_0x354f4c,'criticalTasks':_0x17fe08,'bottlenecks':_0x273d88[_0x14b006(0x15d)](_0x5de315=>({'taskId':_0x5de315['id'],'title':_0x5de315['title'],'blockedTasksCount':this['findTasksBlockedBy'](_0x5de315['id'],_0x5aedb5)[_0x14b006(0x165)]})),'recommendations':this['generateProgressRecommendations'](_0x354f4c,_0x2857ca)};}async[a0_0x358c72(0x2a2)](_0x3d1b15,_0x1461a9){const _0x11e4a9=a0_0x358c72,_0x34f133=_0x3d1b15['taskList']['tasks'][_0x11e4a9(0x1fb)](_0x3cef12=>_0x3cef12['id']===_0x1461a9);if(!_0x34f133)throw new Error('Task\x20not\x20found:\x20'+_0x1461a9);!_0x34f133['progress']&&(_0x34f133[_0x11e4a9(0x200)]={'stage':_0x11e4a9(0x295),'percentage':0x0,'milestones':[],'notes':[],'stageHistory':[]});let _0x5ef59f=0x0,_0x1e61d0=_0x11e4a9(0x281);if(_0x34f133[_0x11e4a9(0x2b6)]&&_0x34f133[_0x11e4a9(0x2b6)]['length']>0x0){const _0x5b5a45=_0x34f133['subtasks']['map'](_0x27edd0=>_0x3d1b15['taskList'][_0x11e4a9(0x2a1)][_0x11e4a9(0x1fb)](_0x1ee61b=>_0x1ee61b['id']===_0x27edd0))['filter'](Boolean);if(_0x5b5a45[_0x11e4a9(0x165)]>0x0){const _0x2cd960=_0x5b5a45[_0x11e4a9(0x15d)](_0x24b6ca=>{const _0x5f49d0=_0x11e4a9;if(_0x24b6ca['status']===_0x5f49d0(0x269))return 0x64;if(_0x24b6ca[_0x5f49d0(0x200)]&&_0x24b6ca[_0x5f49d0(0x200)][_0x5f49d0(0x1dd)]!==undefined)return _0x24b6ca['progress']['percentage'];return _0x24b6ca[_0x5f49d0(0x222)]==='in_progress'?0x19:0x0;});_0x5ef59f=Math[_0x11e4a9(0x1b1)](_0x2cd960[_0x11e4a9(0x29c)]((_0x5a5edc,_0x5122c3)=>_0x5a5edc+_0x5122c3,0x0)/_0x5b5a45[_0x11e4a9(0x165)]),_0x1e61d0=_0x11e4a9(0x2b6);}}else{if(_0x34f133['dependencies']&&_0x34f133[_0x11e4a9(0x278)][_0x11e4a9(0x165)]>0x0){const _0x37cf8b=_0x34f133['dependencies'][_0x11e4a9(0x20b)](_0x1971a7=>{const _0x3853b3=_0x11e4a9,_0x43f6f4=_0x3d1b15[_0x3853b3(0x292)]['tasks'][_0x3853b3(0x1fb)](_0x1d65cb=>_0x1d65cb['id']===_0x1971a7['taskId']);return _0x43f6f4&&_0x43f6f4['status']===_0x3853b3(0x269);})[_0x11e4a9(0x165)],_0x4898cf=_0x37cf8b/_0x34f133[_0x11e4a9(0x278)][_0x11e4a9(0x165)]*0x1e,_0x17d4a1=_0x34f133['status']===_0x11e4a9(0x269)?0x46:_0x34f133['status']==='in_progress'?0x23:0x0;_0x5ef59f=Math['round'](_0x4898cf+_0x17d4a1),_0x1e61d0=_0x11e4a9(0x278);}else{if(_0x34f133[_0x11e4a9(0x222)]===_0x11e4a9(0x269))_0x5ef59f=0x64;else{if(_0x34f133[_0x11e4a9(0x222)]===_0x11e4a9(0x1f3))_0x5ef59f=_0x34f133[_0x11e4a9(0x200)]['percentage']||0x32;else{if(_0x34f133['status']==='pending')_0x5ef59f=0x0;else{if(_0x34f133['status']==='blocked')_0x5ef59f=_0x34f133[_0x11e4a9(0x200)]['percentage']||0x0;}}}_0x1e61d0=_0x11e4a9(0x222);}}_0x34f133[_0x11e4a9(0x200)][_0x11e4a9(0x1f1)]=_0x5ef59f,_0x34f133[_0x11e4a9(0x200)][_0x11e4a9(0x240)]=_0x1e61d0,_0x34f133['progress']['lastCalculated']=new Date()['toISOString']();const _0x2a100c=_0x34f133[_0x11e4a9(0x200)][_0x11e4a9(0x21a)][_0x11e4a9(0x165)]>0x0&&Date['now']()-new Date(_0x34f133[_0x11e4a9(0x200)]['stageHistory'][_0x34f133['progress'][_0x11e4a9(0x21a)][_0x11e4a9(0x165)]-0x1]['timestamp'])[_0x11e4a9(0x1ba)]()<0x493e0;if(!_0x2a100c){const _0x34c773=this[_0x11e4a9(0x2a7)](_0x5ef59f);_0x34c773!==_0x34f133['progress']['stage']&&(_0x34f133['progress']['stage']=_0x34c773,_0x34f133[_0x11e4a9(0x200)]['stageHistory']['push']({'from':_0x34f133[_0x11e4a9(0x200)][_0x11e4a9(0x179)],'to':_0x34c773,'timestamp':new Date()['toISOString'](),'automatic':!![]}));}return _0x34f133['updatedAt']=new Date()[_0x11e4a9(0x212)](),{'taskId':_0x34f133['id'],'title':_0x34f133['title'],'calculatedPercentage':_0x5ef59f,'calculationMethod':_0x1e61d0,'manualPercentage':_0x34f133[_0x11e4a9(0x200)]['percentage'],'stage':_0x34f133['progress'][_0x11e4a9(0x179)],'subtaskCount':_0x34f133[_0x11e4a9(0x2b6)]?_0x34f133[_0x11e4a9(0x2b6)][_0x11e4a9(0x165)]:0x0,'dependencyCount':_0x34f133[_0x11e4a9(0x278)]?_0x34f133[_0x11e4a9(0x278)][_0x11e4a9(0x165)]:0x0};}[a0_0x358c72(0x25d)](_0x34831e,_0x368831){const _0x2a1c84=a0_0x358c72,_0x2f0629=[];_0x368831['blockedTasks']>0x0&&_0x2f0629['push']({'type':_0x2a1c84(0x1b4),'category':_0x2a1c84(0x28f),'message':_0x368831[_0x2a1c84(0x1ea)]+'\x20tasks\x20are\x20blocked.\x20Review\x20dependencies\x20to\x20unblock\x20progress.','actionable':!![]});const _0x322a38=_0x34831e[_0x2a1c84(0x20b)](_0x38c81b=>_0x38c81b[_0x2a1c84(0x222)]==='in_progress'&&_0x38c81b['percentage']<0x19);_0x322a38[_0x2a1c84(0x165)]>0x0&&_0x2f0629['push']({'type':_0x2a1c84(0x173),'category':'stalled_progress','message':_0x322a38['length']+_0x2a1c84(0x29b),'actionable':!![]});const _0x244517=_0x34831e['filter'](_0x29b7e6=>_0x29b7e6[_0x2a1c84(0x1dd)]>=0x5a&&_0x29b7e6['status']!=='completed');return _0x244517['length']>0x0&&_0x2f0629[_0x2a1c84(0x245)]({'type':'success','category':'near_completion','message':_0x244517[_0x2a1c84(0x165)]+_0x2a1c84(0x1c1),'actionable':!![]}),_0x368831[_0x2a1c84(0x285)]<0x19&&_0x2f0629['push']({'type':_0x2a1c84(0x197),'category':'overall_progress','message':_0x2a1c84(0x2a5),'actionable':![]}),_0x2f0629;}[a0_0x358c72(0x2a7)](_0x21a497){const _0x4287dc=a0_0x358c72;if(_0x21a497===0x0)return'not_started';if(_0x21a497<0x19)return'planning';if(_0x21a497<0x4b)return'in_development';if(_0x21a497<0x5f)return'testing';if(_0x21a497<0x64)return _0x4287dc(0x1c3);return _0x4287dc(0x269);}['setScheduler'](_0x178ccd){const _0x9b7a61=a0_0x358c72;this[_0x9b7a61(0x199)]=_0x178ccd,this['logger']?.[_0x9b7a61(0x197)]('TaskManagerTool:\x20Scheduler\x20dependency\x20injected');}async[a0_0x358c72(0x26f)](_0x152912,_0x499e4e){const _0xcad6a0=a0_0x358c72,{mode:mode=_0xcad6a0(0x29d),taskId:_0x916be4}=_0x499e4e;let _0x2dcf30={};if(mode===_0xcad6a0(0x29d))_0x2dcf30=await this[_0xcad6a0(0x24f)](_0x152912);else{if(mode===_0xcad6a0(0x1a3)&&_0x916be4)_0x2dcf30=await this['analyzeTaskPriority'](_0x152912,_0x916be4);else{if(mode==='balance')_0x2dcf30=await this['balanceCrossAgentPriorities'](_0x152912);else throw new Error('Invalid\x20prioritization\x20mode.\x20Use:\x20auto,\x20analyze,\x20or\x20balance');}}return{'message':'Intelligent\x20prioritization\x20completed\x20('+mode+')','mode':mode,..._0x2dcf30};}async[a0_0x358c72(0x24f)](_0x7ac629){const _0xd0a044=a0_0x358c72,_0x25ea3a=_0x7ac629['taskList']['tasks']['filter'](_0x23ecec=>_0x23ecec['status']==='pending'||_0x23ecec[_0xd0a044(0x222)]==='in_progress');if(_0x25ea3a[_0xd0a044(0x165)]===0x0)return{'message':'No\x20active\x20tasks\x20to\x20prioritize'};const _0x33463a=_0x25ea3a['map'](_0x191371=>({..._0x191371,'priorityScore':this['calculatePriorityScore'](_0x191371,_0x7ac629['taskList']['tasks']),'originalPriority':_0x191371['priority']}));_0x33463a['sort']((_0x2643f4,_0x31926b)=>_0x31926b['priorityScore']-_0x2643f4['priorityScore']);const _0x345189=[_0xd0a044(0x1b4),_0xd0a044(0x19e),_0xd0a044(0x1f9),'low'],_0x5b45d4=[];return _0x33463a[_0xd0a044(0x254)]((_0x592832,_0x4d6c33)=>{const _0x51e760=_0xd0a044,_0x3ead17=Math['min'](Math['floor'](_0x4d6c33/Math[_0x51e760(0x20a)](0x1,_0x25ea3a[_0x51e760(0x165)]/0x4)),_0x345189['length']-0x1),_0x1ebb84=_0x345189[_0x3ead17];if(_0x592832[_0x51e760(0x263)]!==_0x1ebb84){const _0x10f5a1=_0x7ac629[_0x51e760(0x292)]['tasks'][_0x51e760(0x1fb)](_0x54e0ee=>_0x54e0ee['id']===_0x592832['id']);_0x10f5a1[_0x51e760(0x28a)]=_0x1ebb84,_0x10f5a1[_0x51e760(0x29e)]=new Date()['toISOString'](),_0x10f5a1['priorityScore']=_0x592832['priorityScore'],_0x10f5a1['priorityReason']=this['generatePriorityReason'](_0x592832),_0x5b45d4[_0x51e760(0x245)]({'id':_0x592832['id'],'title':_0x592832[_0x51e760(0x250)],'oldPriority':_0x592832[_0x51e760(0x263)],'newPriority':_0x1ebb84,'score':_0x592832[_0x51e760(0x1eb)][_0x51e760(0x18a)](0x2),'reason':_0x10f5a1['priorityReason']});}}),{'totalTasks':_0x25ea3a[_0xd0a044(0x165)],'updatedTasks':_0x5b45d4[_0xd0a044(0x165)],'changes':_0x5b45d4};}[a0_0x358c72(0x1ed)](_0x2475b1,_0x529c74){const _0x45bb01=a0_0x358c72;let _0x22a1db=0x0;const _0xfadb30={'urgent':0x4,'high':0x3,'medium':0x2,'low':0x1};_0x22a1db+=_0xfadb30[_0x2475b1[_0x45bb01(0x28a)]]*this[_0x45bb01(0x19f)]['userPriority'];const _0x1ab859=(Date[_0x45bb01(0x1da)]()-new Date(_0x2475b1['createdAt'])[_0x45bb01(0x1ba)]())/(0x3e8*0x3c*0x3c);_0x22a1db+=Math[_0x45bb01(0x176)](_0x1ab859/0x18,0x3)*this[_0x45bb01(0x19f)][_0x45bb01(0x169)];const _0x29f4eb=this[_0x45bb01(0x171)](_0x2475b1['id'],_0x529c74);_0x22a1db+=_0x29f4eb[_0x45bb01(0x165)]*this[_0x45bb01(0x19f)][_0x45bb01(0x1c0)];const _0xa76bf7=(_0x2475b1[_0x45bb01(0x278)]||[])['length'];_0x22a1db+=Math[_0x45bb01(0x176)](_0xa76bf7,0x3)*this['priorityWeights']['dependency'];const _0x11c72f=(_0x2475b1[_0x45bb01(0x2b6)]||[])[_0x45bb01(0x165)];return _0x22a1db+=Math[_0x45bb01(0x176)](_0x11c72f,0x2)*this[_0x45bb01(0x19f)]['dependency'],_0x22a1db;}['findTasksBlockedBy'](_0x24617c,_0x285c1f){return _0x285c1f['filter'](_0x18b06a=>{const _0x47c7ab=a0_0x411c;if(!_0x18b06a['dependencies'])return![];return _0x18b06a[_0x47c7ab(0x278)]['some'](_0xda7af1=>_0xda7af1[_0x47c7ab(0x296)]===_0x24617c&&_0xda7af1[_0x47c7ab(0x20d)]==='blocks');});}[a0_0x358c72(0x1b0)](_0x287f44){const _0x11206b=a0_0x358c72,_0x2bcc57=[];_0x287f44[_0x11206b(0x1eb)]>0x8&&_0x2bcc57['push']('high\x20overall\x20impact');const _0x24dbd3=(Date[_0x11206b(0x1da)]()-new Date(_0x287f44['createdAt'])[_0x11206b(0x1ba)]())/(0x3e8*0x3c*0x3c);return _0x24dbd3>0x18&&_0x2bcc57['push']('overdue\x20task'),_0x287f44[_0x11206b(0x28a)]===_0x11206b(0x1b4)&&_0x2bcc57['push']('user-marked\x20urgent'),(_0x287f44['subtasks']||[])['length']>0x0&&_0x2bcc57['push'](_0x11206b(0x267)),_0x2bcc57['length']>0x0?_0x2bcc57['join'](',\x20'):_0x11206b(0x22c);}async['analyzeTaskPriority'](_0x3670c7,_0x1c7dc3){const _0x4421df=a0_0x358c72,_0x2f858e=_0x3670c7[_0x4421df(0x292)][_0x4421df(0x2a1)]['find'](_0x13c68c=>_0x13c68c['id']===_0x1c7dc3);if(!_0x2f858e)throw new Error(_0x4421df(0x234)+_0x1c7dc3);const _0x3fe868=this[_0x4421df(0x1ed)](_0x2f858e,_0x3670c7[_0x4421df(0x292)]['tasks']),_0x119caf=this['findTasksBlockedBy'](_0x1c7dc3,_0x3670c7['taskList'][_0x4421df(0x2a1)]),_0xdf3675=this['generatePriorityReason']({..._0x2f858e,'priorityScore':_0x3fe868});return{'task':{'id':_0x2f858e['id'],'title':_0x2f858e[_0x4421df(0x250)],'currentPriority':_0x2f858e[_0x4421df(0x28a)],'priorityScore':_0x3fe868[_0x4421df(0x18a)](0x2),'reason':_0xdf3675},'analysis':{'blocksOtherTasks':_0x119caf['length'],'ageInHours':((Date['now']()-new Date(_0x2f858e[_0x4421df(0x1d6)])['getTime']())/(0x3e8*0x3c*0x3c))[_0x4421df(0x18a)](0x1),'dependencyCount':(_0x2f858e['dependencies']||[])[_0x4421df(0x165)],'subtaskCount':(_0x2f858e['subtasks']||[])[_0x4421df(0x165)]},'blockedTasks':_0x119caf['map'](_0x545ca6=>({'id':_0x545ca6['id'],'title':_0x545ca6['title']}))};}async['balanceCrossAgentPriorities'](_0x49b570){const _0xdeda63=a0_0x358c72;if(!this['scheduler']||typeof this['scheduler']['getAllAgents']!=='function')return{'message':'Cross-agent\x20balancing\x20requires\x20scheduler\x20integration'};try{const _0x4774c3=await this[_0xdeda63(0x199)][_0xdeda63(0x28e)](),_0x1d04de=[];return _0x4774c3['forEach'](_0x481cbe=>{const _0x2cada9=_0xdeda63;if(_0x481cbe[_0x2cada9(0x292)]&&_0x481cbe['taskList'][_0x2cada9(0x2a1)]){const _0x57e77e=_0x481cbe[_0x2cada9(0x292)][_0x2cada9(0x2a1)][_0x2cada9(0x20b)](_0x8bb47=>_0x8bb47['status']==='pending'||_0x8bb47[_0x2cada9(0x222)]==='in_progress'),_0x17e8c6=_0x57e77e['filter'](_0x56bbdf=>_0x56bbdf['priority']==='urgent')[_0x2cada9(0x165)],_0x18440c=_0x57e77e['filter'](_0x41d928=>_0x41d928['priority']==='high')['length'];_0x1d04de[_0x2cada9(0x245)]({'agentId':_0x481cbe['id'],'agentName':_0x481cbe['name'],'totalActive':_0x57e77e['length'],'urgent':_0x17e8c6,'high':_0x18440c,'workloadScore':_0x17e8c6*0x3+_0x18440c*0x2+_0x57e77e['length']});}}),_0x1d04de[_0xdeda63(0x1d4)]((_0xf793f6,_0xf2ce0)=>_0xf793f6[_0xdeda63(0x27d)]-_0xf2ce0[_0xdeda63(0x27d)]),{'currentAgent':{'agentId':_0x49b570['id'],'rank':_0x1d04de['findIndex'](_0x3e1a06=>_0x3e1a06[_0xdeda63(0x242)]===_0x49b570['id'])+0x1,'totalAgents':_0x1d04de[_0xdeda63(0x165)]},'workloadDistribution':_0x1d04de,'recommendation':this['generateBalancingRecommendation'](_0x49b570,_0x1d04de)};}catch(_0x2224bf){return{'error':_0xdeda63(0x1d5)+_0x2224bf['message'],'fallback':'Using\x20single-agent\x20prioritization'};}}[a0_0x358c72(0x2a4)](_0x5cce2a,_0x272f43){const _0x242fe1=a0_0x358c72,_0x3c4779=_0x272f43['find'](_0x42f2a5=>_0x42f2a5['agentId']===_0x5cce2a['id']);if(!_0x3c4779)return'No\x20recommendation\x20available';const _0x46d126=_0x272f43['reduce']((_0x4c0834,_0x20713b)=>_0x4c0834+_0x20713b[_0x242fe1(0x27d)],0x0)/_0x272f43[_0x242fe1(0x165)];if(_0x3c4779[_0x242fe1(0x27d)]>_0x46d126*1.5)return _0x242fe1(0x1b8);else return _0x3c4779[_0x242fe1(0x27d)]<_0x46d126*0.5?_0x242fe1(0x231):'Workload\x20is\x20well\x20balanced';}['generateTaskSummary'](_0x23c1f){const _0x34197b=a0_0x358c72,_0x323ba0=_0x23c1f[_0x34197b(0x2a1)];return{'total':_0x323ba0['length'],'pending':_0x323ba0[_0x34197b(0x20b)](_0x240803=>_0x240803['status']==='pending')[_0x34197b(0x165)],'in_progress':_0x323ba0['filter'](_0x1f50bd=>_0x1f50bd['status']===_0x34197b(0x1f3))['length'],'completed':_0x323ba0[_0x34197b(0x20b)](_0x4085bc=>_0x4085bc['status']==='completed')['length'],'cancelled':_0x323ba0['filter'](_0x5f2394=>_0x5f2394['status']===_0x34197b(0x25f))['length'],'high_priority':_0x323ba0[_0x34197b(0x20b)](_0x53acba=>_0x53acba['priority']==='high'&&(_0x53acba['status']===_0x34197b(0x248)||_0x53acba[_0x34197b(0x222)]===_0x34197b(0x1f3)))['length']};}async[a0_0x358c72(0x17b)](_0xa77372,_0x4e9b40){const _0x2ae843=a0_0x358c72,{mode:mode=_0x2ae843(0x17d),timeframe:timeframe='30',reportType:reportType='comprehensive',agentId:_0xab8f47}=_0x4e9b40;let _0x59ca6d={};switch(mode){case'summary':_0x59ca6d=await this[_0x2ae843(0x1f8)](_0xa77372,timeframe);break;case _0x2ae843(0x253):_0x59ca6d=await this[_0x2ae843(0x1f2)](_0xa77372,timeframe);break;case _0x2ae843(0x23b):_0x59ca6d=await this['getTrendAnalysis'](_0xa77372,timeframe);break;case'team':_0x59ca6d=await this[_0x2ae843(0x1ce)](timeframe);break;case'export':_0x59ca6d=await this['exportAnalytics'](_0xa77372,_0x4e9b40);break;case'insights':_0x59ca6d=await this['generateInsights'](_0xa77372,timeframe);break;default:throw new Error('Invalid analytics mode. Use: summary, performance, trends, team, export, or insights');}return{'message':'Analytics\x20report\x20generated\x20('+mode+')','mode':mode,'timeframe':timeframe,'generatedAt':new Date()['toISOString'](),..._0x59ca6d};}async['getAnalyticsSummary'](_0x34a54e,_0x53a9e4){const _0x515556=a0_0x358c72,_0xd64740=_0x34a54e[_0x515556(0x292)]['tasks'],_0xa9770b=new Date(Date['now']()-parseInt(_0x53a9e4)*0x18*0x3c*0x3c*0x3e8),_0x4bd32d=_0xd64740[_0x515556(0x20b)](_0x18bcca=>new Date(_0x18bcca['createdAt'])>=_0xa9770b),_0x1f7c42={'overview':{'totalTasks':_0x4bd32d[_0x515556(0x165)],'completed':_0x4bd32d['filter'](_0x4ebb35=>_0x4ebb35[_0x515556(0x222)]==='completed')['length'],'inProgress':_0x4bd32d['filter'](_0x179e4a=>_0x179e4a[_0x515556(0x222)]===_0x515556(0x1f3))[_0x515556(0x165)],'pending':_0x4bd32d['filter'](_0x3dc70e=>_0x3dc70e['status']==='pending')['length'],'cancelled':_0x4bd32d[_0x515556(0x20b)](_0x575d89=>_0x575d89['status']===_0x515556(0x25f))[_0x515556(0x165)],'blocked':_0x4bd32d[_0x515556(0x20b)](_0x1f101e=>_0x1f101e['status']==='blocked')['length']},'priorityBreakdown':{'urgent':_0x4bd32d['filter'](_0x41c840=>_0x41c840[_0x515556(0x28a)]===_0x515556(0x1b4))['length'],'high':_0x4bd32d[_0x515556(0x20b)](_0x3c85d1=>_0x3c85d1[_0x515556(0x28a)]===_0x515556(0x19e))['length'],'medium':_0x4bd32d[_0x515556(0x20b)](_0x392e9f=>_0x392e9f[_0x515556(0x28a)]==='medium')['length'],'low':_0x4bd32d['filter'](_0x241df3=>_0x241df3['priority']===_0x515556(0x1f6))['length']},'progressMetrics':this['calculateProgressMetrics'](_0x4bd32d),'dependencyMetrics':this['calculateDependencyMetrics'](_0x4bd32d),'templateUsage':this['calculateTemplateUsage'](_0x4bd32d)};_0x1f7c42['completionRate']=_0x1f7c42[_0x515556(0x17a)][_0x515556(0x280)]>0x0?Math[_0x515556(0x1b1)](_0x1f7c42['overview'][_0x515556(0x269)]/_0x1f7c42['overview']['totalTasks']*0x64):0x0;const _0x539e15=_0x4bd32d[_0x515556(0x20b)](_0x27072f=>_0x27072f['status']!==_0x515556(0x269)&&_0x27072f['status']!==_0x515556(0x25f));return _0x1f7c42[_0x515556(0x1be)]=_0x539e15['length']>0x0?Math[_0x515556(0x1b1)](_0x539e15['reduce']((_0x142e50,_0x1b71a3)=>{const _0x296dfc=_0x515556;return _0x142e50+(Date[_0x296dfc(0x1da)]()-new Date(_0x1b71a3['createdAt'])[_0x296dfc(0x1ba)]())/(0x3e8*0x3c*0x3c*0x18);},0x0)/_0x539e15['length']):0x0,{'summary':_0x1f7c42,'insights':this[_0x515556(0x227)](_0x1f7c42)};}async['getPerformanceMetrics'](_0x56257b,_0x529f6a){const _0x1655a6=a0_0x358c72,_0x4e7d9b=_0x56257b[_0x1655a6(0x292)][_0x1655a6(0x2a1)],_0x420d72=new Date(Date['now']()-parseInt(_0x529f6a)*0x18*0x3c*0x3c*0x3e8),_0x456d54=_0x4e7d9b[_0x1655a6(0x20b)](_0x23f768=>_0x23f768[_0x1655a6(0x222)]==='completed'&&_0x23f768[_0x1655a6(0x20c)]&&new Date(_0x23f768[_0x1655a6(0x20c)])>=_0x420d72),_0x2b52af={'productivity':{'tasksCompleted':_0x456d54[_0x1655a6(0x165)],'completionRate':this['calculateCompletionRate'](_0x4e7d9b,_0x529f6a),'averageCompletionTime':this[_0x1655a6(0x177)](_0x456d54),'velocityTrend':this['calculateVelocityTrend'](_0x4e7d9b,_0x529f6a)},'quality':{'blockedTasksRate':this['calculateBlockedTasksRate'](_0x4e7d9b),'cancelledTasksRate':this[_0x1655a6(0x1ff)](_0x4e7d9b,_0x529f6a),'reworkRate':this[_0x1655a6(0x2a8)](_0x4e7d9b,_0x529f6a)},'efficiency':{'priorityAccuracy':this[_0x1655a6(0x22f)](_0x456d54),'dependencyHandling':this[_0x1655a6(0x243)](_0x4e7d9b),'progressConsistency':this['calculateProgressConsistency'](_0x4e7d9b)}};return{'metrics':_0x2b52af,'recommendations':this[_0x1655a6(0x18c)](_0x2b52af)};}async[a0_0x358c72(0x271)](_0x17a95c,_0x282674){const _0x1e4ca3=a0_0x358c72,_0x22b2b9=_0x17a95c['taskList'][_0x1e4ca3(0x2a1)],_0x512842=parseInt(_0x282674),_0x2acf35={'daily':this['calculateDailyTrends'](_0x22b2b9,_0x512842),'weekly':this['calculateWeeklyTrends'](_0x22b2b9,_0x512842),'priorityTrends':this[_0x1e4ca3(0x264)](_0x22b2b9,_0x512842),'progressTrends':this[_0x1e4ca3(0x1d2)](_0x22b2b9,_0x512842)};return{'trends':_0x2acf35,'forecasts':this[_0x1e4ca3(0x1e1)](_0x2acf35),'patterns':this[_0x1e4ca3(0x275)](_0x2acf35)};}async[a0_0x358c72(0x1ce)](_0x577ad4){const _0x28ee1b=a0_0x358c72;if(!this['scheduler']||!this[_0x28ee1b(0x199)]['getAllAgents'])throw new Error(_0x28ee1b(0x1f5));const _0x129c06=await this['scheduler']['getAllAgents'](),_0x3e21c9=new Date(Date['now']()-parseInt(_0x577ad4)*0x18*0x3c*0x3c*0x3e8),_0x5d0ed8={'agents':[],'aggregatedMetrics':{'totalTasks':0x0,'totalCompleted':0x0,'averageWorkload':0x0,'topPerformers':[],'bottlenecks':[]}};for(const _0x5a022e of _0x129c06){if(!_0x5a022e[_0x28ee1b(0x292)]||!_0x5a022e[_0x28ee1b(0x292)]['tasks'])continue;const _0x312122=_0x5a022e['taskList']['tasks'],_0x2fe572=_0x312122['filter'](_0x425147=>new Date(_0x425147[_0x28ee1b(0x1d6)])>=_0x3e21c9),_0x5ae87c={'agentId':_0x5a022e['id'],'agentName':_0x5a022e[_0x28ee1b(0x1b3)],'totalTasks':_0x2fe572[_0x28ee1b(0x165)],'completed':_0x2fe572['filter'](_0x586a90=>_0x586a90[_0x28ee1b(0x222)]===_0x28ee1b(0x269))['length'],'pending':_0x2fe572[_0x28ee1b(0x20b)](_0x138500=>_0x138500['status']===_0x28ee1b(0x248))[_0x28ee1b(0x165)],'inProgress':_0x2fe572[_0x28ee1b(0x20b)](_0x1737f9=>_0x1737f9[_0x28ee1b(0x222)]==='in_progress')[_0x28ee1b(0x165)],'workloadScore':this[_0x28ee1b(0x232)](_0x312122),'completionRate':_0x2fe572['length']>0x0?Math[_0x28ee1b(0x1b1)](_0x2fe572[_0x28ee1b(0x20b)](_0x1547b5=>_0x1547b5['status']===_0x28ee1b(0x269))[_0x28ee1b(0x165)]/_0x2fe572['length']*0x64):0x0};_0x5d0ed8[_0x28ee1b(0x2a6)]['push'](_0x5ae87c),_0x5d0ed8[_0x28ee1b(0x262)]['totalTasks']+=_0x5ae87c[_0x28ee1b(0x280)],_0x5d0ed8[_0x28ee1b(0x262)]['totalCompleted']+=_0x5ae87c['completed'];}return _0x5d0ed8['aggregatedMetrics']['teamCompletionRate']=_0x5d0ed8[_0x28ee1b(0x262)]['totalTasks']>0x0?Math['round'](_0x5d0ed8['aggregatedMetrics'][_0x28ee1b(0x2b1)]/_0x5d0ed8['aggregatedMetrics']['totalTasks']*0x64):0x0,_0x5d0ed8[_0x28ee1b(0x262)][_0x28ee1b(0x1af)]=_0x5d0ed8['agents']['length']>0x0?Math['round'](_0x5d0ed8[_0x28ee1b(0x2a6)]['reduce']((_0x3f7950,_0x110cae)=>_0x3f7950+_0x110cae['workloadScore'],0x0)/_0x5d0ed8['agents']['length']):0x0,_0x5d0ed8[_0x28ee1b(0x262)][_0x28ee1b(0x22a)]=_0x5d0ed8['agents']['filter'](_0x3e7fb8=>_0x3e7fb8['completionRate']>=0x50)['sort']((_0x23d745,_0x6cfadb)=>_0x6cfadb[_0x28ee1b(0x26d)]-_0x23d745['completionRate'])['slice'](0x0,0x3),_0x5d0ed8['aggregatedMetrics']['bottlenecks']=_0x5d0ed8[_0x28ee1b(0x2a6)]['filter'](_0x56026f=>_0x56026f['workloadScore']>_0x5d0ed8[_0x28ee1b(0x262)][_0x28ee1b(0x1af)]*1.5)[_0x28ee1b(0x1d4)]((_0x25d926,_0x73dbd1)=>_0x73dbd1['workloadScore']-_0x25d926[_0x28ee1b(0x27d)]),{'teamAnalytics':_0x5d0ed8,'workloadDistribution':this['analyzeWorkloadDistribution'](_0x5d0ed8[_0x28ee1b(0x2a6)]),'collaborationMetrics':this['analyzeCollaborationMetrics'](_0x129c06)};}async['exportAnalytics'](_0x14393d,_0x244e6f){const _0x5842c9=a0_0x358c72,{format:format=_0x5842c9(0x186),includeRawData:includeRawData=![],timeframe:timeframe='30'}=_0x244e6f,_0x2f3691={'metadata':{'agentId':_0x14393d['id'],'agentName':_0x14393d[_0x5842c9(0x1b3)],'exportedAt':new Date()[_0x5842c9(0x212)](),'timeframe':timeframe+_0x5842c9(0x17e),'format':format},'summary':await this[_0x5842c9(0x1f8)](_0x14393d,timeframe),'performance':await this['getPerformanceMetrics'](_0x14393d,timeframe),'trends':await this['getTrendAnalysis'](_0x14393d,timeframe)};if(includeRawData){const _0x32218c=new Date(Date[_0x5842c9(0x1da)]()-parseInt(timeframe)*0x18*0x3c*0x3c*0x3e8);_0x2f3691[_0x5842c9(0x1fd)]={'tasks':_0x14393d[_0x5842c9(0x292)]['tasks']['filter'](_0xd57e80=>new Date(_0xd57e80[_0x5842c9(0x1d6)])>=_0x32218c)};}let exportedData;switch(format['toLowerCase']()){case'json':exportedData=JSON[_0x5842c9(0x223)](_0x2f3691,null,0x2);break;case'csv':exportedData=this[_0x5842c9(0x1c4)](_0x2f3691);break;case'summary':exportedData=this[_0x5842c9(0x27c)](_0x2f3691);break;default:throw new Error('Invalid export format. Use: json, csv, or summary');}return{'exportData':exportedData,'format':format,'size':exportedData[_0x5842c9(0x165)],'records':_0x2f3691[_0x5842c9(0x1fd)]?_0x2f3691['rawData'][_0x5842c9(0x2a1)][_0x5842c9(0x165)]:0x0};}async['generateInsights'](_0x305194,_0x2c0da0){const _0x48adc4=a0_0x358c72,_0x1137ee=await this['getAnalyticsSummary'](_0x305194,_0x2c0da0),_0xf9cc7a=await this['getPerformanceMetrics'](_0x305194,_0x2c0da0),_0x2c24dd=await this[_0x48adc4(0x271)](_0x305194,_0x2c0da0),_0xce7d8b={'productivity':this[_0x48adc4(0x15e)](_0x1137ee,_0xf9cc7a,_0x2c24dd),'workflow':this[_0x48adc4(0x1a1)](_0x1137ee,_0xf9cc7a,_0x2c24dd),'optimization':this['generateOptimizationInsights'](_0x1137ee,_0xf9cc7a,_0x2c24dd),'predictions':this[_0x48adc4(0x24a)](_0x2c24dd)};return{'insights':_0xce7d8b,'actionItems':this[_0x48adc4(0x1d8)](_0xce7d8b),'priorities':this['generatePriorityRecommendations'](_0xce7d8b)};}['calculateProgressMetrics'](_0x39acfc){const _0x4142c4=a0_0x358c72,_0x303c8a=_0x39acfc['filter'](_0x23888e=>_0x23888e[_0x4142c4(0x200)]);if(_0x303c8a['length']===0x0)return{'averageProgress':0x0,'stageDistribution':{}};const _0x46128b=Math[_0x4142c4(0x1b1)](_0x303c8a['reduce']((_0x4afc0e,_0x20249c)=>_0x4afc0e+(_0x20249c[_0x4142c4(0x200)]['percentage']||0x0),0x0)/_0x303c8a[_0x4142c4(0x165)]),_0x15cd1f={};return this[_0x4142c4(0x224)]['forEach'](_0x2705cf=>{const _0x5b9cf0=_0x4142c4;_0x15cd1f[_0x2705cf]=_0x303c8a['filter'](_0x4b6384=>_0x4b6384[_0x5b9cf0(0x200)][_0x5b9cf0(0x179)]===_0x2705cf)['length'];}),{'averageProgress':_0x46128b,'stageDistribution':_0x15cd1f};}['calculateDependencyMetrics'](_0x389b30){const _0x112c8e=a0_0x358c72,_0x17ea04=_0x389b30['filter'](_0x3b80b9=>_0x3b80b9[_0x112c8e(0x278)]&&_0x3b80b9[_0x112c8e(0x278)]['length']>0x0),_0x47eac9=_0x389b30['filter'](_0x3c6f2d=>_0x3c6f2d['status']==='blocked')['length'];return{'tasksWithDependencies':_0x17ea04[_0x112c8e(0x165)],'averageDependencies':_0x17ea04[_0x112c8e(0x165)]>0x0?Math[_0x112c8e(0x1b1)](_0x17ea04[_0x112c8e(0x29c)]((_0x47537b,_0x318c50)=>_0x47537b+_0x318c50['dependencies'][_0x112c8e(0x165)],0x0)/_0x17ea04['length']):0x0,'blockedTasks':_0x47eac9,'dependencyChainLength':this[_0x112c8e(0x229)](_0x389b30)};}['calculateTemplateUsage'](_0x44ddc2){const _0x3d81d3=a0_0x358c72,_0x4d09c1=_0x44ddc2['filter'](_0x23d7b3=>_0x23d7b3['source']==='template-generated'),_0x4ce227={};return _0x4d09c1['forEach'](_0x4698be=>{const _0x399aeb=a0_0x411c,_0x4b82de=_0x4698be[_0x399aeb(0x183)]||'unknown';_0x4ce227[_0x4b82de]=(_0x4ce227[_0x4b82de]||0x0)+0x1;}),{'totalTemplateGenerated':_0x4d09c1['length'],'templateDistribution':_0x4ce227,'templateEfficiency':this[_0x3d81d3(0x2ad)](_0x4d09c1)};}['calculateCompletionRate'](_0x4c4c0d,_0x1a8f90){const _0x508e1f=a0_0x358c72,_0x372f3d=new Date(Date['now']()-parseInt(_0x1a8f90)*0x18*0x3c*0x3c*0x3e8),_0x547255=_0x4c4c0d[_0x508e1f(0x20b)](_0x267036=>new Date(_0x267036['createdAt'])>=_0x372f3d);return _0x547255[_0x508e1f(0x165)]>0x0?Math[_0x508e1f(0x1b1)](_0x547255[_0x508e1f(0x20b)](_0x371e61=>_0x371e61[_0x508e1f(0x222)]===_0x508e1f(0x269))[_0x508e1f(0x165)]/_0x547255[_0x508e1f(0x165)]*0x64):0x0;}[a0_0x358c72(0x177)](_0x52855d){const _0x1ef53c=a0_0x358c72;if(_0x52855d['length']===0x0)return 0x0;const _0xcf1ca0=_0x52855d['map'](_0x2de0f4=>{const _0x43bf5e=new Date(_0x2de0f4['createdAt']),_0x305d45=new Date(_0x2de0f4['completedAt']);return(_0x305d45-_0x43bf5e)/(0x3e8*0x3c*0x3c*0x18);});return Math[_0x1ef53c(0x1b1)](_0xcf1ca0['reduce']((_0x3fbd45,_0x48a213)=>_0x3fbd45+_0x48a213,0x0)/_0xcf1ca0['length']*0xa)/0xa;}['generateSummaryInsights'](_0x1fa96b){const _0x3feda6=a0_0x358c72,_0x60f6a7=[];return _0x1fa96b[_0x3feda6(0x26d)]<0x32&&_0x60f6a7['push'](_0x3feda6(0x15b)),_0x1fa96b['averageTaskAge']>0x7&&_0x60f6a7['push']('Tasks\x20are\x20aging\x20(avg:\x20'+_0x1fa96b['averageTaskAge']+'\x20days).\x20Focus\x20on\x20completing\x20older\x20tasks.'),_0x1fa96b[_0x3feda6(0x185)]['urgent']>_0x1fa96b['overview'][_0x3feda6(0x280)]*0.3&&_0x60f6a7[_0x3feda6(0x245)]('High\x20proportion\x20of\x20urgent\x20tasks.\x20Consider\x20better\x20planning\x20and\x20early\x20issue\x20identification.'),_0x60f6a7;}[a0_0x358c72(0x18c)](_0x2eeb5a){const _0x37cdc0=a0_0x358c72,_0x471494=[];return _0x2eeb5a['productivity']['completionRate']<0x46&&_0x471494['push']('Focus\x20on\x20improving\x20task\x20completion\x20rate\x20through\x20better\x20time\x20management'),_0x2eeb5a[_0x37cdc0(0x19c)][_0x37cdc0(0x210)]>0x14&&_0x471494['push'](_0x37cdc0(0x20e)),_0x2eeb5a[_0x37cdc0(0x15a)]['priorityAccuracy']<0x3c&&_0x471494[_0x37cdc0(0x245)](_0x37cdc0(0x194)),_0x471494;}['calculateWorkloadScore'](_0x113bd4){const _0xbe35a8=a0_0x358c72,_0x4b6a2c=_0x113bd4['filter'](_0x508648=>_0x508648['status']===_0xbe35a8(0x248)||_0x508648['status']===_0xbe35a8(0x1f3)),_0x5f5cef=_0x4b6a2c[_0xbe35a8(0x20b)](_0x24c8d2=>_0x24c8d2['priority']==='urgent')[_0xbe35a8(0x165)],_0x430b02=_0x4b6a2c[_0xbe35a8(0x20b)](_0x153f3d=>_0x153f3d[_0xbe35a8(0x28a)]===_0xbe35a8(0x19e))['length'];return _0x5f5cef*0x3+_0x430b02*0x2+_0x4b6a2c['length'];}[a0_0x358c72(0x229)](_0x1e93c4){const _0x127c0a=a0_0x358c72;return Math['max'](0x0,..._0x1e93c4[_0x127c0a(0x15d)](_0xf981cc=>_0xf981cc['dependencies']?_0xf981cc[_0x127c0a(0x278)]['length']:0x0));}['calculateTemplateEfficiency'](_0x315ea2){const _0x553a47=a0_0x358c72;if(_0x315ea2[_0x553a47(0x165)]===0x0)return 0x64;const _0x325956=_0x315ea2['filter'](_0x2bb5c8=>_0x2bb5c8['status']===_0x553a47(0x269))['length'];return Math[_0x553a47(0x1b1)](_0x325956/_0x315ea2['length']*0x64);}['calculateVelocityTrend'](_0x36eb3e,_0x56c785){const _0x3fbeba=a0_0x358c72,_0x3cfe52=new Date(Date[_0x3fbeba(0x1da)]()-parseInt(_0x56c785)*0x18*0x3c*0x3c*0x3e8),_0x455eb6=_0x36eb3e['filter'](_0x32f5a3=>_0x32f5a3['status']==='completed'&&_0x32f5a3[_0x3fbeba(0x20c)]&&new Date(_0x32f5a3[_0x3fbeba(0x20c)])>=_0x3cfe52)['length'];return Math[_0x3fbeba(0x1b1)](_0x455eb6/parseInt(_0x56c785)*0x7);}['calculateBlockedTasksRate'](_0x17fcc2){const _0x53bcee=a0_0x358c72,_0x3890b9=_0x17fcc2[_0x53bcee(0x20b)](_0x594fa1=>_0x594fa1[_0x53bcee(0x222)]!=='completed'&&_0x594fa1['status']!=='cancelled');if(_0x3890b9[_0x53bcee(0x165)]===0x0)return 0x0;const _0x20fb20=_0x17fcc2[_0x53bcee(0x20b)](_0x56dd65=>_0x56dd65[_0x53bcee(0x222)]===_0x53bcee(0x1b2))['length'];return Math['round'](_0x20fb20/_0x3890b9[_0x53bcee(0x165)]*0x64);}[a0_0x358c72(0x1ff)](_0x4650e8,_0x3e8e9c){const _0x399757=a0_0x358c72,_0x2f62ef=new Date(Date[_0x399757(0x1da)]()-parseInt(_0x3e8e9c)*0x18*0x3c*0x3c*0x3e8),_0x3e76a5=_0x4650e8['filter'](_0x4afe1e=>new Date(_0x4afe1e['createdAt'])>=_0x2f62ef);if(_0x3e76a5['length']===0x0)return 0x0;const _0x3ef76e=_0x3e76a5[_0x399757(0x20b)](_0x4d50cc=>_0x4d50cc['status']==='cancelled')['length'];return Math['round'](_0x3ef76e/_0x3e76a5[_0x399757(0x165)]*0x64);}[a0_0x358c72(0x2a8)](_0x4b9be9,_0x257156){const _0x16be3f=a0_0x358c72,_0x51dd24=new Date(Date[_0x16be3f(0x1da)]()-parseInt(_0x257156)*0x18*0x3c*0x3c*0x3e8),_0x3454ea=_0x4b9be9['filter'](_0x42152a=>new Date(_0x42152a['createdAt'])>=_0x51dd24),_0x2ddfcc=_0x3454ea['filter'](_0x4eec94=>_0x4eec94['progress']&&_0x4eec94[_0x16be3f(0x200)]['stageHistory']&&_0x4eec94[_0x16be3f(0x200)][_0x16be3f(0x21a)][_0x16be3f(0x215)](_0x3f31c1=>this[_0x16be3f(0x224)][_0x16be3f(0x276)](_0x3f31c1['to'])<this[_0x16be3f(0x224)][_0x16be3f(0x276)](_0x3f31c1[_0x16be3f(0x26b)])))[_0x16be3f(0x165)];return _0x3454ea[_0x16be3f(0x165)]>0x0?Math['round'](_0x2ddfcc/_0x3454ea['length']*0x64):0x0;}[a0_0x358c72(0x22f)](_0x1a9689){const _0x4995c2=a0_0x358c72;if(_0x1a9689['length']===0x0)return 0x64;const _0x458d9e=_0x1a9689[_0x4995c2(0x20b)](_0x3dd8e3=>{const _0x320ed9=_0x4995c2;if(!['urgent',_0x320ed9(0x19e)][_0x320ed9(0x184)](_0x3dd8e3['priority']))return![];const _0x690c62=new Date(_0x3dd8e3['createdAt']),_0x58a8ff=new Date(_0x3dd8e3['completedAt']),_0x1fd712=(_0x58a8ff-_0x690c62)/(0x3e8*0x3c*0x3c*0x18);return _0x1fd712<=0x3;})[_0x4995c2(0x165)],_0x5dab31=_0x1a9689['filter'](_0x2b82f1=>[_0x4995c2(0x1b4),_0x4995c2(0x19e)]['includes'](_0x2b82f1[_0x4995c2(0x28a)]))['length'];return _0x5dab31>0x0?Math['round'](_0x458d9e/_0x5dab31*0x64):0x64;}['calculateDependencyEfficiency'](_0x48ebca){const _0x5520ed=a0_0x358c72,_0x3b07ec=_0x48ebca[_0x5520ed(0x20b)](_0x1d60e5=>_0x1d60e5['dependencies']&&_0x1d60e5[_0x5520ed(0x278)]['length']>0x0);if(_0x3b07ec['length']===0x0)return 0x64;const _0x19c5e3=_0x3b07ec[_0x5520ed(0x20b)](_0x5be268=>_0x5be268[_0x5520ed(0x222)]!=='blocked')['length'];return Math['round'](_0x19c5e3/_0x3b07ec['length']*0x64);}[a0_0x358c72(0x225)](_0x14a8e4){const _0x3c1ed5=a0_0x358c72,_0x35e183=_0x14a8e4['filter'](_0x2e1e33=>_0x2e1e33['progress']&&_0x2e1e33[_0x3c1ed5(0x200)][_0x3c1ed5(0x1dd)]!==undefined);if(_0x35e183['length']===0x0)return 0x64;const _0x47b856=_0x35e183['filter'](_0x3e6c64=>{const _0x4529a6=_0x3c1ed5,_0xcb6ce5=_0x3e6c64[_0x4529a6(0x200)]['stage'],_0x1260fd=_0x3e6c64[_0x4529a6(0x200)][_0x4529a6(0x1dd)];if(_0xcb6ce5==='not_started'&&_0x1260fd===0x0)return!![];if(_0xcb6ce5===_0x4529a6(0x29f)&&_0x1260fd>0x0&&_0x1260fd<0x19)return!![];if(_0xcb6ce5==='in_development'&&_0x1260fd>=0x19&&_0x1260fd<0x4b)return!![];if(_0xcb6ce5==='testing'&&_0x1260fd>=0x4b&&_0x1260fd<0x5f)return!![];if(_0xcb6ce5===_0x4529a6(0x1c3)&&_0x1260fd>=0x5f&&_0x1260fd<0x64)return!![];if(_0xcb6ce5===_0x4529a6(0x269)&&_0x1260fd===0x64)return!![];return![];})[_0x3c1ed5(0x165)];return Math['round'](_0x47b856/_0x35e183['length']*0x64);}[a0_0x358c72(0x20f)](_0x182944,_0x1369bc){const _0x5c4ebf=a0_0x358c72,_0xd03d0c=[];for(let _0x5a6236=0x0;_0x5a6236<_0x1369bc;_0x5a6236++){const _0x370f46=new Date(Date[_0x5c4ebf(0x1da)]()-_0x5a6236*0x18*0x3c*0x3c*0x3e8),_0x543aae=new Date(_0x370f46['getFullYear'](),_0x370f46[_0x5c4ebf(0x1c9)](),_0x370f46[_0x5c4ebf(0x166)]()),_0x332e90=new Date(_0x543aae[_0x5c4ebf(0x1ba)]()+0x18*0x3c*0x3c*0x3e8),_0x48e89a=_0x182944[_0x5c4ebf(0x20b)](_0x289482=>{const _0x16bbf2=new Date(_0x289482['createdAt']);return _0x16bbf2>=_0x543aae&&_0x16bbf2<_0x332e90;});_0xd03d0c[_0x5c4ebf(0x24c)]({'date':_0x543aae[_0x5c4ebf(0x212)]()['split']('T')[0x0],'created':_0x48e89a['length'],'completed':_0x48e89a[_0x5c4ebf(0x20b)](_0x5cbac2=>_0x5cbac2[_0x5c4ebf(0x222)]===_0x5c4ebf(0x269))['length']});}return _0xd03d0c;}[a0_0x358c72(0x163)](_0x15db28,_0x15199a){const _0x5ac81b=a0_0x358c72,_0x28e1f7=Math['ceil'](_0x15199a/0x7),_0x369873=[];for(let _0x9340f1=0x0;_0x9340f1<_0x28e1f7;_0x9340f1++){const _0x4d7d3e=new Date(Date['now']()-(_0x9340f1+0x1)*0x7*0x18*0x3c*0x3c*0x3e8),_0xc87727=new Date(Date['now']()-_0x9340f1*0x7*0x18*0x3c*0x3c*0x3e8),_0x434d0a=_0x15db28[_0x5ac81b(0x20b)](_0x3b781a=>{const _0x44e82f=new Date(_0x3b781a['createdAt']);return _0x44e82f>=_0x4d7d3e&&_0x44e82f<_0xc87727;});_0x369873[_0x5ac81b(0x24c)]({'week':'Week\x20'+(_0x28e1f7-_0x9340f1),'created':_0x434d0a[_0x5ac81b(0x165)],'completed':_0x434d0a['filter'](_0x132c08=>_0x132c08[_0x5ac81b(0x222)]==='completed')[_0x5ac81b(0x165)]});}return _0x369873;}[a0_0x358c72(0x264)](_0x33061d,_0x33aa4c){const _0x101710=a0_0x358c72,_0x1909dd=new Date(Date[_0x101710(0x1da)]()-_0x33aa4c*0x18*0x3c*0x3c*0x3e8),_0xc4be6f=_0x33061d[_0x101710(0x20b)](_0x65e5a5=>new Date(_0x65e5a5[_0x101710(0x1d6)])>=_0x1909dd);return{'urgent':_0xc4be6f['filter'](_0x5d9887=>_0x5d9887['priority']==='urgent')[_0x101710(0x165)],'high':_0xc4be6f['filter'](_0x9212dc=>_0x9212dc['priority']===_0x101710(0x19e))['length'],'medium':_0xc4be6f['filter'](_0x804c76=>_0x804c76['priority']===_0x101710(0x1f9))['length'],'low':_0xc4be6f['filter'](_0x434cd8=>_0x434cd8[_0x101710(0x28a)]==='low')[_0x101710(0x165)]};}[a0_0x358c72(0x1d2)](_0x8d6fb8,_0x48ccec){const _0x406ca9=a0_0x358c72,_0x57e23f=new Date(Date[_0x406ca9(0x1da)]()-_0x48ccec*0x18*0x3c*0x3c*0x3e8),_0x582d46=_0x8d6fb8[_0x406ca9(0x20b)](_0x4904f7=>new Date(_0x4904f7[_0x406ca9(0x1d6)])>=_0x57e23f),_0x4ba57f=_0x582d46['filter'](_0x384d46=>_0x384d46['progress']),_0x1c1852={};return this['progressStages']['forEach'](_0x355124=>{const _0xe6fb0=_0x406ca9;_0x1c1852[_0x355124]=_0x4ba57f[_0xe6fb0(0x20b)](_0x1b5349=>_0x1b5349[_0xe6fb0(0x200)][_0xe6fb0(0x179)]===_0x355124)['length'];}),_0x1c1852;}['generateForecasts'](_0x5b4ea4){const _0x5c0e8f=a0_0x358c72;return{'predictedCompletions':this[_0x5c0e8f(0x1b9)](_0x5b4ea4['daily']),'workloadForecast':this['predictWorkloadTrend'](_0x5b4ea4['weekly']),'priorityShift':this[_0x5c0e8f(0x279)](_0x5b4ea4['priorityTrends'])};}['identifyPatterns'](_0x471c90){const _0x1f7489=a0_0x358c72;return{'peakDays':this[_0x1f7489(0x1bd)](_0x471c90['daily']),'cyclicalPatterns':this[_0x1f7489(0x1f0)](_0x471c90['weekly']),'priorityPatterns':this[_0x1f7489(0x1a6)](_0x471c90[_0x1f7489(0x238)])};}['predictFutureCompletions'](_0x3c935c){const _0x3af36c=a0_0x358c72;if(_0x3c935c[_0x3af36c(0x165)]<0x7)return _0x3af36c(0x219);const _0xab3079=_0x3c935c[_0x3af36c(0x16c)](-0x7)['reduce']((_0x34ed73,_0x45360c)=>_0x34ed73+_0x45360c[_0x3af36c(0x269)],0x0)/0x7;return Math[_0x3af36c(0x1b1)](_0xab3079)+_0x3af36c(0x21d);}[a0_0x358c72(0x1ae)](_0x44de5e){const _0x564b3a=a0_0x358c72;if(_0x44de5e[_0x564b3a(0x165)]<0x2)return _0x564b3a(0x261);const _0x205561=_0x44de5e[_0x44de5e['length']-0x1][_0x564b3a(0x25e)],_0x2c7c16=_0x44de5e[_0x44de5e[_0x564b3a(0x165)]-0x2]['created'],_0x2dc184=(_0x205561-_0x2c7c16)/_0x2c7c16*0x64;if(_0x2dc184>0x14)return'Increasing\x20workload';if(_0x2dc184<-0x14)return'Decreasing\x20workload';return'Stable\x20workload';}['predictPriorityShift'](_0x245b4c){const _0x39238e=a0_0x358c72,_0x2a8176=Object[_0x39238e(0x174)](_0x245b4c)['reduce']((_0x4bbca7,_0x57ba6a)=>_0x4bbca7+_0x57ba6a,0x0);if(_0x2a8176===0x0)return _0x39238e(0x206);const _0x24a64b=_0x245b4c['urgent']/_0x2a8176*0x64;if(_0x24a64b>0x1e)return _0x39238e(0x1c6);return _0x39238e(0x28b);}[a0_0x358c72(0x1bd)](_0x515116){const _0x4d0835=a0_0x358c72,_0x96807d=Math['max'](..._0x515116[_0x4d0835(0x15d)](_0x2989cd=>_0x2989cd[_0x4d0835(0x25e)]));return _0x515116['filter'](_0x47431a=>_0x47431a[_0x4d0835(0x25e)]===_0x96807d)['map'](_0x27afb8=>_0x27afb8[_0x4d0835(0x2ab)]);}[a0_0x358c72(0x1f0)](_0x3a4bc7){const _0x528c25=a0_0x358c72;if(_0x3a4bc7[_0x528c25(0x165)]<0x4)return _0x528c25(0x2b8);return _0x528c25(0x2a9);}['identifyPriorityPatterns'](_0x1d4c47){const _0x19e8a9=a0_0x358c72,_0x3109b8=Object['values'](_0x1d4c47)[_0x19e8a9(0x29c)]((_0xb3eb2,_0x4a89b5)=>_0xb3eb2+_0x4a89b5,0x0);if(_0x3109b8===0x0)return'No\x20priority\x20patterns';const _0x2240cf=Object['entries'](_0x1d4c47)['reduce']((_0x104cbd,[_0x4dc391,_0x276c5f])=>_0x276c5f>_0x104cbd['count']?{'priority':_0x4dc391,'count':_0x276c5f}:_0x104cbd,{'priority':'','count':0x0});return _0x2240cf['priority']+_0x19e8a9(0x21e)+Math['round'](_0x2240cf[_0x19e8a9(0x1ef)]/_0x3109b8*0x64)+'%)';}['generateProductivityInsights'](_0x4cf38f,_0x4ad8da,_0xe43b5a){const _0x5e20f4=a0_0x358c72,_0x5b6a8c=[];if(_0x4ad8da[_0x5e20f4(0x1e5)][_0x5e20f4(0x256)][_0x5e20f4(0x26d)]>0x50)_0x5b6a8c[_0x5e20f4(0x245)](_0x5e20f4(0x218));else _0x4ad8da[_0x5e20f4(0x1e5)][_0x5e20f4(0x256)]['completionRate']<0x32&&_0x5b6a8c['push'](_0x5e20f4(0x1b5));return _0x4cf38f[_0x5e20f4(0x17d)]['averageTaskAge']>0xa&&_0x5b6a8c[_0x5e20f4(0x245)]('Tasks\x20are\x20aging\x20significantly\x20-\x20prioritize\x20older\x20tasks'),_0x5b6a8c;}[a0_0x358c72(0x1a1)](_0x2bf301,_0x5672a0,_0x32a30c){const _0x1c6dd2=a0_0x358c72,_0x13e88a=[];return _0x2bf301[_0x1c6dd2(0x17d)]['dependencyMetrics']['blockedTasks']>0x3&&_0x13e88a['push'](_0x1c6dd2(0x167)),_0x2bf301['summary'][_0x1c6dd2(0x182)][_0x1c6dd2(0x1c2)]>_0x2bf301['summary'][_0x1c6dd2(0x17a)]['totalTasks']*0.5&&_0x13e88a['push']('Heavy\x20template\x20usage\x20-\x20consider\x20workflow\x20optimization'),_0x13e88a;}[a0_0x358c72(0x19d)](_0x50da08,_0x1c0271,_0x563e17){const _0x38e9f0=a0_0x358c72,_0x38ad29=[];return _0x1c0271[_0x38e9f0(0x1e5)]['efficiency'][_0x38e9f0(0x1bc)]<0x46&&_0x38ad29['push'](_0x38e9f0(0x1fa)),_0x1c0271['metrics']['quality'][_0x38e9f0(0x210)]>0xf&&_0x38ad29[_0x38e9f0(0x245)](_0x38e9f0(0x1a9)),_0x38ad29;}[a0_0x358c72(0x24a)](_0x2b7468){const _0x5a843f=a0_0x358c72;return[_0x2b7468['forecasts']['predictedCompletions'],_0x2b7468['forecasts'][_0x5a843f(0x16e)],_0x2b7468[_0x5a843f(0x294)][_0x5a843f(0x297)]];}['generateActionItems'](_0x4d5169){const _0x7a4c09=a0_0x358c72,_0xdccb0a=[..._0x4d5169['productivity'],..._0x4d5169['workflow'],..._0x4d5169['optimization']];return _0xdccb0a[_0x7a4c09(0x15d)]((_0x463374,_0x4d1518)=>({'id':'action-'+(_0x4d1518+0x1),'description':_0x463374,'priority':_0x463374[_0x7a4c09(0x184)]('urgent')||_0x463374[_0x7a4c09(0x184)]('critical')?'high':'medium','category':_0x463374[_0x7a4c09(0x184)]('productivity')?_0x7a4c09(0x256):_0x463374['includes'](_0x7a4c09(0x22e))?'workflow':_0x7a4c09(0x249)}));}[a0_0x358c72(0x259)](_0x4bce3f){const _0x5318db=a0_0x358c72,_0x4bcb0f=[];return _0x4bce3f['productivity'][_0x5318db(0x215)](_0x5dc70a=>_0x5dc70a[_0x5318db(0x184)]('Low\x20productivity'))&&_0x4bcb0f[_0x5318db(0x245)]({'priority':_0x5318db(0x1b4),'action':_0x5318db(0x168),'impact':_0x5318db(0x19e)}),_0x4bce3f['workflow']['some'](_0x513787=>_0x513787['includes']('blocked\x20tasks'))&&_0x4bcb0f[_0x5318db(0x245)]({'priority':'high','action':_0x5318db(0x21f),'impact':'medium'}),_0x4bcb0f;}['analyzeWorkloadDistribution'](_0x2556a7){const _0x546482=a0_0x358c72;if(_0x2556a7[_0x546482(0x165)]===0x0)return{'balance':'No\x20agents','distribution':[]};const _0x264b4e=_0x2556a7['map'](_0x1ad47d=>_0x1ad47d['workloadScore']),_0x140e32=_0x264b4e[_0x546482(0x29c)]((_0x2476a0,_0x5ba85b)=>_0x2476a0+_0x5ba85b,0x0)/_0x264b4e[_0x546482(0x165)],_0xb44e1a=Math['max'](..._0x264b4e[_0x546482(0x15d)](_0x437847=>Math['abs'](_0x437847-_0x140e32)));return{'balance':_0xb44e1a>_0x140e32*0.5?'Unbalanced':'Balanced','distribution':_0x2556a7['map'](_0x2a92b8=>({'agent':_0x2a92b8[_0x546482(0x202)],'workload':_0x2a92b8['workloadScore'],'deviation':Math['round']((_0x2a92b8[_0x546482(0x27d)]-_0x140e32)/_0x140e32*0x64)}))};}['analyzeCollaborationMetrics'](_0x7f02b2){const _0x1a80ea=a0_0x358c72;return{'totalAgents':_0x7f02b2[_0x1a80ea(0x165)],'activeAgents':_0x7f02b2[_0x1a80ea(0x20b)](_0x46b6f1=>_0x46b6f1['taskList']&&_0x46b6f1['taskList'][_0x1a80ea(0x2a1)][_0x1a80ea(0x165)]>0x0)[_0x1a80ea(0x165)],'collaborationScore':Math['round'](Math['random']()*0x64)};}[a0_0x358c72(0x1c4)](_0x27db07){const _0x4f12cc=a0_0x358c72,_0x3fd983=[_0x4f12cc(0x23e),'Value'],_0x16f29c=[[_0x4f12cc(0x2b9),_0x27db07['summary']['summary']['overview'][_0x4f12cc(0x280)]],['Completed\x20Tasks',_0x27db07['summary'][_0x4f12cc(0x17d)]['overview']['completed']],[_0x4f12cc(0x244),_0x27db07[_0x4f12cc(0x17d)][_0x4f12cc(0x17d)]['completionRate']+'%'],['Average\x20Task\x20Age',_0x27db07[_0x4f12cc(0x17d)][_0x4f12cc(0x17d)][_0x4f12cc(0x1be)]+_0x4f12cc(0x17e)]];return[_0x3fd983,..._0x16f29c]['map'](_0x50c7d9=>_0x50c7d9['join'](','))['join']('\x0a');}[a0_0x358c72(0x27c)](_0x222352){const _0x487979=a0_0x358c72,_0xa7e65d=_0x222352[_0x487979(0x17d)]['summary'];return('\x0aAnalytics\x20Summary\x0a================\x0aTotal\x20Tasks:\x20'+_0xa7e65d['overview']['totalTasks']+'\x0aCompleted:\x20'+_0xa7e65d['overview']['completed']+'\x20('+_0xa7e65d['completionRate']+'%)\x0aIn\x20Progress:\x20'+_0xa7e65d[_0x487979(0x17a)][_0x487979(0x205)]+'\x0aPending:\x20'+_0xa7e65d[_0x487979(0x17a)][_0x487979(0x248)]+'\x0aAverage\x20Task\x20Age:\x20'+_0xa7e65d['averageTaskAge']+_0x487979(0x23a)+_0x222352['summary']['insights'][_0x487979(0x15d)](_0x320156=>'-\x20'+_0x320156)['join']('\x0a')+_0x487979(0x237))['trim']();}[a0_0x358c72(0x15f)](_0x5f0b54){const _0x360650=a0_0x358c72;if(!_0x5f0b54[_0x360650(0x188)])return _0x360650(0x21b)+_0x5f0b54['error'];const _0xb7bdf7=[_0x360650(0x207)+_0x5f0b54['action']+'\x20completed'];return _0x5f0b54['result']['task']&&_0xb7bdf7[_0x360650(0x245)]('Task:\x20['+_0x5f0b54['result'][_0x360650(0x270)][_0x360650(0x222)]+']\x20'+_0x5f0b54['result']['task'][_0x360650(0x250)]+'\x20('+_0x5f0b54[_0x360650(0x1cb)]['task']['id']+')'),_0x5f0b54['result'][_0x360650(0x2a1)]&&(_0xb7bdf7[_0x360650(0x245)]('Found\x20'+_0x5f0b54[_0x360650(0x1cb)]['tasks']['length']+_0x360650(0x191)),_0x5f0b54[_0x360650(0x1cb)][_0x360650(0x2a1)]['forEach'](_0x610fc6=>{const _0x32ab95=_0x360650;_0xb7bdf7['push'](_0x32ab95(0x18e)+_0x610fc6[_0x32ab95(0x222)]+']\x20'+_0x610fc6[_0x32ab95(0x250)]+_0x32ab95(0x2b4)+_0x610fc6['priority']+')');})),_0x5f0b54['summary']&&_0xb7bdf7['push'](_0x360650(0x193)+_0x5f0b54[_0x360650(0x17d)]['pending']+_0x360650(0x246)+_0x5f0b54[_0x360650(0x17d)]['in_progress']+'\x20in\x20progress,\x20'+_0x5f0b54[_0x360650(0x17d)]['completed']+_0x360650(0x1d7)),_0xb7bdf7[_0x360650(0x221)]('\x0a');}}export default TaskManagerTool;
|