snow-flow 3.0.9 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/claude-flow.bat +0 -0
  2. package/claude-flow.ps1 +0 -0
  3. package/dist/mcp/servicenow-automation-mcp.js +0 -0
  4. package/dist/mcp/servicenow-deployment-mcp.js +0 -0
  5. package/dist/mcp/servicenow-integration-mcp.js +0 -0
  6. package/dist/mcp/servicenow-mcp-server.js +0 -0
  7. package/dist/mcp/servicenow-operations-mcp.js +0 -0
  8. package/dist/mcp/servicenow-platform-development-mcp.js +0 -0
  9. package/dist/mcp/servicenow-progressive-indexer.js +0 -0
  10. package/dist/mcp/servicenow-reporting-analytics-mcp.js +133 -19
  11. package/dist/mcp/servicenow-security-compliance-mcp.js +0 -0
  12. package/dist/mcp/servicenow-update-set-mcp.js +0 -0
  13. package/dist/mcp/start-all-mcp-servers.js +0 -0
  14. package/dist/mcp/start-servicenow-mcp.js +0 -0
  15. package/memory/agents/README.md +1 -1
  16. package/memory/claude-flow-data.json +1 -1
  17. package/memory/sessions/README.md +1 -1
  18. package/package.json +2 -2
  19. package/.mcp.json +0 -22
  20. package/claude-flow.config.json +0 -20
  21. package/dist/agents/app-creator.agent.d.ts +0 -55
  22. package/dist/agents/app-creator.agent.js +0 -1292
  23. package/dist/agents/base/base-snow-agent.d.ts +0 -75
  24. package/dist/agents/base/base-snow-agent.js +0 -169
  25. package/dist/agents/base-snow-agent.d.ts +0 -63
  26. package/dist/agents/base-snow-agent.js +0 -296
  27. package/dist/agents/coordinator.d.ts +0 -200
  28. package/dist/agents/coordinator.js +0 -777
  29. package/dist/agents/flow-builder-agent.d.ts +0 -18
  30. package/dist/agents/flow-builder-agent.js +0 -197
  31. package/dist/agents/queen-403-handler.d.ts +0 -47
  32. package/dist/agents/queen-403-handler.js +0 -175
  33. package/dist/agents/queen-agent-example.d.ts +0 -23
  34. package/dist/agents/queen-agent-example.js +0 -240
  35. package/dist/agents/queen-agent.test.d.ts +0 -6
  36. package/dist/agents/script-generator.agent.d.ts +0 -32
  37. package/dist/agents/script-generator.agent.js +0 -772
  38. package/dist/agents/script-writer-agent.d.ts +0 -22
  39. package/dist/agents/script-writer-agent.js +0 -695
  40. package/dist/agents/security-agent.d.ts +0 -23
  41. package/dist/agents/security-agent.js +0 -619
  42. package/dist/agents/specialists/automation-specialist.agent.d.ts +0 -44
  43. package/dist/agents/specialists/automation-specialist.agent.js +0 -204
  44. package/dist/agents/specialists/data-specialist.agent.d.ts +0 -165
  45. package/dist/agents/specialists/data-specialist.agent.js +0 -484
  46. package/dist/agents/specialists/integration-specialist.agent.d.ts +0 -227
  47. package/dist/agents/specialists/integration-specialist.agent.js +0 -725
  48. package/dist/agents/specialists/reporting-specialist.agent.d.ts +0 -54
  49. package/dist/agents/specialists/reporting-specialist.agent.js +0 -193
  50. package/dist/agents/specialists/security-specialist.agent.d.ts +0 -85
  51. package/dist/agents/specialists/security-specialist.agent.js +0 -309
  52. package/dist/agents/teams/adaptive/adaptive-coordinator.agent.d.ts +0 -111
  53. package/dist/agents/teams/adaptive/adaptive-coordinator.agent.js +0 -383
  54. package/dist/agents/teams/base-team.d.ts +0 -72
  55. package/dist/agents/teams/base-team.js +0 -253
  56. package/dist/agents/teams/team-types.d.ts +0 -265
  57. package/dist/agents/teams/team-types.js +0 -3
  58. package/dist/agents/teams/widget/widget-architect.agent.d.ts +0 -61
  59. package/dist/agents/teams/widget/widget-architect.agent.js +0 -436
  60. package/dist/agents/teams/widget/widget-backend.agent.d.ts +0 -74
  61. package/dist/agents/teams/widget/widget-backend.agent.js +0 -1531
  62. package/dist/agents/teams/widget/widget-frontend.agent.d.ts +0 -67
  63. package/dist/agents/teams/widget/widget-frontend.agent.js +0 -1014
  64. package/dist/agents/teams/widget/widget-platform.agent.d.ts +0 -90
  65. package/dist/agents/teams/widget/widget-platform.agent.js +0 -1190
  66. package/dist/agents/teams/widget/widget-uiux.agent.d.ts +0 -107
  67. package/dist/agents/teams/widget/widget-uiux.agent.js +0 -1033
  68. package/dist/agents/test-agent.d.ts +0 -26
  69. package/dist/agents/test-agent.js +0 -734
  70. package/dist/agents/test-agents.d.ts +0 -7
  71. package/dist/agents/test-agents.js +0 -64
  72. package/dist/agents/ui-builder.agent.d.ts +0 -50
  73. package/dist/agents/ui-builder.agent.js +0 -1539
  74. package/dist/agents/widget-builder.agent.d.ts +0 -32
  75. package/dist/agents/widget-builder.agent.js +0 -439
  76. package/dist/agents/widget-creator-agent.d.ts +0 -18
  77. package/dist/agents/widget-creator-agent.js +0 -498
  78. package/dist/agents/workflow-designer.agent.d.ts +0 -31
  79. package/dist/agents/workflow-designer.agent.js +0 -583
  80. package/dist/api/error-handling.d.ts +0 -325
  81. package/dist/api/error-handling.js +0 -1488
  82. package/dist/api/flow-designer-api.d.ts +0 -167
  83. package/dist/api/flow-designer-api.js +0 -554
  84. package/dist/api/natural-language-mapper.d.ts +0 -124
  85. package/dist/api/natural-language-mapper.js +0 -501
  86. package/dist/api/performance-optimizer.d.ts +0 -240
  87. package/dist/api/performance-optimizer.js +0 -706
  88. package/dist/api/transaction-manager.d.ts +0 -189
  89. package/dist/api/transaction-manager.js +0 -576
  90. package/dist/assembly/team-assembler.d.ts +0 -140
  91. package/dist/assembly/team-assembler.js +0 -502
  92. package/dist/benchmark-performance.d.ts +0 -41
  93. package/dist/benchmark-performance.js +0 -230
  94. package/dist/cli/snow-flow-cli-integration.d.ts +0 -30
  95. package/dist/cli/snow-flow-cli-integration.js +0 -396
  96. package/dist/coordination/coordination-engine.d.ts +0 -41
  97. package/dist/coordination/coordination-engine.js +0 -324
  98. package/dist/coordination/coordination.test.d.ts +0 -6
  99. package/dist/coordination/example.d.ts +0 -31
  100. package/dist/coordination/example.js +0 -394
  101. package/dist/coordination/execution-patterns.d.ts +0 -43
  102. package/dist/coordination/execution-patterns.js +0 -507
  103. package/dist/coordination/factory.d.ts +0 -94
  104. package/dist/coordination/factory.js +0 -433
  105. package/dist/coordination/index.d.ts +0 -71
  106. package/dist/coordination/index.js +0 -135
  107. package/dist/coordination/progress-monitor.d.ts +0 -71
  108. package/dist/coordination/progress-monitor.js +0 -505
  109. package/dist/coordination/quality-gates.d.ts +0 -124
  110. package/dist/coordination/quality-gates.js +0 -577
  111. package/dist/coordination/shared-memory.d.ts +0 -39
  112. package/dist/coordination/shared-memory.js +0 -289
  113. package/dist/coordination/task-dependencies.d.ts +0 -50
  114. package/dist/coordination/task-dependencies.js +0 -407
  115. package/dist/coordination/team-coordinator.d.ts +0 -59
  116. package/dist/coordination/team-coordinator.js +0 -550
  117. package/dist/coordination/types.d.ts +0 -152
  118. package/dist/coordination/types.js +0 -3
  119. package/dist/mcp/mcp-wrapper.d.ts +0 -8
  120. package/dist/mcp/mcp-wrapper.js +0 -77
  121. package/dist/mcp/servicenow-flow-composer-enhanced.js +0 -396
  122. package/dist/mcp/servicenow-flow-composer-mcp.d.ts +0 -7
  123. package/dist/mcp/servicenow-flow-composer-mcp.js +0 -3103
  124. package/dist/mcp/servicenow-graph-memory-mcp.d.ts +0 -7
  125. package/dist/mcp/servicenow-intelligent-mcp.d.ts +0 -143
  126. package/dist/mcp/servicenow-intelligent-mcp.js +0 -4156
  127. package/dist/mcp/servicenow-xml-flow-mcp.d.ts +0 -53
  128. package/dist/mcp/servicenow-xml-flow-mcp.js +0 -1704
  129. package/dist/mcp/singleton-check.js +0 -31
  130. package/dist/mcp/test-simple-mcp.d.ts +0 -6
  131. package/dist/mcp/test-simple-mcp.js +0 -63
  132. package/dist/memory/hierarchical-memory-system.d.ts +0 -90
  133. package/dist/memory/hierarchical-memory-system.js +0 -400
  134. package/dist/memory/index.d.ts +0 -9
  135. package/dist/memory/index.js +0 -20
  136. package/dist/memory/mcp-integration-example.d.ts +0 -6
  137. package/dist/memory/mcp-integration-example.js +0 -281
  138. package/dist/memory/memory-client.d.ts +0 -199
  139. package/dist/memory/memory-client.js +0 -364
  140. package/dist/memory/memory-manager.d.ts +0 -29
  141. package/dist/memory/memory-manager.js +0 -280
  142. package/dist/memory/memory-operations.d.ts +0 -179
  143. package/dist/memory/memory-operations.js +0 -691
  144. package/dist/memory/memory-system.d.ts +0 -153
  145. package/dist/memory/memory-system.js +0 -651
  146. package/dist/memory/memory-test.d.ts +0 -6
  147. package/dist/memory/memory-test.js +0 -161
  148. package/dist/memory/snow-flow-memory-patterns.d.ts +0 -213
  149. package/dist/memory/snow-flow-memory-patterns.js +0 -200
  150. package/dist/memory/snow-memory.d.ts +0 -54
  151. package/dist/memory/snow-memory.js +0 -301
  152. package/dist/memory/swarm-memory.d.ts +0 -135
  153. package/dist/memory/swarm-memory.js +0 -378
  154. package/dist/optimization/flow-performance-optimizer.js +0 -723
  155. package/dist/orchestration/discovery/service-discovery.d.ts +0 -81
  156. package/dist/orchestration/discovery/service-discovery.js +0 -808
  157. package/dist/orchestration/distributed-orchestrator.d.ts +0 -131
  158. package/dist/orchestration/distributed-orchestrator.js +0 -712
  159. package/dist/orchestration/distribution/task-distribution-engine.d.ts +0 -53
  160. package/dist/orchestration/distribution/task-distribution-engine.js +0 -586
  161. package/dist/orchestration/flow-update-orchestrator.js +0 -648
  162. package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +0 -606
  163. package/dist/orchestration/interfaces/distributed-orchestration.interface.js +0 -65
  164. package/dist/orchestration/protocols/mcpx-protocol.d.ts +0 -71
  165. package/dist/orchestration/protocols/mcpx-protocol.js +0 -668
  166. package/dist/orchestration/state/distributed-state-manager.d.ts +0 -89
  167. package/dist/orchestration/state/distributed-state-manager.js +0 -716
  168. package/dist/orchestrator/flow-composer.d.ts +0 -105
  169. package/dist/orchestrator/flow-composer.js +0 -404
  170. package/dist/orchestrator/flow-pattern-templates.d.ts +0 -260
  171. package/dist/orchestrator/flow-pattern-templates.js +0 -908
  172. package/dist/orchestrator/flow-subflow-decision-engine.d.ts +0 -202
  173. package/dist/orchestrator/flow-subflow-decision-engine.js +0 -769
  174. package/dist/orchestrator/flow-validation-engine.d.ts +0 -169
  175. package/dist/orchestrator/flow-validation-engine.js +0 -913
  176. package/dist/orchestrator/snow-orchestrator.d.ts +0 -49
  177. package/dist/orchestrator/snow-orchestrator.js +0 -235
  178. package/dist/orchestrator/subflow-creation-handler.d.ts +0 -230
  179. package/dist/orchestrator/subflow-creation-handler.js +0 -791
  180. package/dist/patterns/adaptive-patterns.d.ts +0 -140
  181. package/dist/patterns/adaptive-patterns.js +0 -549
  182. package/dist/queen/advanced-integration-test.d.ts +0 -48
  183. package/dist/queen/advanced-integration-test.js +0 -473
  184. package/dist/queen/integration-example.d.ts +0 -82
  185. package/dist/queen/integration-example.js +0 -219
  186. package/dist/queen/integration-test.d.ts +0 -72
  187. package/dist/queen/integration-test.js +0 -563
  188. package/dist/queen/mock-mcp-client.d.ts +0 -71
  189. package/dist/queen/mock-mcp-client.js +0 -317
  190. package/dist/queen/run-integration-tests.d.ts +0 -9
  191. package/dist/queen/run-integration-tests.js +0 -27
  192. package/dist/sparc/coordinators/adaptive-coordinator.d.ts +0 -54
  193. package/dist/sparc/coordinators/adaptive-coordinator.js +0 -367
  194. package/dist/sparc/coordinators/team-coordinator.d.ts +0 -66
  195. package/dist/sparc/coordinators/team-coordinator.js +0 -402
  196. package/dist/sparc/modes/team-modes.d.ts +0 -33
  197. package/dist/sparc/modes/team-modes.js +0 -399
  198. package/dist/sparc/teams/application-team.d.ts +0 -73
  199. package/dist/sparc/teams/application-team.js +0 -463
  200. package/dist/sparc/teams/flow-team.d.ts +0 -67
  201. package/dist/sparc/teams/flow-team.js +0 -373
  202. package/dist/sparc/teams/widget-team.d.ts +0 -61
  203. package/dist/sparc/teams/widget-team.js +0 -280
  204. package/dist/specialists/app-specialists.d.ts +0 -93
  205. package/dist/specialists/app-specialists.js +0 -1639
  206. package/dist/specialists/base-specialist.d.ts +0 -19
  207. package/dist/specialists/base-specialist.js +0 -54
  208. package/dist/specialists/flow-specialists.d.ts +0 -113
  209. package/dist/specialists/flow-specialists.js +0 -1787
  210. package/dist/specialists/individual-specialists.d.ts +0 -67
  211. package/dist/specialists/individual-specialists.js +0 -632
  212. package/dist/specialists/widget-specialists.d.ts +0 -70
  213. package/dist/specialists/widget-specialists.js +0 -1264
  214. package/dist/src/utils/agent-detector.js +0 -655
  215. package/dist/teams/adaptive-team.d.ts +0 -81
  216. package/dist/teams/adaptive-team.js +0 -1153
  217. package/dist/teams/application-team.d.ts +0 -30
  218. package/dist/teams/application-team.js +0 -547
  219. package/dist/teams/base-team.d.ts +0 -55
  220. package/dist/teams/base-team.js +0 -243
  221. package/dist/teams/flow-team.d.ts +0 -28
  222. package/dist/teams/flow-team.js +0 -525
  223. package/dist/teams/widget-team.d.ts +0 -26
  224. package/dist/teams/widget-team.js +0 -459
  225. package/dist/templates/flow-template-system.js +0 -625
  226. package/dist/test-fetch-incidents.d.ts +0 -2
  227. package/dist/test-fetch-incidents.js +0 -84
  228. package/dist/test-incident-access.d.ts +0 -2
  229. package/dist/test-incident-access.js +0 -72
  230. package/dist/test-iphone-flow.js +0 -189
  231. package/dist/test-limit-problem.d.ts +0 -2
  232. package/dist/test-limit-problem.js +0 -60
  233. package/dist/test-ml-batch-fix.d.ts +0 -2
  234. package/dist/test-ml-batch-fix.js +0 -104
  235. package/dist/test-ml-batch.d.ts +0 -2
  236. package/dist/test-ml-batch.js +0 -87
  237. package/dist/test-ml-query.d.ts +0 -2
  238. package/dist/test-ml-query.js +0 -100
  239. package/dist/test-ml-training-fix.d.ts +0 -12
  240. package/dist/test-ml-training-fix.js +0 -113
  241. package/dist/test-ml-training.d.ts +0 -2
  242. package/dist/test-ml-training.js +0 -32
  243. package/dist/test-operations-query.d.ts +0 -2
  244. package/dist/test-operations-query.js +0 -84
  245. package/dist/test-performance-query.d.ts +0 -2
  246. package/dist/test-performance-query.js +0 -52
  247. package/dist/test-singleton-protection.d.ts +0 -8
  248. package/dist/test-singleton-protection.js +0 -110
  249. package/dist/test-smart-limits.d.ts +0 -13
  250. package/dist/test-smart-limits.js +0 -100
  251. package/dist/test-snow-query-incidents.d.ts +0 -2
  252. package/dist/test-snow-query-incidents.js +0 -66
  253. package/dist/test-universal-query.d.ts +0 -2
  254. package/dist/test-universal-query.js +0 -106
  255. package/dist/testing/flow-testing-automation.js +0 -641
  256. package/dist/utils/complete-flow-xml-generator.js +0 -1285
  257. package/dist/utils/file-storage-fallback.d.ts +0 -62
  258. package/dist/utils/file-storage-fallback.js +0 -289
  259. package/dist/utils/flow-api-discovery.d.ts +0 -151
  260. package/dist/utils/flow-api-discovery.js +0 -439
  261. package/dist/utils/flow-examples.js +0 -720
  262. package/dist/utils/flow-structure-builder.js +0 -677
  263. package/dist/utils/flow-xml-generator.d.ts +0 -41
  264. package/dist/utils/flow-xml-generator.js +0 -258
  265. package/dist/utils/improved-flow-xml-generator.js +0 -820
  266. package/dist/utils/mcp-process-manager.backup.d.ts +0 -58
  267. package/dist/utils/mcp-process-manager.backup.js +0 -220
  268. package/dist/utils/mcp-singleton-enforcer.d.ts +0 -36
  269. package/dist/utils/mcp-singleton-enforcer.js +0 -201
  270. package/dist/utils/mcp-timeout-fix.d.ts +0 -53
  271. package/dist/utils/mcp-timeout-fix.js +0 -221
  272. package/dist/utils/migrate-claude-flow.d.ts +0 -22
  273. package/dist/utils/migrate-claude-flow.js +0 -120
  274. package/dist/utils/scope-utils.d.ts +0 -72
  275. package/dist/utils/scope-utils.js +0 -386
  276. package/dist/utils/snow-oauth-old.d.ts +0 -65
  277. package/dist/utils/snow-oauth-old.js +0 -345
  278. package/dist/utils/xml-first-flow-generator.js +0 -513
  279. package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +0 -30
  280. package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +0 -36
  281. package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +0 -30
  282. package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +0 -30
  283. package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +0 -55
  284. package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +0 -55
  285. package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +0 -9
  286. package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +0 -9
  287. package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +0 -8
  288. package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +0 -9
  289. package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +0 -9
  290. package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +0 -9
  291. package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +0 -58
  292. package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +0 -9
  293. package/reports/swarm-auto-centralized-1752649029776.json +0 -13
  294. package/src/memory/README.md +0 -240
@@ -1,1639 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PerformanceSpecialist = exports.InterfaceSpecialist = exports.BusinessLogicSpecialist = exports.DatabaseSpecialist = void 0;
4
- const base_specialist_js_1 = require("./base-specialist.js");
5
- class DatabaseSpecialist extends base_specialist_js_1.BaseSpecialist {
6
- constructor(options = {}) {
7
- super('Database Designer', 'Database Designer', ['Table Design', 'Relationships', 'Indexing', 'Performance', 'Data Modeling'], options);
8
- }
9
- async execute(task, context) {
10
- await this.logProgress(`Analyzing database requirements for: ${task}`);
11
- const analysis = await this.analyzeTask(task);
12
- const dbRequirements = {
13
- tables: this.identifyTables(task),
14
- relationships: this.analyzeRelationships(task),
15
- fields: this.identifyFields(task),
16
- indexes: this.analyzeIndexingNeeds(task),
17
- constraints: this.identifyConstraints(task),
18
- performance: this.analyzePerformanceRequirements(task)
19
- };
20
- await this.logProgress('Designing database schema');
21
- const schema = await this.createDatabaseSchema(dbRequirements);
22
- await this.logProgress('Creating table definitions and relationships');
23
- const tableDefinitions = await this.createTableDefinitions(dbRequirements);
24
- return {
25
- ...analysis,
26
- specialist: 'Database Designer',
27
- deliverables: {
28
- schema,
29
- tableDefinitions,
30
- requirements: dbRequirements
31
- }
32
- };
33
- }
34
- identifyTables(task) {
35
- const tables = [];
36
- const lowerTask = task.toLowerCase();
37
- if (lowerTask.includes('itsm') || lowerTask.includes('service management')) {
38
- tables.push({ name: 'custom_incident', label: 'Custom Incident', extends: 'incident' }, { name: 'custom_request', label: 'Custom Request', extends: 'sc_request' }, { name: 'custom_change', label: 'Custom Change', extends: 'change_request' });
39
- }
40
- if (lowerTask.includes('asset') || lowerTask.includes('inventory')) {
41
- tables.push({ name: 'custom_asset', label: 'Custom Asset', extends: 'alm_asset' }, { name: 'asset_location', label: 'Asset Location', extends: 'cmn_location' });
42
- }
43
- if (lowerTask.includes('hr') || lowerTask.includes('employee')) {
44
- tables.push({ name: 'employee_profile', label: 'Employee Profile', extends: 'sys_user' }, { name: 'employee_skill', label: 'Employee Skills', extends: '' }, { name: 'skill_category', label: 'Skill Categories', extends: '' });
45
- }
46
- if (lowerTask.includes('project') || lowerTask.includes('task')) {
47
- tables.push({ name: 'project', label: 'Projects', extends: '' }, { name: 'project_task', label: 'Project Tasks', extends: 'task' }, { name: 'project_milestone', label: 'Project Milestones', extends: '' });
48
- }
49
- if (lowerTask.includes('financial') || lowerTask.includes('budget')) {
50
- tables.push({ name: 'budget_item', label: 'Budget Items', extends: '' }, { name: 'expense_record', label: 'Expense Records', extends: '' }, { name: 'cost_center', label: 'Cost Centers', extends: '' });
51
- }
52
- // If no specific domain identified, create generic tables
53
- if (tables.length === 0) {
54
- tables.push({ name: 'custom_record', label: 'Custom Records', extends: '' }, { name: 'custom_category', label: 'Custom Categories', extends: '' });
55
- }
56
- return tables;
57
- }
58
- analyzeRelationships(task) {
59
- const relationships = [];
60
- const lowerTask = task.toLowerCase();
61
- if (lowerTask.includes('itsm')) {
62
- relationships.push({
63
- from: 'custom_incident',
64
- to: 'sys_user',
65
- type: 'many_to_one',
66
- field: 'assigned_to',
67
- description: 'Incident assignment relationship'
68
- }, {
69
- from: 'custom_request',
70
- to: 'sys_user',
71
- type: 'many_to_one',
72
- field: 'requested_for',
73
- description: 'Request requester relationship'
74
- });
75
- }
76
- if (lowerTask.includes('asset')) {
77
- relationships.push({
78
- from: 'custom_asset',
79
- to: 'asset_location',
80
- type: 'many_to_one',
81
- field: 'location',
82
- description: 'Asset location relationship'
83
- }, {
84
- from: 'custom_asset',
85
- to: 'sys_user',
86
- type: 'many_to_one',
87
- field: 'assigned_to',
88
- description: 'Asset ownership relationship'
89
- });
90
- }
91
- if (lowerTask.includes('project')) {
92
- relationships.push({
93
- from: 'project_task',
94
- to: 'project',
95
- type: 'many_to_one',
96
- field: 'project',
97
- description: 'Task to project relationship'
98
- }, {
99
- from: 'project_milestone',
100
- to: 'project',
101
- type: 'many_to_one',
102
- field: 'project',
103
- description: 'Milestone to project relationship'
104
- });
105
- }
106
- return relationships;
107
- }
108
- identifyFields(task) {
109
- const lowerTask = task.toLowerCase();
110
- const commonFields = {
111
- core: [
112
- { name: 'sys_id', type: 'GUID', label: 'Sys ID', mandatory: true },
113
- { name: 'sys_created_on', type: 'glide_date_time', label: 'Created', mandatory: true },
114
- { name: 'sys_created_by', type: 'reference', label: 'Created by', mandatory: true },
115
- { name: 'sys_updated_on', type: 'glide_date_time', label: 'Updated', mandatory: true },
116
- { name: 'sys_updated_by', type: 'reference', label: 'Updated by', mandatory: true }
117
- ],
118
- standard: [
119
- { name: 'number', type: 'string', label: 'Number', mandatory: true },
120
- { name: 'short_description', type: 'string', label: 'Short description', mandatory: true },
121
- { name: 'description', type: 'html', label: 'Description', mandatory: false },
122
- { name: 'state', type: 'integer', label: 'State', mandatory: true },
123
- { name: 'priority', type: 'integer', label: 'Priority', mandatory: false }
124
- ]
125
- };
126
- const domainSpecificFields = {};
127
- if (lowerTask.includes('itsm')) {
128
- domainSpecificFields.itsm = [
129
- { name: 'impact', type: 'integer', label: 'Impact', mandatory: false },
130
- { name: 'urgency', type: 'integer', label: 'Urgency', mandatory: false },
131
- { name: 'assignment_group', type: 'reference', label: 'Assignment group', mandatory: false },
132
- { name: 'assigned_to', type: 'reference', label: 'Assigned to', mandatory: false },
133
- { name: 'category', type: 'string', label: 'Category', mandatory: false }
134
- ];
135
- }
136
- if (lowerTask.includes('asset')) {
137
- domainSpecificFields.asset = [
138
- { name: 'asset_tag', type: 'string', label: 'Asset tag', mandatory: true },
139
- { name: 'serial_number', type: 'string', label: 'Serial number', mandatory: false },
140
- { name: 'model', type: 'reference', label: 'Model', mandatory: false },
141
- { name: 'location', type: 'reference', label: 'Location', mandatory: false },
142
- { name: 'cost', type: 'currency', label: 'Cost', mandatory: false }
143
- ];
144
- }
145
- if (lowerTask.includes('project')) {
146
- domainSpecificFields.project = [
147
- { name: 'start_date', type: 'glide_date', label: 'Start date', mandatory: false },
148
- { name: 'end_date', type: 'glide_date', label: 'End date', mandatory: false },
149
- { name: 'percent_complete', type: 'integer', label: 'Percent complete', mandatory: false },
150
- { name: 'project_manager', type: 'reference', label: 'Project manager', mandatory: false },
151
- { name: 'budget', type: 'currency', label: 'Budget', mandatory: false }
152
- ];
153
- }
154
- return { commonFields, domainSpecificFields };
155
- }
156
- analyzeIndexingNeeds(task) {
157
- const indexes = [];
158
- // Common indexes for all tables
159
- indexes.push({ fields: ['sys_created_on'], type: 'btree', purpose: 'creation_date_queries' }, { fields: ['sys_updated_on'], type: 'btree', purpose: 'modification_date_queries' }, { fields: ['number'], type: 'unique', purpose: 'number_lookup' });
160
- const lowerTask = task.toLowerCase();
161
- if (lowerTask.includes('itsm')) {
162
- indexes.push({ fields: ['state'], type: 'hash', purpose: 'state_filtering' }, { fields: ['priority'], type: 'btree', purpose: 'priority_sorting' }, { fields: ['assigned_to'], type: 'btree', purpose: 'assignment_queries' }, { fields: ['assignment_group'], type: 'btree', purpose: 'group_assignment_queries' });
163
- }
164
- if (lowerTask.includes('asset')) {
165
- indexes.push({ fields: ['asset_tag'], type: 'unique', purpose: 'asset_tag_lookup' }, { fields: ['serial_number'], type: 'btree', purpose: 'serial_number_search' }, { fields: ['location'], type: 'btree', purpose: 'location_queries' });
166
- }
167
- if (lowerTask.includes('project')) {
168
- indexes.push({ fields: ['start_date'], type: 'btree', purpose: 'date_range_queries' }, { fields: ['end_date'], type: 'btree', purpose: 'deadline_queries' }, { fields: ['project_manager'], type: 'btree', purpose: 'manager_queries' });
169
- }
170
- return indexes;
171
- }
172
- identifyConstraints(task) {
173
- const constraints = [];
174
- // Common constraints
175
- constraints.push({ type: 'not_null', field: 'number', description: 'Number field cannot be null' }, { type: 'not_null', field: 'short_description', description: 'Short description is required' }, { type: 'unique', field: 'number', description: 'Number must be unique' });
176
- const lowerTask = task.toLowerCase();
177
- if (lowerTask.includes('asset')) {
178
- constraints.push({ type: 'unique', field: 'asset_tag', description: 'Asset tag must be unique' }, { type: 'check', field: 'cost', condition: 'cost >= 0', description: 'Cost cannot be negative' });
179
- }
180
- if (lowerTask.includes('project')) {
181
- constraints.push({ type: 'check', field: 'percent_complete', condition: 'percent_complete BETWEEN 0 AND 100', description: 'Percent complete must be between 0 and 100' }, { type: 'check', field: 'dates', condition: 'end_date >= start_date', description: 'End date must be after start date' });
182
- }
183
- return constraints;
184
- }
185
- analyzePerformanceRequirements(task) {
186
- const lowerTask = task.toLowerCase();
187
- return {
188
- expectedVolume: this.estimateDataVolume(task),
189
- queryPatterns: this.identifyQueryPatterns(task),
190
- performanceTargets: {
191
- insertTime: lowerTask.includes('high volume') ? '< 100ms' : '< 50ms',
192
- queryTime: '< 200ms',
193
- updateTime: '< 150ms'
194
- },
195
- partitioning: lowerTask.includes('large') || lowerTask.includes('enterprise'),
196
- archiving: lowerTask.includes('historical') || lowerTask.includes('audit')
197
- };
198
- }
199
- estimateDataVolume(task) {
200
- const lowerTask = task.toLowerCase();
201
- if (lowerTask.includes('enterprise') || lowerTask.includes('large')) {
202
- return 'high'; // 1M+ records
203
- }
204
- else if (lowerTask.includes('medium') || lowerTask.includes('department')) {
205
- return 'medium'; // 100K-1M records
206
- }
207
- return 'low'; // < 100K records
208
- }
209
- identifyQueryPatterns(task) {
210
- const patterns = ['single_record_lookup', 'list_views'];
211
- const lowerTask = task.toLowerCase();
212
- if (lowerTask.includes('report') || lowerTask.includes('analytics')) {
213
- patterns.push('aggregation_queries', 'complex_joins');
214
- }
215
- if (lowerTask.includes('dashboard')) {
216
- patterns.push('real_time_queries', 'count_queries');
217
- }
218
- if (lowerTask.includes('search')) {
219
- patterns.push('full_text_search', 'fuzzy_matching');
220
- }
221
- return patterns;
222
- }
223
- async createDatabaseSchema(requirements) {
224
- const schema = {
225
- tables: requirements.tables,
226
- relationships: requirements.relationships,
227
- indexes: requirements.indexes,
228
- constraints: requirements.constraints,
229
- performance: requirements.performance,
230
- metadata: {
231
- version: '1.0',
232
- created: new Date(),
233
- description: 'Auto-generated database schema'
234
- }
235
- };
236
- return schema;
237
- }
238
- async createTableDefinitions(requirements) {
239
- const definitions = [];
240
- for (const table of requirements.tables) {
241
- const definition = {
242
- name: table.name,
243
- label: table.label,
244
- extends: table.extends,
245
- fields: this.generateFieldDefinitions(table, requirements.fields),
246
- indexes: this.generateTableIndexes(table, requirements.indexes),
247
- constraints: this.generateTableConstraints(table, requirements.constraints),
248
- permissions: this.generateTablePermissions(table),
249
- businessRules: this.generateBusinessRules(table)
250
- };
251
- definitions.push(definition);
252
- }
253
- return definitions;
254
- }
255
- generateFieldDefinitions(table, fieldsConfig) {
256
- const fields = [...fieldsConfig.commonFields.core, ...fieldsConfig.commonFields.standard];
257
- // Add domain-specific fields based on table type
258
- if (table.name.includes('incident') || table.name.includes('request')) {
259
- fields.push(...(fieldsConfig.domainSpecificFields.itsm || []));
260
- }
261
- else if (table.name.includes('asset')) {
262
- fields.push(...(fieldsConfig.domainSpecificFields.asset || []));
263
- }
264
- else if (table.name.includes('project')) {
265
- fields.push(...(fieldsConfig.domainSpecificFields.project || []));
266
- }
267
- return fields;
268
- }
269
- generateTableIndexes(table, indexes) {
270
- return indexes.filter(index =>
271
- // Include common indexes and table-specific ones
272
- index.purpose.includes('common') ||
273
- index.purpose.includes(table.name) ||
274
- (table.name.includes('incident') && index.purpose.includes('itsm')) ||
275
- (table.name.includes('asset') && index.purpose.includes('asset')));
276
- }
277
- generateTableConstraints(table, constraints) {
278
- return constraints.filter(constraint =>
279
- // Include constraints relevant to this table
280
- !constraint.tableSpecific || constraint.tableSpecific.includes(table.name));
281
- }
282
- generateTablePermissions(table) {
283
- return {
284
- read: ['user', 'admin'],
285
- write: ['admin'],
286
- create: ['admin'],
287
- delete: ['admin'],
288
- acl_rules: [
289
- {
290
- name: `${table.name}_read`,
291
- type: 'read',
292
- roles: 'user',
293
- condition: ''
294
- },
295
- {
296
- name: `${table.name}_write`,
297
- type: 'write',
298
- roles: 'admin',
299
- condition: ''
300
- }
301
- ]
302
- };
303
- }
304
- generateBusinessRules(table) {
305
- return [
306
- {
307
- name: `${table.name}_auto_number`,
308
- when: 'before',
309
- insert: true,
310
- script: `if (current.number.nil()) { current.number = new NumberManager('${table.name}').getNextObjNumber(); }`
311
- },
312
- {
313
- name: `${table.name}_audit_log`,
314
- when: 'after',
315
- insert: true,
316
- update: true,
317
- script: `gs.log('${table.name} record modified: ' + current.number);`
318
- }
319
- ];
320
- }
321
- }
322
- exports.DatabaseSpecialist = DatabaseSpecialist;
323
- class BusinessLogicSpecialist extends base_specialist_js_1.BaseSpecialist {
324
- constructor(options = {}) {
325
- super('Business Logic Developer', 'Business Logic Developer', ['Business Rules', 'Script Includes', 'Workflows', 'Calculations', 'Validations'], options);
326
- }
327
- async execute(task, context) {
328
- await this.logProgress(`Analyzing business logic requirements for: ${task}`);
329
- const analysis = await this.analyzeTask(task);
330
- const logicRequirements = {
331
- businessRules: this.identifyBusinessRules(task),
332
- scriptIncludes: this.identifyScriptIncludes(task),
333
- calculations: this.identifyCalculations(task),
334
- validations: this.identifyValidations(task),
335
- workflows: this.identifyWorkflows(task),
336
- automations: this.identifyAutomations(task)
337
- };
338
- await this.logProgress('Designing business logic architecture');
339
- const logicArchitecture = await this.createLogicArchitecture(logicRequirements);
340
- await this.logProgress('Creating business logic implementations');
341
- const implementations = await this.createImplementations(logicRequirements);
342
- return {
343
- ...analysis,
344
- specialist: 'Business Logic Developer',
345
- deliverables: {
346
- logicArchitecture,
347
- implementations,
348
- requirements: logicRequirements
349
- }
350
- };
351
- }
352
- identifyBusinessRules(task) {
353
- const rules = [];
354
- const lowerTask = task.toLowerCase();
355
- // Auto-numbering rules
356
- rules.push({
357
- name: 'Auto Number Generation',
358
- type: 'before_insert',
359
- description: 'Automatically generate unique numbers for new records',
360
- priority: 100,
361
- table: 'auto_detect'
362
- });
363
- if (lowerTask.includes('itsm')) {
364
- rules.push({
365
- name: 'Priority Calculation',
366
- type: 'before_insert_update',
367
- description: 'Calculate priority based on impact and urgency',
368
- priority: 200,
369
- table: 'incident'
370
- }, {
371
- name: 'Assignment Group Population',
372
- type: 'before_insert_update',
373
- description: 'Auto-populate assignment group based on category',
374
- priority: 300,
375
- table: 'incident'
376
- }, {
377
- name: 'SLA Start Trigger',
378
- type: 'after_insert',
379
- description: 'Start SLA timers when incident is created',
380
- priority: 400,
381
- table: 'incident'
382
- });
383
- }
384
- if (lowerTask.includes('asset')) {
385
- rules.push({
386
- name: 'Asset Tag Validation',
387
- type: 'before_insert_update',
388
- description: 'Validate asset tag format and uniqueness',
389
- priority: 200,
390
- table: 'asset'
391
- }, {
392
- name: 'Depreciation Calculation',
393
- type: 'before_update',
394
- description: 'Calculate asset depreciation on cost changes',
395
- priority: 300,
396
- table: 'asset'
397
- });
398
- }
399
- if (lowerTask.includes('approval')) {
400
- rules.push({
401
- name: 'Approval Chain Trigger',
402
- type: 'after_insert_update',
403
- description: 'Trigger approval workflow based on request value',
404
- priority: 500,
405
- table: 'request'
406
- });
407
- }
408
- return rules;
409
- }
410
- identifyScriptIncludes(task) {
411
- const scriptIncludes = [];
412
- const lowerTask = task.toLowerCase();
413
- // Common utility script includes
414
- scriptIncludes.push({
415
- name: 'ApplicationUtils',
416
- description: 'Common utility functions for the application',
417
- clientCallable: false,
418
- functions: ['validateData', 'formatNumber', 'calculateDate']
419
- });
420
- if (lowerTask.includes('itsm')) {
421
- scriptIncludes.push({
422
- name: 'IncidentUtils',
423
- description: 'Utility functions for incident management',
424
- clientCallable: true,
425
- functions: ['calculatePriority', 'getAssignmentGroup', 'checkSLA']
426
- }, {
427
- name: 'ITSMIntegration',
428
- description: 'Integration functions for ITSM processes',
429
- clientCallable: false,
430
- functions: ['syncWithCMDB', 'updateAssetStatus', 'createChangeRequest']
431
- });
432
- }
433
- if (lowerTask.includes('asset')) {
434
- scriptIncludes.push({
435
- name: 'AssetManager',
436
- description: 'Asset management utility functions',
437
- clientCallable: true,
438
- functions: ['calculateDepreciation', 'validateAssetTag', 'getAssetHistory']
439
- });
440
- }
441
- if (lowerTask.includes('notification') || lowerTask.includes('email')) {
442
- scriptIncludes.push({
443
- name: 'NotificationUtils',
444
- description: 'Notification and communication utilities',
445
- clientCallable: false,
446
- functions: ['sendEmail', 'formatNotification', 'getRecipients']
447
- });
448
- }
449
- return scriptIncludes;
450
- }
451
- identifyCalculations(task) {
452
- const calculations = [];
453
- const lowerTask = task.toLowerCase();
454
- if (lowerTask.includes('itsm')) {
455
- calculations.push({
456
- name: 'Priority Calculation',
457
- description: 'Calculate priority from impact and urgency',
458
- formula: 'priority = Math.max(impact, urgency)',
459
- triggers: ['impact_change', 'urgency_change']
460
- }, {
461
- name: 'SLA Duration',
462
- description: 'Calculate SLA duration based on priority',
463
- formula: 'sla_duration = priority_mapping[priority]',
464
- triggers: ['priority_change', 'sla_start']
465
- });
466
- }
467
- if (lowerTask.includes('asset')) {
468
- calculations.push({
469
- name: 'Depreciation Value',
470
- description: 'Calculate current asset value with depreciation',
471
- formula: 'current_value = cost - (cost * depreciation_rate * years)',
472
- triggers: ['cost_change', 'date_change']
473
- }, {
474
- name: 'Total Cost of Ownership',
475
- description: 'Calculate TCO including maintenance and operational costs',
476
- formula: 'tco = purchase_cost + maintenance_cost + operational_cost',
477
- triggers: ['cost_updates']
478
- });
479
- }
480
- if (lowerTask.includes('project')) {
481
- calculations.push({
482
- name: 'Project Progress',
483
- description: 'Calculate project completion percentage',
484
- formula: 'progress = completed_tasks / total_tasks * 100',
485
- triggers: ['task_completion', 'task_creation']
486
- }, {
487
- name: 'Budget Utilization',
488
- description: 'Calculate budget utilization percentage',
489
- formula: 'utilization = spent_amount / total_budget * 100',
490
- triggers: ['expense_recording']
491
- });
492
- }
493
- return calculations;
494
- }
495
- identifyValidations(task) {
496
- const validations = [];
497
- const lowerTask = task.toLowerCase();
498
- // Common validations
499
- validations.push({
500
- name: 'Required Fields',
501
- description: 'Validate that required fields are not empty',
502
- type: 'client_server',
503
- severity: 'error'
504
- }, {
505
- name: 'Field Format',
506
- description: 'Validate field formats (email, phone, etc.)',
507
- type: 'client',
508
- severity: 'error'
509
- });
510
- if (lowerTask.includes('asset')) {
511
- validations.push({
512
- name: 'Asset Tag Format',
513
- description: 'Validate asset tag follows organization format',
514
- type: 'server',
515
- severity: 'error',
516
- pattern: '^[A-Z]{2}[0-9]{6}$'
517
- }, {
518
- name: 'Serial Number Uniqueness',
519
- description: 'Ensure serial numbers are unique across assets',
520
- type: 'server',
521
- severity: 'error'
522
- });
523
- }
524
- if (lowerTask.includes('financial') || lowerTask.includes('budget')) {
525
- validations.push({
526
- name: 'Positive Amount',
527
- description: 'Ensure monetary amounts are positive',
528
- type: 'client_server',
529
- severity: 'error'
530
- }, {
531
- name: 'Budget Limits',
532
- description: 'Validate expenses do not exceed budget limits',
533
- type: 'server',
534
- severity: 'warning'
535
- });
536
- }
537
- return validations;
538
- }
539
- identifyWorkflows(task) {
540
- const workflows = [];
541
- const lowerTask = task.toLowerCase();
542
- if (lowerTask.includes('approval')) {
543
- workflows.push({
544
- name: 'Approval Process',
545
- description: 'Multi-stage approval workflow',
546
- trigger: 'record_insert_update',
547
- stages: ['manager_approval', 'finance_approval', 'final_approval']
548
- });
549
- }
550
- if (lowerTask.includes('itsm')) {
551
- workflows.push({
552
- name: 'Incident Resolution',
553
- description: 'Incident lifecycle management workflow',
554
- trigger: 'state_change',
555
- stages: ['assignment', 'investigation', 'resolution', 'closure']
556
- }, {
557
- name: 'Change Management',
558
- description: 'Change request approval and implementation',
559
- trigger: 'change_request_creation',
560
- stages: ['assessment', 'approval', 'implementation', 'review']
561
- });
562
- }
563
- if (lowerTask.includes('asset')) {
564
- workflows.push({
565
- name: 'Asset Lifecycle',
566
- description: 'Asset procurement to disposal workflow',
567
- trigger: 'asset_state_change',
568
- stages: ['procurement', 'deployment', 'maintenance', 'disposal']
569
- });
570
- }
571
- return workflows;
572
- }
573
- identifyAutomations(task) {
574
- const automations = [];
575
- const lowerTask = task.toLowerCase();
576
- if (lowerTask.includes('notification') || lowerTask.includes('email')) {
577
- automations.push({
578
- name: 'Automatic Notifications',
579
- description: 'Send notifications on record state changes',
580
- trigger: 'state_change',
581
- actions: ['send_email', 'update_stakeholders']
582
- });
583
- }
584
- if (lowerTask.includes('escalation')) {
585
- automations.push({
586
- name: 'SLA Escalation',
587
- description: 'Automatic escalation on SLA breach',
588
- trigger: 'sla_breach',
589
- actions: ['escalate_to_manager', 'send_alert', 'increase_priority']
590
- });
591
- }
592
- if (lowerTask.includes('integration')) {
593
- automations.push({
594
- name: 'External System Sync',
595
- description: 'Synchronize data with external systems',
596
- trigger: 'record_update',
597
- actions: ['api_call', 'data_transform', 'update_external']
598
- });
599
- }
600
- return automations;
601
- }
602
- async createLogicArchitecture(requirements) {
603
- return {
604
- layers: {
605
- presentation: 'UI policies and client scripts',
606
- business: 'Business rules and script includes',
607
- data: 'Database constraints and triggers',
608
- integration: 'REST APIs and web services'
609
- },
610
- patterns: {
611
- validation: 'Client-side and server-side validation',
612
- calculation: 'Real-time and batch calculations',
613
- workflow: 'State-based workflow automation',
614
- notification: 'Event-driven notifications'
615
- },
616
- components: {
617
- businessRules: requirements.businessRules.length,
618
- scriptIncludes: requirements.scriptIncludes.length,
619
- workflows: requirements.workflows.length,
620
- validations: requirements.validations.length
621
- },
622
- performance: {
623
- caching: 'Script include function caching',
624
- optimization: 'Query optimization in business rules',
625
- batching: 'Batch processing for bulk operations'
626
- }
627
- };
628
- }
629
- async createImplementations(requirements) {
630
- return {
631
- businessRules: await this.generateBusinessRulesCode(requirements.businessRules),
632
- scriptIncludes: await this.generateScriptIncludesCode(requirements.scriptIncludes),
633
- validations: await this.generateValidationCode(requirements.validations),
634
- calculations: await this.generateCalculationCode(requirements.calculations),
635
- workflows: await this.generateWorkflowDefinitions(requirements.workflows)
636
- };
637
- }
638
- async generateBusinessRulesCode(rules) {
639
- return rules.map(rule => ({
640
- name: rule.name,
641
- when: this.getWhenCondition(rule.type),
642
- condition: this.generateRuleCondition(rule),
643
- script: this.generateRuleScript(rule)
644
- }));
645
- }
646
- getWhenCondition(type) {
647
- if (type.includes('before'))
648
- return 'before';
649
- if (type.includes('after'))
650
- return 'after';
651
- return 'before';
652
- }
653
- generateRuleCondition(rule) {
654
- if (rule.name.includes('Priority')) {
655
- return 'current.impact.changes() || current.urgency.changes()';
656
- }
657
- if (rule.name.includes('Auto Number')) {
658
- return 'current.number.nil()';
659
- }
660
- return '';
661
- }
662
- generateRuleScript(rule) {
663
- if (rule.name.includes('Auto Number')) {
664
- return `
665
- // Auto-generate number for new records
666
- if (current.number.nil()) {
667
- current.number = new NumberManager('${rule.table || 'custom'}').getNextObjNumber();
668
- }
669
- `.trim();
670
- }
671
- if (rule.name.includes('Priority')) {
672
- return `
673
- // Calculate priority based on impact and urgency
674
- if (current.impact.changes() || current.urgency.changes()) {
675
- var impact = parseInt(current.impact) || 3;
676
- var urgency = parseInt(current.urgency) || 3;
677
- current.priority = Math.max(impact, urgency);
678
- }
679
- `.trim();
680
- }
681
- if (rule.name.includes('Assignment Group')) {
682
- return `
683
- // Auto-populate assignment group based on category
684
- if (current.category.changes() && !current.assignment_group.nil()) {
685
- var assignmentMapping = {
686
- 'hardware': 'Hardware Support',
687
- 'software': 'Software Support',
688
- 'network': 'Network Operations'
689
- };
690
-
691
- var group = assignmentMapping[current.category.toString()] || 'General Support';
692
- var gr = new GlideRecord('sys_user_group');
693
- if (gr.get('name', group)) {
694
- current.assignment_group = gr.sys_id;
695
- }
696
- }
697
- `.trim();
698
- }
699
- return `// ${rule.description}\n// TODO: Implement ${rule.name} logic`;
700
- }
701
- async generateScriptIncludesCode(scriptIncludes) {
702
- return scriptIncludes.map(si => ({
703
- name: si.name,
704
- clientCallable: si.clientCallable,
705
- description: si.description,
706
- script: this.generateScriptIncludeContent(si)
707
- }));
708
- }
709
- generateScriptIncludeContent(scriptInclude) {
710
- const className = scriptInclude.name;
711
- const functions = scriptInclude.functions || [];
712
- let script = `var ${className} = Class.create();\n`;
713
- script += `${className}.prototype = {\n`;
714
- script += ` initialize: function() {\n`;
715
- script += ` },\n\n`;
716
- functions.forEach((func, index) => {
717
- script += ` ${func}: function() {\n`;
718
- script += ` // TODO: Implement ${func} logic\n`;
719
- script += ` return null;\n`;
720
- script += ` }${index < functions.length - 1 ? ',' : ''}\n\n`;
721
- });
722
- script += ` type: '${className}'\n`;
723
- script += `};`;
724
- return script;
725
- }
726
- async generateValidationCode(validations) {
727
- return validations.map(validation => ({
728
- name: validation.name,
729
- type: validation.type,
730
- severity: validation.severity,
731
- clientScript: this.generateClientValidation(validation),
732
- serverScript: this.generateServerValidation(validation)
733
- }));
734
- }
735
- generateClientValidation(validation) {
736
- if (validation.name.includes('Required Fields')) {
737
- return `
738
- function onSubmit() {
739
- var requiredFields = ['short_description', 'category'];
740
- for (var i = 0; i < requiredFields.length; i++) {
741
- var field = requiredFields[i];
742
- if (g_form.getValue(field) == '') {
743
- g_form.addErrorMessage(field + ' is required');
744
- return false;
745
- }
746
- }
747
- return true;
748
- }
749
- `.trim();
750
- }
751
- if (validation.name.includes('Field Format')) {
752
- return `
753
- function onChange(control, oldValue, newValue, isLoading) {
754
- if (isLoading || newValue == '') return;
755
-
756
- // Email validation
757
- if (control == 'email') {
758
- var emailPattern = /^[\\w\\.-]+@[\\w\\.-]+\\.[a-zA-Z]{2,}$/;
759
- if (!emailPattern.test(newValue)) {
760
- g_form.addErrorMessage('Please enter a valid email address');
761
- g_form.clearValue('email');
762
- }
763
- }
764
- }
765
- `.trim();
766
- }
767
- return `// Client-side validation for ${validation.name}`;
768
- }
769
- generateServerValidation(validation) {
770
- if (validation.name.includes('Asset Tag Format') && validation.pattern) {
771
- return `
772
- // Validate asset tag format
773
- if (current.asset_tag.changes()) {
774
- var pattern = /${validation.pattern}/;
775
- if (!pattern.test(current.asset_tag.toString())) {
776
- gs.addErrorMessage('Asset tag must follow format: ${validation.pattern}');
777
- current.setAbortAction(true);
778
- }
779
- }
780
- `.trim();
781
- }
782
- return `// Server-side validation for ${validation.name}`;
783
- }
784
- async generateCalculationCode(calculations) {
785
- return calculations.map(calc => ({
786
- name: calc.name,
787
- description: calc.description,
788
- formula: calc.formula,
789
- implementation: this.generateCalculationImplementation(calc)
790
- }));
791
- }
792
- generateCalculationImplementation(calculation) {
793
- if (calculation.name.includes('Priority')) {
794
- return `
795
- // Priority calculation based on impact and urgency
796
- function calculatePriority(impact, urgency) {
797
- var impactValue = parseInt(impact) || 3;
798
- var urgencyValue = parseInt(urgency) || 3;
799
- return Math.max(impactValue, urgencyValue);
800
- }
801
- `.trim();
802
- }
803
- if (calculation.name.includes('Depreciation')) {
804
- return `
805
- // Asset depreciation calculation
806
- function calculateDepreciation(cost, depreciationRate, years) {
807
- var annualDepreciation = cost * depreciationRate;
808
- var totalDepreciation = annualDepreciation * years;
809
- return Math.max(0, cost - totalDepreciation);
810
- }
811
- `.trim();
812
- }
813
- return `// Implementation for ${calculation.name}`;
814
- }
815
- async generateWorkflowDefinitions(workflows) {
816
- return workflows.map(workflow => ({
817
- name: workflow.name,
818
- description: workflow.description,
819
- trigger: workflow.trigger,
820
- stages: workflow.stages,
821
- definition: this.generateWorkflowDefinition(workflow)
822
- }));
823
- }
824
- generateWorkflowDefinition(workflow) {
825
- return {
826
- name: workflow.name,
827
- table: this.getWorkflowTable(workflow),
828
- condition: this.getWorkflowCondition(workflow),
829
- activities: workflow.stages.map((stage, index) => ({
830
- sequence: index + 1,
831
- name: stage.replace('_', ' ').replace(/\b\w/g, l => l.toUpperCase()),
832
- type: 'task',
833
- description: `Execute ${stage} stage`
834
- }))
835
- };
836
- }
837
- getWorkflowTable(workflow) {
838
- if (workflow.name.includes('Incident'))
839
- return 'incident';
840
- if (workflow.name.includes('Change'))
841
- return 'change_request';
842
- if (workflow.name.includes('Request'))
843
- return 'sc_request';
844
- if (workflow.name.includes('Asset'))
845
- return 'alm_asset';
846
- return 'task';
847
- }
848
- getWorkflowCondition(workflow) {
849
- if (workflow.trigger === 'record_insert_update')
850
- return 'current.operation() != "delete"';
851
- if (workflow.trigger === 'state_change')
852
- return 'current.state.changes()';
853
- return '';
854
- }
855
- }
856
- exports.BusinessLogicSpecialist = BusinessLogicSpecialist;
857
- class InterfaceSpecialist extends base_specialist_js_1.BaseSpecialist {
858
- constructor(options = {}) {
859
- super('Interface Designer', 'Interface Designer', ['Forms', 'Lists', 'UI Policies', 'Client Scripts', 'User Experience'], options);
860
- }
861
- async execute(task, context) {
862
- await this.logProgress(`Analyzing interface requirements for: ${task}`);
863
- const analysis = await this.analyzeTask(task);
864
- const interfaceRequirements = {
865
- forms: this.identifyForms(task),
866
- lists: this.identifyLists(task),
867
- uiPolicies: this.identifyUIPolicies(task),
868
- clientScripts: this.identifyClientScripts(task),
869
- modules: this.identifyNavigationModules(task),
870
- userExperience: this.analyzeUXRequirements(task)
871
- };
872
- await this.logProgress('Designing user interface architecture');
873
- const interfaceArchitecture = await this.createInterfaceArchitecture(interfaceRequirements);
874
- await this.logProgress('Creating interface implementations');
875
- const implementations = await this.createInterfaceImplementations(interfaceRequirements);
876
- return {
877
- ...analysis,
878
- specialist: 'Interface Designer',
879
- deliverables: {
880
- interfaceArchitecture,
881
- implementations,
882
- requirements: interfaceRequirements
883
- }
884
- };
885
- }
886
- identifyForms(task) {
887
- const forms = [];
888
- const lowerTask = task.toLowerCase();
889
- if (lowerTask.includes('itsm')) {
890
- forms.push({
891
- name: 'incident_form',
892
- table: 'incident',
893
- type: 'default',
894
- sections: ['details', 'assignment', 'resolution', 'related']
895
- }, {
896
- name: 'request_form',
897
- table: 'sc_request',
898
- type: 'default',
899
- sections: ['request_details', 'approval', 'fulfillment']
900
- });
901
- }
902
- if (lowerTask.includes('asset')) {
903
- forms.push({
904
- name: 'asset_form',
905
- table: 'alm_asset',
906
- type: 'default',
907
- sections: ['basic_info', 'financial', 'location', 'maintenance']
908
- });
909
- }
910
- if (lowerTask.includes('project')) {
911
- forms.push({
912
- name: 'project_form',
913
- table: 'project',
914
- type: 'default',
915
- sections: ['project_details', 'timeline', 'team', 'budget']
916
- }, {
917
- name: 'task_form',
918
- table: 'project_task',
919
- type: 'default',
920
- sections: ['task_details', 'assignment', 'progress']
921
- });
922
- }
923
- // Default generic form if no specific domain
924
- if (forms.length === 0) {
925
- forms.push({
926
- name: 'default_form',
927
- table: 'custom_table',
928
- type: 'default',
929
- sections: ['basic_information', 'details', 'system_information']
930
- });
931
- }
932
- return forms;
933
- }
934
- identifyLists(task) {
935
- const lists = [];
936
- const lowerTask = task.toLowerCase();
937
- if (lowerTask.includes('itsm')) {
938
- lists.push({
939
- name: 'open_incidents',
940
- table: 'incident',
941
- filter: 'active=true',
942
- columns: ['number', 'short_description', 'state', 'priority', 'assigned_to']
943
- }, {
944
- name: 'my_requests',
945
- table: 'sc_request',
946
- filter: 'requested_by=javascript:gs.getUserID()',
947
- columns: ['number', 'short_description', 'state', 'requested_for']
948
- });
949
- }
950
- if (lowerTask.includes('asset')) {
951
- lists.push({
952
- name: 'asset_inventory',
953
- table: 'alm_asset',
954
- filter: 'install_status!=7',
955
- columns: ['asset_tag', 'display_name', 'model', 'assigned_to', 'location']
956
- });
957
- }
958
- if (lowerTask.includes('project')) {
959
- lists.push({
960
- name: 'active_projects',
961
- table: 'project',
962
- filter: 'state=2',
963
- columns: ['number', 'short_description', 'percent_complete', 'project_manager']
964
- }, {
965
- name: 'my_tasks',
966
- table: 'project_task',
967
- filter: 'assigned_to=javascript:gs.getUserID()',
968
- columns: ['number', 'short_description', 'state', 'due_date']
969
- });
970
- }
971
- return lists;
972
- }
973
- identifyUIPolicies(task) {
974
- const policies = [];
975
- const lowerTask = task.toLowerCase();
976
- // Common UI policies
977
- policies.push({
978
- name: 'Hide System Fields',
979
- description: 'Hide system fields from end users',
980
- condition: '!gs.hasRole("admin")',
981
- actions: [
982
- { field: 'sys_created_by', action: 'hidden', value: true },
983
- { field: 'sys_updated_by', action: 'hidden', value: true }
984
- ]
985
- });
986
- if (lowerTask.includes('itsm')) {
987
- policies.push({
988
- name: 'Incident Assignment Logic',
989
- description: 'Show assignment fields only when incident is assigned',
990
- condition: 'current.state >= 2',
991
- actions: [
992
- { field: 'assigned_to', action: 'visible', value: true },
993
- { field: 'assignment_group', action: 'visible', value: true }
994
- ]
995
- }, {
996
- name: 'Resolution Fields',
997
- description: 'Show resolution fields only when resolving',
998
- condition: 'current.state == 6',
999
- actions: [
1000
- { field: 'close_code', action: 'mandatory', value: true },
1001
- { field: 'close_notes', action: 'mandatory', value: true }
1002
- ]
1003
- });
1004
- }
1005
- if (lowerTask.includes('approval')) {
1006
- policies.push({
1007
- name: 'Approval Fields Visibility',
1008
- description: 'Show approval fields based on approval state',
1009
- condition: 'current.approval != "not requested"',
1010
- actions: [
1011
- { field: 'approver', action: 'readonly', value: true },
1012
- { field: 'approval_history', action: 'visible', value: true }
1013
- ]
1014
- });
1015
- }
1016
- return policies;
1017
- }
1018
- identifyClientScripts(task) {
1019
- const scripts = [];
1020
- const lowerTask = task.toLowerCase();
1021
- // Common client scripts
1022
- scripts.push({
1023
- name: 'Form Validation',
1024
- type: 'onSubmit',
1025
- description: 'Validate required fields before submission',
1026
- table: 'global'
1027
- });
1028
- if (lowerTask.includes('itsm')) {
1029
- scripts.push({
1030
- name: 'Priority Calculation',
1031
- type: 'onChange',
1032
- description: 'Calculate priority when impact or urgency changes',
1033
- table: 'incident',
1034
- field: 'impact,urgency'
1035
- }, {
1036
- name: 'Category Assignment Group',
1037
- type: 'onChange',
1038
- description: 'Suggest assignment group based on category',
1039
- table: 'incident',
1040
- field: 'category'
1041
- });
1042
- }
1043
- if (lowerTask.includes('asset')) {
1044
- scripts.push({
1045
- name: 'Asset Tag Format',
1046
- type: 'onChange',
1047
- description: 'Format and validate asset tag',
1048
- table: 'alm_asset',
1049
- field: 'asset_tag'
1050
- });
1051
- }
1052
- if (lowerTask.includes('financial') || lowerTask.includes('cost')) {
1053
- scripts.push({
1054
- name: 'Currency Formatting',
1055
- type: 'onChange',
1056
- description: 'Format currency fields',
1057
- table: 'global',
1058
- field: 'cost,price,amount'
1059
- });
1060
- }
1061
- return scripts;
1062
- }
1063
- identifyNavigationModules(task) {
1064
- const modules = [];
1065
- const lowerTask = task.toLowerCase();
1066
- if (lowerTask.includes('itsm')) {
1067
- modules.push({
1068
- title: 'Incident Management',
1069
- application: 'ITSM Application',
1070
- items: [
1071
- { title: 'Create New', table: 'incident', type: 'new' },
1072
- { title: 'Open Incidents', table: 'incident', type: 'list', filter: 'active=true' },
1073
- { title: 'My Incidents', table: 'incident', type: 'list', filter: 'assigned_to=javascript:gs.getUserID()' }
1074
- ]
1075
- }, {
1076
- title: 'Request Management',
1077
- application: 'ITSM Application',
1078
- items: [
1079
- { title: 'Service Catalog', type: 'catalog' },
1080
- { title: 'My Requests', table: 'sc_request', type: 'list', filter: 'requested_by=javascript:gs.getUserID()' }
1081
- ]
1082
- });
1083
- }
1084
- if (lowerTask.includes('asset')) {
1085
- modules.push({
1086
- title: 'Asset Management',
1087
- application: 'Asset Application',
1088
- items: [
1089
- { title: 'All Assets', table: 'alm_asset', type: 'list' },
1090
- { title: 'My Assets', table: 'alm_asset', type: 'list', filter: 'assigned_to=javascript:gs.getUserID()' },
1091
- { title: 'Asset Reports', type: 'reports' }
1092
- ]
1093
- });
1094
- }
1095
- return modules;
1096
- }
1097
- analyzeUXRequirements(task) {
1098
- const lowerTask = task.toLowerCase();
1099
- return {
1100
- usability: {
1101
- intuitive: true,
1102
- consistent: true,
1103
- accessible: true,
1104
- responsive: lowerTask.includes('mobile') || lowerTask.includes('responsive')
1105
- },
1106
- performance: {
1107
- fastLoading: true,
1108
- efficientQueries: true,
1109
- caching: lowerTask.includes('dashboard') || lowerTask.includes('reports')
1110
- },
1111
- accessibility: {
1112
- wcag: 'AA',
1113
- screenReader: true,
1114
- keyboardNavigation: true,
1115
- colorContrast: true
1116
- },
1117
- responsive: {
1118
- mobile: lowerTask.includes('mobile'),
1119
- tablet: true,
1120
- desktop: true
1121
- }
1122
- };
1123
- }
1124
- async createInterfaceArchitecture(requirements) {
1125
- return {
1126
- patterns: {
1127
- navigation: 'Hierarchical menu structure',
1128
- forms: 'Section-based form layout',
1129
- lists: 'Filtered list views with sorting',
1130
- interaction: 'Real-time field validation'
1131
- },
1132
- components: {
1133
- forms: requirements.forms.length,
1134
- lists: requirements.lists.length,
1135
- uiPolicies: requirements.uiPolicies.length,
1136
- clientScripts: requirements.clientScripts.length,
1137
- modules: requirements.modules.length
1138
- },
1139
- userExperience: requirements.userExperience,
1140
- responsive: {
1141
- breakpoints: ['mobile', 'tablet', 'desktop'],
1142
- approach: 'mobile-first'
1143
- }
1144
- };
1145
- }
1146
- async createInterfaceImplementations(requirements) {
1147
- return {
1148
- forms: await this.generateFormDefinitions(requirements.forms),
1149
- lists: await this.generateListDefinitions(requirements.lists),
1150
- uiPolicies: await this.generateUIPolicyCode(requirements.uiPolicies),
1151
- clientScripts: await this.generateClientScriptCode(requirements.clientScripts),
1152
- modules: await this.generateModuleDefinitions(requirements.modules)
1153
- };
1154
- }
1155
- async generateFormDefinitions(forms) {
1156
- return forms.map(form => ({
1157
- name: form.name,
1158
- table: form.table,
1159
- type: form.type,
1160
- layout: this.generateFormLayout(form),
1161
- sections: this.generateFormSections(form.sections)
1162
- }));
1163
- }
1164
- generateFormLayout(form) {
1165
- return {
1166
- columns: 2,
1167
- sections: form.sections,
1168
- responsive: true,
1169
- collapsible: true
1170
- };
1171
- }
1172
- generateFormSections(sections) {
1173
- return sections.map(section => ({
1174
- name: section,
1175
- label: section.replace('_', ' ').replace(/\b\w/g, l => l.toUpperCase()),
1176
- collapsed: section.includes('system'),
1177
- columns: section === 'details' ? 1 : 2
1178
- }));
1179
- }
1180
- async generateListDefinitions(lists) {
1181
- return lists.map(list => ({
1182
- name: list.name,
1183
- table: list.table,
1184
- filter: list.filter,
1185
- columns: list.columns,
1186
- sortBy: list.columns[0],
1187
- groupBy: null,
1188
- aggregates: []
1189
- }));
1190
- }
1191
- async generateUIPolicyCode(policies) {
1192
- return policies.map(policy => ({
1193
- name: policy.name,
1194
- description: policy.description,
1195
- condition: policy.condition,
1196
- script: this.generateUIPolicyScript(policy)
1197
- }));
1198
- }
1199
- generateUIPolicyScript(policy) {
1200
- let script = `// ${policy.description}\n`;
1201
- script += `if (${policy.condition}) {\n`;
1202
- policy.actions.forEach(action => {
1203
- switch (action.action) {
1204
- case 'hidden':
1205
- script += ` g_form.setVisible('${action.field}', ${!action.value});\n`;
1206
- break;
1207
- case 'visible':
1208
- script += ` g_form.setVisible('${action.field}', ${action.value});\n`;
1209
- break;
1210
- case 'mandatory':
1211
- script += ` g_form.setMandatory('${action.field}', ${action.value});\n`;
1212
- break;
1213
- case 'readonly':
1214
- script += ` g_form.setReadOnly('${action.field}', ${action.value});\n`;
1215
- break;
1216
- }
1217
- });
1218
- script += `}`;
1219
- return script;
1220
- }
1221
- async generateClientScriptCode(scripts) {
1222
- return scripts.map(script => ({
1223
- name: script.name,
1224
- type: script.type,
1225
- table: script.table,
1226
- field: script.field,
1227
- script: this.generateClientScriptContent(script)
1228
- }));
1229
- }
1230
- generateClientScriptContent(script) {
1231
- if (script.name.includes('Form Validation')) {
1232
- return `
1233
- function onSubmit() {
1234
- var requiredFields = ['short_description'];
1235
- for (var i = 0; i < requiredFields.length; i++) {
1236
- var field = requiredFields[i];
1237
- if (g_form.getValue(field) == '') {
1238
- g_form.addErrorMessage(field.replace('_', ' ') + ' is required');
1239
- return false;
1240
- }
1241
- }
1242
- return true;
1243
- }
1244
- `.trim();
1245
- }
1246
- if (script.name.includes('Priority Calculation')) {
1247
- return `
1248
- function onChange(control, oldValue, newValue, isLoading) {
1249
- if (isLoading || newValue == '') return;
1250
-
1251
- var impact = parseInt(g_form.getValue('impact')) || 3;
1252
- var urgency = parseInt(g_form.getValue('urgency')) || 3;
1253
- var priority = Math.max(impact, urgency);
1254
-
1255
- g_form.setValue('priority', priority);
1256
- }
1257
- `.trim();
1258
- }
1259
- return `// ${script.description}\nfunction ${script.type}() {\n // TODO: Implement logic\n}`;
1260
- }
1261
- async generateModuleDefinitions(modules) {
1262
- return modules.map(module => ({
1263
- title: module.title,
1264
- application: module.application,
1265
- order: 100,
1266
- items: module.items.map((item, index) => ({
1267
- title: item.title,
1268
- order: (index + 1) * 10,
1269
- table: item.table,
1270
- type: item.type,
1271
- filter: item.filter
1272
- }))
1273
- }));
1274
- }
1275
- }
1276
- exports.InterfaceSpecialist = InterfaceSpecialist;
1277
- class PerformanceSpecialist extends base_specialist_js_1.BaseSpecialist {
1278
- constructor(options = {}) {
1279
- super('Performance Optimizer', 'Performance Specialist', ['Query Optimization', 'Caching', 'Indexing', 'Load Testing', 'Monitoring'], options);
1280
- }
1281
- async execute(task, context) {
1282
- await this.logProgress(`Analyzing performance requirements for: ${task}`);
1283
- const analysis = await this.analyzeTask(task);
1284
- const performanceRequirements = {
1285
- queryOptimization: this.analyzeQueryOptimization(task),
1286
- caching: this.analyzeCachingNeeds(task),
1287
- indexing: this.analyzeIndexingStrategy(task),
1288
- monitoring: this.analyzeMonitoringNeeds(task),
1289
- scalability: this.analyzeScalabilityRequirements(task),
1290
- loadTesting: this.analyzeLoadTestingNeeds(task)
1291
- };
1292
- await this.logProgress('Designing performance optimization strategy');
1293
- const optimizationStrategy = await this.createOptimizationStrategy(performanceRequirements);
1294
- await this.logProgress('Creating performance implementation plan');
1295
- const implementationPlan = await this.createImplementationPlan(performanceRequirements);
1296
- return {
1297
- ...analysis,
1298
- specialist: 'Performance Specialist',
1299
- deliverables: {
1300
- optimizationStrategy,
1301
- implementationPlan,
1302
- requirements: performanceRequirements
1303
- }
1304
- };
1305
- }
1306
- analyzeQueryOptimization(task) {
1307
- const lowerTask = task.toLowerCase();
1308
- return {
1309
- enabled: true,
1310
- techniques: [
1311
- 'indexed_queries',
1312
- 'query_caching',
1313
- 'result_limiting',
1314
- 'field_selection'
1315
- ],
1316
- priorities: this.identifyQueryPriorities(task),
1317
- monitoring: lowerTask.includes('monitor') || lowerTask.includes('analytics'),
1318
- automation: true
1319
- };
1320
- }
1321
- identifyQueryPriorities(task) {
1322
- const priorities = ['list_views', 'form_loads'];
1323
- const lowerTask = task.toLowerCase();
1324
- if (lowerTask.includes('dashboard')) {
1325
- priorities.push('dashboard_queries', 'aggregation_queries');
1326
- }
1327
- if (lowerTask.includes('report')) {
1328
- priorities.push('reporting_queries', 'complex_joins');
1329
- }
1330
- if (lowerTask.includes('search')) {
1331
- priorities.push('search_queries', 'full_text_search');
1332
- }
1333
- return priorities;
1334
- }
1335
- analyzeCachingNeeds(task) {
1336
- const lowerTask = task.toLowerCase();
1337
- return {
1338
- levels: ['browser', 'application', 'database'],
1339
- strategies: {
1340
- static: lowerTask.includes('reference') || lowerTask.includes('lookup'),
1341
- dynamic: lowerTask.includes('dashboard') || lowerTask.includes('realtime'),
1342
- distributed: lowerTask.includes('enterprise') || lowerTask.includes('high volume')
1343
- },
1344
- ttl: {
1345
- short: '5 minutes',
1346
- medium: '30 minutes',
1347
- long: '4 hours'
1348
- },
1349
- invalidation: 'event_based'
1350
- };
1351
- }
1352
- analyzeIndexingStrategy(task) {
1353
- const lowerTask = task.toLowerCase();
1354
- return {
1355
- automatic: true,
1356
- types: ['btree', 'hash', 'composite'],
1357
- monitoring: true,
1358
- maintenance: 'automated',
1359
- priorities: this.identifyIndexPriorities(task)
1360
- };
1361
- }
1362
- identifyIndexPriorities(task) {
1363
- const priorities = ['primary_keys', 'foreign_keys', 'frequently_queried'];
1364
- const lowerTask = task.toLowerCase();
1365
- if (lowerTask.includes('search')) {
1366
- priorities.push('text_search', 'full_text_indexes');
1367
- }
1368
- if (lowerTask.includes('date') || lowerTask.includes('time')) {
1369
- priorities.push('temporal_indexes');
1370
- }
1371
- if (lowerTask.includes('geographic') || lowerTask.includes('location')) {
1372
- priorities.push('spatial_indexes');
1373
- }
1374
- return priorities;
1375
- }
1376
- analyzeMonitoringNeeds(task) {
1377
- const lowerTask = task.toLowerCase();
1378
- return {
1379
- realTime: lowerTask.includes('realtime') || lowerTask.includes('monitor'),
1380
- metrics: [
1381
- 'response_time',
1382
- 'throughput',
1383
- 'error_rate',
1384
- 'resource_utilization'
1385
- ],
1386
- alerting: {
1387
- thresholds: {
1388
- response_time: '> 2 seconds',
1389
- error_rate: '> 5%',
1390
- cpu_usage: '> 80%',
1391
- memory_usage: '> 90%'
1392
- },
1393
- notifications: ['email', 'dashboard']
1394
- },
1395
- dashboards: lowerTask.includes('dashboard') || lowerTask.includes('monitor')
1396
- };
1397
- }
1398
- analyzeScalabilityRequirements(task) {
1399
- const lowerTask = task.toLowerCase();
1400
- return {
1401
- horizontal: lowerTask.includes('enterprise') || lowerTask.includes('large'),
1402
- vertical: true,
1403
- autoScaling: lowerTask.includes('auto') || lowerTask.includes('dynamic'),
1404
- loadBalancing: lowerTask.includes('distributed') || lowerTask.includes('cluster'),
1405
- partitioning: lowerTask.includes('partition') || lowerTask.includes('shard')
1406
- };
1407
- }
1408
- analyzeLoadTestingNeeds(task) {
1409
- const lowerTask = task.toLowerCase();
1410
- return {
1411
- required: lowerTask.includes('performance') || lowerTask.includes('load'),
1412
- scenarios: [
1413
- 'normal_load',
1414
- 'peak_load',
1415
- 'stress_test'
1416
- ],
1417
- metrics: [
1418
- 'concurrent_users',
1419
- 'transactions_per_second',
1420
- 'response_time_percentiles'
1421
- ],
1422
- automation: true
1423
- };
1424
- }
1425
- async createOptimizationStrategy(requirements) {
1426
- return {
1427
- phases: [
1428
- {
1429
- name: 'Assessment',
1430
- duration: '1-2 days',
1431
- activities: ['baseline_measurement', 'bottleneck_identification', 'requirements_analysis']
1432
- },
1433
- {
1434
- name: 'Quick Wins',
1435
- duration: '2-3 days',
1436
- activities: ['query_optimization', 'index_creation', 'caching_implementation']
1437
- },
1438
- {
1439
- name: 'Deep Optimization',
1440
- duration: '1-2 weeks',
1441
- activities: ['architecture_optimization', 'advanced_caching', 'load_balancing']
1442
- },
1443
- {
1444
- name: 'Monitoring & Tuning',
1445
- duration: 'ongoing',
1446
- activities: ['performance_monitoring', 'continuous_optimization', 'capacity_planning']
1447
- }
1448
- ],
1449
- priorities: this.createOptimizationPriorities(requirements),
1450
- success_criteria: this.createSuccessCriteria(requirements)
1451
- };
1452
- }
1453
- createOptimizationPriorities(requirements) {
1454
- return [
1455
- {
1456
- priority: 'high',
1457
- area: 'Database Queries',
1458
- techniques: requirements.queryOptimization.techniques,
1459
- expectedImprovement: '50-80%'
1460
- },
1461
- {
1462
- priority: 'high',
1463
- area: 'Caching',
1464
- techniques: Object.keys(requirements.caching.strategies),
1465
- expectedImprovement: '30-60%'
1466
- },
1467
- {
1468
- priority: 'medium',
1469
- area: 'Indexing',
1470
- techniques: requirements.indexing.types,
1471
- expectedImprovement: '20-40%'
1472
- },
1473
- {
1474
- priority: 'medium',
1475
- area: 'Monitoring',
1476
- techniques: ['real_time_monitoring', 'alerting'],
1477
- expectedImprovement: 'ongoing'
1478
- }
1479
- ];
1480
- }
1481
- createSuccessCriteria(requirements) {
1482
- return {
1483
- response_time: {
1484
- form_loads: '< 2 seconds',
1485
- list_views: '< 3 seconds',
1486
- dashboard_loads: '< 5 seconds',
1487
- search_results: '< 1 second'
1488
- },
1489
- throughput: {
1490
- concurrent_users: '100+',
1491
- transactions_per_second: '50+',
1492
- data_processing: '1000+ records/minute'
1493
- },
1494
- availability: {
1495
- uptime: '99.9%',
1496
- error_rate: '< 1%',
1497
- recovery_time: '< 5 minutes'
1498
- },
1499
- scalability: {
1500
- user_growth: '200% capacity',
1501
- data_growth: '300% capacity',
1502
- transaction_growth: '250% capacity'
1503
- }
1504
- };
1505
- }
1506
- async createImplementationPlan(requirements) {
1507
- return {
1508
- database_optimization: this.createDatabaseOptimizationPlan(requirements),
1509
- caching_implementation: this.createCachingImplementationPlan(requirements),
1510
- monitoring_setup: this.createMonitoringSetupPlan(requirements),
1511
- testing_strategy: this.createTestingStrategy(requirements),
1512
- maintenance_plan: this.createMaintenancePlan(requirements)
1513
- };
1514
- }
1515
- createDatabaseOptimizationPlan(requirements) {
1516
- return {
1517
- query_optimization: {
1518
- techniques: requirements.queryOptimization.techniques,
1519
- tools: ['query_analyzer', 'execution_plan_viewer', 'performance_dashboard'],
1520
- automation: requirements.queryOptimization.automation
1521
- },
1522
- indexing: {
1523
- strategy: requirements.indexing,
1524
- creation_priority: requirements.indexing.priorities,
1525
- maintenance: 'automated'
1526
- },
1527
- partitioning: {
1528
- enabled: requirements.scalability.partitioning,
1529
- strategy: 'date_based',
1530
- maintenance: 'automated'
1531
- }
1532
- };
1533
- }
1534
- createCachingImplementationPlan(requirements) {
1535
- return {
1536
- levels: requirements.caching.levels,
1537
- strategies: requirements.caching.strategies,
1538
- configuration: {
1539
- ttl_policies: requirements.caching.ttl,
1540
- invalidation: requirements.caching.invalidation,
1541
- compression: true,
1542
- encryption: false
1543
- },
1544
- monitoring: {
1545
- hit_rate: 'target > 80%',
1546
- miss_rate: 'target < 20%',
1547
- eviction_rate: 'monitor'
1548
- }
1549
- };
1550
- }
1551
- createMonitoringSetupPlan(requirements) {
1552
- return {
1553
- metrics_collection: {
1554
- real_time: requirements.monitoring.realTime,
1555
- metrics: requirements.monitoring.metrics,
1556
- retention: '90 days'
1557
- },
1558
- alerting: requirements.monitoring.alerting,
1559
- dashboards: {
1560
- executive: 'high_level_kpis',
1561
- operational: 'detailed_metrics',
1562
- technical: 'system_performance'
1563
- },
1564
- reporting: {
1565
- frequency: 'weekly',
1566
- format: 'automated_reports',
1567
- distribution: ['technical_team', 'management']
1568
- }
1569
- };
1570
- }
1571
- createTestingStrategy(requirements) {
1572
- if (!requirements.loadTesting.required) {
1573
- return { required: false };
1574
- }
1575
- return {
1576
- scenarios: requirements.loadTesting.scenarios.map(scenario => ({
1577
- name: scenario,
1578
- users: this.getScenarioUsers(scenario),
1579
- duration: this.getScenarioDuration(scenario),
1580
- ramp_up: this.getScenarioRampUp(scenario)
1581
- })),
1582
- metrics: requirements.loadTesting.metrics,
1583
- tools: ['jmeter', 'loadrunner', 'gatling'],
1584
- automation: requirements.loadTesting.automation,
1585
- schedule: 'before_major_releases'
1586
- };
1587
- }
1588
- getScenarioUsers(scenario) {
1589
- switch (scenario) {
1590
- case 'normal_load': return 50;
1591
- case 'peak_load': return 200;
1592
- case 'stress_test': return 500;
1593
- default: return 100;
1594
- }
1595
- }
1596
- getScenarioDuration(scenario) {
1597
- switch (scenario) {
1598
- case 'normal_load': return '30 minutes';
1599
- case 'peak_load': return '15 minutes';
1600
- case 'stress_test': return '10 minutes';
1601
- default: return '20 minutes';
1602
- }
1603
- }
1604
- getScenarioRampUp(scenario) {
1605
- switch (scenario) {
1606
- case 'normal_load': return '5 minutes';
1607
- case 'peak_load': return '2 minutes';
1608
- case 'stress_test': return '1 minute';
1609
- default: return '3 minutes';
1610
- }
1611
- }
1612
- createMaintenancePlan(requirements) {
1613
- return {
1614
- daily: [
1615
- 'performance_metrics_review',
1616
- 'cache_hit_rate_monitoring',
1617
- 'slow_query_identification'
1618
- ],
1619
- weekly: [
1620
- 'index_usage_analysis',
1621
- 'performance_trend_analysis',
1622
- 'capacity_planning_review'
1623
- ],
1624
- monthly: [
1625
- 'full_performance_audit',
1626
- 'optimization_opportunities_assessment',
1627
- 'scalability_planning'
1628
- ],
1629
- automation: {
1630
- monitoring: true,
1631
- alerting: true,
1632
- reporting: true,
1633
- optimization: 'semi_automated'
1634
- }
1635
- };
1636
- }
1637
- }
1638
- exports.PerformanceSpecialist = PerformanceSpecialist;
1639
- //# sourceMappingURL=app-specialists.js.map