snow-flow 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/{.claude/mcp-config.json → .mcp.json} +13 -12
  2. package/.releaserc.json +47 -0
  3. package/README.md +6 -0
  4. package/package.json +1 -1
  5. package/.claude/claude-settings.json +0 -15
  6. package/.claude/commands/analysis/README.md +0 -9
  7. package/.claude/commands/automation/README.md +0 -9
  8. package/.claude/commands/github/README.md +0 -11
  9. package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
  10. package/.claude/commands/hooks/README.md +0 -11
  11. package/.claude/commands/monitoring/README.md +0 -9
  12. package/.claude/commands/optimization/README.md +0 -9
  13. package/.claude/commands/training/README.md +0 -9
  14. package/.claude/commands/workflows/README.md +0 -9
  15. package/.claude/config.json +0 -36
  16. package/.claude/helpers/github-setup.sh +0 -28
  17. package/.claude/helpers/quick-start.sh +0 -19
  18. package/.claude/helpers/setup-mcp.sh +0 -18
  19. package/.claude/settings.json +0 -114
  20. package/.claude/settings.local.json +0 -33
  21. package/.claude-flow/metrics/agent-metrics.json +0 -1
  22. package/.claude-flow/metrics/performance.json +0 -9
  23. package/.claude-flow/metrics/system-metrics.json +0 -15986
  24. package/.claude-flow/metrics/task-metrics.json +0 -10
  25. package/.roo/README.md +0 -402
  26. package/.roo/mcp-list.txt +0 -257
  27. package/.roo/mcp.json +0 -32
  28. package/.roo/workflows/basic-tdd.json +0 -32
  29. package/.roomodes +0 -201
  30. package/CLAUDE.md +0 -393
  31. package/bin/snow-flow.js +0 -3
  32. package/dist/cli.js.bak +0 -2052
  33. package/dist/config/snow-flow-config.d.ts +0 -1492
  34. package/dist/config/snow-flow-config.js +0 -938
  35. package/scripts/create-env.js +0 -91
  36. package/scripts/postinstall.js +0 -30
  37. package/scripts/register-mcp-servers.js +0 -210
  38. package/scripts/reset-mcp-servers.js +0 -246
  39. package/scripts/setup-mcp.js +0 -106
  40. package/scripts/update-version.js +0 -31
  41. package/src/agents/README.md +0 -192
  42. package/src/agents/base-agent.ts +0 -251
  43. package/src/agents/coordinator.ts +0 -971
  44. package/src/agents/index.ts +0 -18
  45. package/src/agents/queen-403-handler.ts +0 -230
  46. package/src/agents/queen-agent.ts +0 -1399
  47. package/src/agents/script-writer-agent.ts +0 -769
  48. package/src/agents/security-agent.ts +0 -726
  49. package/src/agents/widget-creator-agent.ts +0 -568
  50. package/src/api/error-handling.ts +0 -1758
  51. package/src/api/natural-language-mapper.ts +0 -630
  52. package/src/api/performance-optimizer.ts +0 -891
  53. package/src/api/transaction-manager.ts +0 -754
  54. package/src/cli/deploy-artifact.ts +0 -304
  55. package/src/cli/snow-flow-cli-integration.ts +0 -434
  56. package/src/cli.ts +0 -4455
  57. package/src/cli.ts.bak +0 -5616
  58. package/src/compliance/advanced-compliance-system.ts +0 -1268
  59. package/src/compliance/index.ts +0 -19
  60. package/src/config/snow-flow-config.ts +0 -1019
  61. package/src/documentation/index.ts +0 -16
  62. package/src/documentation/self-documenting-system.ts +0 -1421
  63. package/src/dynamic-version.ts +0 -44
  64. package/src/healing/index.ts +0 -20
  65. package/src/healing/self-healing-system.ts +0 -1435
  66. package/src/health/README.md +0 -161
  67. package/src/health/system-health.ts +0 -995
  68. package/src/index.ts +0 -60
  69. package/src/intelligence/acl-analyzer.ts +0 -377
  70. package/src/intelligence/auto-resolution-engine.ts +0 -643
  71. package/src/intelligence/gap-analysis-engine.ts +0 -488
  72. package/src/intelligence/manual-instructions-generator.ts +0 -744
  73. package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
  74. package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
  75. package/src/intelligence/performance-recommendations-engine.ts +0 -1223
  76. package/src/intelligence/requirements-analyzer.ts +0 -1148
  77. package/src/intelligence/task-analyzer.ts +0 -628
  78. package/src/managers/scope-manager.ts +0 -555
  79. package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
  80. package/src/mcp/base-mcp-server.ts +0 -660
  81. package/src/mcp/http-transport-wrapper.ts +0 -426
  82. package/src/mcp/service-discovery-client.ts +0 -312
  83. package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
  84. package/src/mcp/servicenow-automation-mcp.ts +0 -838
  85. package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
  86. package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
  87. package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
  88. package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
  89. package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
  90. package/src/mcp/servicenow-integration-mcp.ts +0 -819
  91. package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
  92. package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
  93. package/src/mcp/servicenow-mcp-server.ts +0 -728
  94. package/src/mcp/servicenow-memory-mcp.ts +0 -474
  95. package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
  96. package/src/mcp/servicenow-operations-mcp.ts +0 -3384
  97. package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
  98. package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
  99. package/src/mcp/servicenow-progressive-indexer.ts +0 -370
  100. package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
  101. package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
  102. package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
  103. package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
  104. package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
  105. package/src/mcp/servicenow-update-set-mcp.ts +0 -811
  106. package/src/mcp/shared/agent-context-provider.ts +0 -365
  107. package/src/mcp/shared/base-mcp-server.ts +0 -2463
  108. package/src/mcp/shared/mcp-memory-manager.ts +0 -540
  109. package/src/mcp/shared/mcp-resource-manager.ts +0 -367
  110. package/src/mcp/snow-flow-mcp.ts +0 -911
  111. package/src/mcp/start-all-mcp-servers.ts +0 -102
  112. package/src/mcp/start-servicenow-mcp.ts +0 -67
  113. package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
  114. package/src/monitoring/performance-tracker.ts +0 -777
  115. package/src/optimization/cost-optimization-engine.ts +0 -1125
  116. package/src/optimization/index.ts +0 -10
  117. package/src/queen/README.md +0 -403
  118. package/src/queen/agent-factory.ts +0 -574
  119. package/src/queen/index.ts +0 -94
  120. package/src/queen/mcp-execution-bridge.ts +0 -681
  121. package/src/queen/neural-learning.ts +0 -319
  122. package/src/queen/parallel-agent-engine.ts +0 -848
  123. package/src/queen/queen-memory-system.ts +0 -490
  124. package/src/queen/queen-memory.ts +0 -456
  125. package/src/queen/servicenow-queen.ts +0 -1029
  126. package/src/queen/types.ts +0 -87
  127. package/src/rollback/smart-rollback-system.ts +0 -866
  128. package/src/schemas/deployment.schema.json +0 -58
  129. package/src/schemas/flow.schema.json +0 -79
  130. package/src/schemas/widget.schema.json +0 -72
  131. package/src/snow-flow-system.ts +0 -541
  132. package/src/sparc/sparc-help.ts +0 -49
  133. package/src/sparc/team-sparc.ts +0 -88
  134. package/src/strategies/global-scope-strategy.ts +0 -736
  135. package/src/templates/base/application.template.json +0 -45
  136. package/src/templates/base/business_rule.template.json +0 -33
  137. package/src/templates/base/script_include.template.json +0 -18
  138. package/src/templates/base/table.template.json +0 -64
  139. package/src/templates/base/widget.template.json +0 -25
  140. package/src/templates/patterns/composite.incident-management.template.json +0 -140
  141. package/src/templates/patterns/widget.dashboard.template.json +0 -238
  142. package/src/templates/patterns/widget.datatable.template.json +0 -292
  143. package/src/testing/integration-test-suite.ts +0 -1276
  144. package/src/types/index.ts +0 -183
  145. package/src/types/neo4j-driver.d.ts +0 -23
  146. package/src/types/servicenow.types.ts +0 -307
  147. package/src/types/snow-flow.types.ts +0 -186
  148. package/src/types/todo.types.ts +0 -70
  149. package/src/utils/action-type-cache.ts +0 -286
  150. package/src/utils/agent-detector.ts +0 -573
  151. package/src/utils/artifact-tracker.ts +0 -379
  152. package/src/utils/dependency-detector.ts +0 -233
  153. package/src/utils/deployment-metadata-handler.ts +0 -518
  154. package/src/utils/error-recovery.ts +0 -680
  155. package/src/utils/logger.ts +0 -60
  156. package/src/utils/mcp-auth-middleware.ts +0 -262
  157. package/src/utils/mcp-config-manager.ts +0 -270
  158. package/src/utils/mcp-server-manager.ts +0 -446
  159. package/src/utils/mcp-tool-registry.ts +0 -298
  160. package/src/utils/migrate-snow-flow.ts +0 -98
  161. package/src/utils/oauth-html-templates.ts +0 -188
  162. package/src/utils/scope-utils.ts +0 -443
  163. package/src/utils/servicenow-client.ts +0 -3321
  164. package/src/utils/servicenow-id-generator.ts +0 -181
  165. package/src/utils/snow-memory-manager.ts +0 -605
  166. package/src/utils/snow-oauth.ts +0 -797
  167. package/src/utils/template-engine.ts +0 -463
  168. package/src/utils/theme-manager.ts +0 -295
  169. package/src/utils/unified-auth-store.ts +0 -222
  170. package/src/utils/update-set-importer.ts +0 -422
  171. package/src/utils/update-set-xml-packager.ts +0 -371
  172. package/src/utils/widget-template-generator.ts +0 -1744
  173. package/src/version.ts +0 -1950
@@ -1,1019 +0,0 @@
1
- /**
2
- * Snow-Flow Configuration Management
3
- * Central configuration for all system components
4
- */
5
-
6
- import path from 'path';
7
- import os from 'os';
8
- import fs from 'fs';
9
- import { z } from 'zod';
10
-
11
- // Configuration Schema using Zod for validation
12
- const ConfigSchema = z.object({
13
- // System-wide settings
14
- system: z
15
- .object({
16
- environment: z.enum(['development', 'staging', 'production']).default('development'),
17
- logLevel: z.enum(['debug', 'info', 'warn', 'error']).default('info'),
18
- dataDir: z
19
- .string()
20
- .default(process.env.SNOW_FLOW_HOME || path.join(os.homedir(), '.snow-flow')),
21
- maxConcurrentOperations: z.number().min(1).max(100).default(10),
22
- sessionTimeout: z.number().min(300000).default(3600000), // 1 hour default
23
- })
24
- .default({}),
25
-
26
- // Agent configuration
27
- agents: z
28
- .object({
29
- queen: z
30
- .object({
31
- maxWorkerAgents: z.number().min(1).max(50).default(10),
32
- spawnTimeout: z.number().min(5000).default(30000),
33
- coordinationInterval: z.number().min(1000).default(5000),
34
- decisionThreshold: z.number().min(0).max(1).default(0.7),
35
- retryAttempts: z.number().min(1).max(10).default(3),
36
- })
37
- .default({}),
38
- worker: z
39
- .object({
40
- heartbeatInterval: z.number().min(1000).default(10000),
41
- taskTimeout: z.number().min(60000).default(300000), // 5 minutes
42
- maxMemoryUsage: z.number().min(100).default(500), // MB
43
- autoShutdownIdle: z.number().min(60000).default(600000), // 10 minutes
44
- })
45
- .default({}),
46
- specializations: z
47
- .object({
48
- widgetCreator: z
49
- .object({
50
- enabled: z.boolean().default(true),
51
- priority: z.number().min(1).max(10).default(8),
52
- capabilities: z
53
- .array(z.string())
54
- .default(['html', 'css', 'javascript', 'servicenow-api']),
55
- })
56
- .default({}),
57
- flowBuilder: z
58
- .object({
59
- enabled: z.boolean().default(true),
60
- priority: z.number().min(1).max(10).default(8),
61
- capabilities: z
62
- .array(z.string())
63
- .default(['flow-designer', 'triggers', 'actions', 'approvals']),
64
- })
65
- .default({}),
66
- scriptWriter: z
67
- .object({
68
- enabled: z.boolean().default(true),
69
- priority: z.number().min(1).max(10).default(7),
70
- capabilities: z
71
- .array(z.string())
72
- .default(['business-rules', 'script-includes', 'client-scripts']),
73
- })
74
- .default({}),
75
- securityAgent: z
76
- .object({
77
- enabled: z.boolean().default(true),
78
- priority: z.number().min(1).max(10).default(9),
79
- capabilities: z.array(z.string()).default(['acl', 'security-scan', 'compliance']),
80
- })
81
- .default({}),
82
- testAgent: z
83
- .object({
84
- enabled: z.boolean().default(true),
85
- priority: z.number().min(1).max(10).default(6),
86
- capabilities: z
87
- .array(z.string())
88
- .default(['unit-test', 'integration-test', 'performance-test']),
89
- })
90
- .default({}),
91
- })
92
- .default({}),
93
- })
94
- .default({}),
95
-
96
- // Memory system configuration
97
- memory: z
98
- .object({
99
- dbPath: z.string().optional(),
100
- schema: z
101
- .object({
102
- version: z.string().default('1.0.0'),
103
- autoMigrate: z.boolean().default(true),
104
- })
105
- .default({}),
106
- cache: z
107
- .object({
108
- enabled: z.boolean().default(true),
109
- maxSize: z.number().min(10).default(100), // MB
110
- ttl: z.number().min(60000).default(3600000), // 1 hour
111
- })
112
- .default({}),
113
- ttl: z
114
- .object({
115
- default: z.number().min(3600000).default(86400000), // 24 hours
116
- session: z.number().min(3600000).default(86400000), // 24 hours
117
- artifact: z.number().min(86400000).default(604800000), // 7 days
118
- metric: z.number().min(86400000).default(2592000000), // 30 days
119
- })
120
- .default({}),
121
- cleanup: z
122
- .object({
123
- enabled: z.boolean().default(true),
124
- interval: z.number().min(3600000).default(86400000), // 24 hours
125
- retentionDays: z.number().min(7).default(30),
126
- })
127
- .default({}),
128
- })
129
- .default({}),
130
-
131
- // MCP server configuration
132
- mcp: z
133
- .object({
134
- servers: z
135
- .object({
136
- deployment: z
137
- .object({
138
- enabled: z.boolean().default(true),
139
- port: z.number().min(3000).max(65535).default(3001),
140
- host: z.string().default('localhost'),
141
- })
142
- .default({}),
143
- intelligent: z
144
- .object({
145
- enabled: z.boolean().default(true),
146
- port: z.number().min(3000).max(65535).default(3002),
147
- host: z.string().default('localhost'),
148
- })
149
- .default({}),
150
- operations: z
151
- .object({
152
- enabled: z.boolean().default(true),
153
- port: z.number().min(3000).max(65535).default(3003),
154
- host: z.string().default('localhost'),
155
- })
156
- .default({}),
157
- flowComposer: z
158
- .object({
159
- enabled: z.boolean().default(true),
160
- port: z.number().min(3000).max(65535).default(3004),
161
- host: z.string().default('localhost'),
162
- })
163
- .default({}),
164
- platformDevelopment: z
165
- .object({
166
- enabled: z.boolean().default(true),
167
- port: z.number().min(3000).max(65535).default(3005),
168
- host: z.string().default('localhost'),
169
- })
170
- .default({}),
171
- })
172
- .default({}),
173
- transport: z
174
- .object({
175
- type: z.enum(['stdio', 'http', 'websocket']).default('stdio'),
176
- timeout: z.number().min(0).default(30000), // Allow 0 to disable timeout, or set via MCP_TIMEOUT env var
177
- retryAttempts: z.number().min(1).max(10).default(3),
178
- retryDelay: z.number().min(1000).default(5000),
179
- })
180
- .default({}),
181
- authentication: z
182
- .object({
183
- required: z.boolean().default(true),
184
- tokenExpiry: z.number().min(3600000).default(86400000), // 24 hours
185
- })
186
- .default({}),
187
- })
188
- .default({}),
189
-
190
- // ServiceNow connection settings
191
- servicenow: z
192
- .object({
193
- instance: z.string().optional(),
194
- clientId: z.string().optional(),
195
- clientSecret: z.string().optional(),
196
- username: z.string().optional(),
197
- password: z.string().optional(),
198
- authType: z.enum(['oauth', 'basic']).default('oauth'),
199
- apiVersion: z.string().default('now'),
200
- timeout: z.number().min(5000).default(60000),
201
- retryConfig: z
202
- .object({
203
- maxRetries: z.number().min(0).max(10).default(3),
204
- retryDelay: z.number().min(1000).default(2000),
205
- backoffMultiplier: z.number().min(1).max(5).default(2),
206
- })
207
- .default({}),
208
- cache: z
209
- .object({
210
- enabled: z.boolean().default(true),
211
- ttl: z.number().min(60000).default(300000), // 5 minutes
212
- maxSize: z.number().min(10).default(50), // MB
213
- })
214
- .default({}),
215
- oauth: z
216
- .object({
217
- redirectHost: z.string().default('localhost'),
218
- redirectPort: z.number().min(3000).max(65535).default(3005),
219
- redirectPath: z.string().default('/callback'),
220
- })
221
- .default({}),
222
- })
223
- .default({}),
224
-
225
- // Monitoring configuration
226
- monitoring: z
227
- .object({
228
- performance: z
229
- .object({
230
- enabled: z.boolean().default(true),
231
- sampleRate: z.number().min(0).max(1).default(1),
232
- metricsRetention: z.number().min(86400000).default(604800000), // 7 days
233
- aggregationInterval: z.number().min(60000).default(300000), // 5 minutes
234
- })
235
- .default({}),
236
- health: z
237
- .object({
238
- enabled: z.boolean().default(true),
239
- checkInterval: z.number().min(30000).default(60000), // 1 minute
240
- endpoints: z.array(z.string()).default([]),
241
- thresholds: z
242
- .object({
243
- memoryUsage: z.number().min(0).max(1).default(0.8), // 80%
244
- cpuUsage: z.number().min(0).max(1).default(0.8), // 80%
245
- errorRate: z.number().min(0).max(1).default(0.05), // 5%
246
- })
247
- .default({}),
248
- })
249
- .default({}),
250
- alerts: z
251
- .object({
252
- enabled: z.boolean().default(true),
253
- channels: z.array(z.enum(['console', 'file', 'webhook'])).default(['console']),
254
- webhookUrl: z.string().url().optional(),
255
- severityThreshold: z.enum(['info', 'warn', 'error']).default('warn'),
256
- })
257
- .default({}),
258
- })
259
- .default({}),
260
-
261
- // Health check configuration
262
- health: z
263
- .object({
264
- checks: z
265
- .object({
266
- memory: z.boolean().default(true),
267
- mcp: z.boolean().default(true),
268
- servicenow: z.boolean().default(true),
269
- queen: z.boolean().default(true),
270
- })
271
- .default({}),
272
- thresholds: z
273
- .object({
274
- responseTime: z.number().min(100).default(5000), // ms
275
- memoryUsage: z.number().min(100).default(1000), // MB
276
- queueSize: z.number().min(10).default(100),
277
- })
278
- .default({}),
279
- })
280
- .default({}),
281
-
282
- // Feature flags
283
- features: z
284
- .object({
285
- autoPermissions: z.boolean().default(false),
286
- smartDiscovery: z.boolean().default(true),
287
- liveTesting: z.boolean().default(true),
288
- autoDeploy: z.boolean().default(true),
289
- autoRollback: z.boolean().default(true),
290
- sharedMemory: z.boolean().default(true),
291
- progressMonitoring: z.boolean().default(true),
292
- neuralPatterns: z.boolean().default(false),
293
- cognitiveAnalysis: z.boolean().default(false),
294
- })
295
- .default({}),
296
- });
297
-
298
- export type ISnowFlowConfig = z.infer<typeof ConfigSchema>;
299
-
300
- export class SnowFlowConfig {
301
- private config: ISnowFlowConfig;
302
- private configPath: string;
303
-
304
- constructor(overrides?: Partial<ISnowFlowConfig>) {
305
- // Determine config path
306
- this.configPath = path.join(os.homedir(), '.snow-flow', 'config.json');
307
-
308
- // Load config from file if exists
309
- const fileConfig = this.loadFromFile();
310
-
311
- // Load environment variables
312
- const envConfig = this.loadFromEnvironment();
313
-
314
- // Merge configurations: defaults < file < env < overrides
315
- const mergedConfig = this.mergeConfigs(
316
- this.getDefaults(),
317
- fileConfig,
318
- envConfig,
319
- overrides || {}
320
- );
321
-
322
- // Validate configuration
323
- const result = ConfigSchema.safeParse(mergedConfig);
324
- if (!result.success) {
325
- throw new Error(`Invalid configuration: ${JSON.stringify(result.error.errors)}`);
326
- }
327
-
328
- this.config = result.data;
329
-
330
- // Ensure data directories exist
331
- this.ensureDirectories();
332
- }
333
-
334
- /**
335
- * Get the current configuration
336
- */
337
- get(): ISnowFlowConfig {
338
- return { ...this.config };
339
- }
340
-
341
- /**
342
- * Update configuration
343
- */
344
- update(updates: Partial<ISnowFlowConfig>): void {
345
- const mergedConfig = this.mergeConfigs(this.config, updates);
346
-
347
- const result = ConfigSchema.safeParse(mergedConfig);
348
- if (!result.success) {
349
- throw new Error(`Invalid configuration update: ${JSON.stringify(result.error.errors)}`);
350
- }
351
-
352
- this.config = result.data;
353
- this.saveToFile();
354
- }
355
-
356
- /**
357
- * Get a specific configuration value
358
- */
359
- getValue(path: string): any {
360
- const keys = path.split('.');
361
- let value: any = this.config;
362
-
363
- for (const key of keys) {
364
- if (value && typeof value === 'object' && key in value) {
365
- value = value[key];
366
- } else {
367
- return undefined;
368
- }
369
- }
370
-
371
- return value;
372
- }
373
-
374
- /**
375
- * Set a specific configuration value
376
- */
377
- setValue(path: string, value: any): void {
378
- const keys = path.split('.');
379
- const lastKey = keys.pop()!;
380
- let obj: any = this.config;
381
-
382
- for (const key of keys) {
383
- if (!obj[key] || typeof obj[key] !== 'object') {
384
- obj[key] = {};
385
- }
386
- obj = obj[key];
387
- }
388
-
389
- obj[lastKey] = value;
390
- this.update(this.config);
391
- }
392
-
393
- /**
394
- * Save configuration to file
395
- */
396
- saveToFile(): void {
397
- try {
398
- const dir = path.dirname(this.configPath);
399
- if (!fs.existsSync(dir)) {
400
- fs.mkdirSync(dir, { recursive: true });
401
- }
402
-
403
- fs.writeFileSync(this.configPath, JSON.stringify(this.config, null, 2), 'utf8');
404
- } catch (error) {
405
- console.error('Failed to save configuration:', error);
406
- }
407
- }
408
-
409
- /**
410
- * Load configuration from file
411
- */
412
- private loadFromFile(): Partial<ISnowFlowConfig> {
413
- try {
414
- if (fs.existsSync(this.configPath)) {
415
- const content = fs.readFileSync(this.configPath, 'utf8');
416
- return JSON.parse(content);
417
- }
418
- } catch (error) {
419
- console.error('Failed to load configuration from file:', error);
420
- }
421
- return {};
422
- }
423
-
424
- /**
425
- * Load configuration from environment variables
426
- */
427
- private loadFromEnvironment(): Partial<ISnowFlowConfig> {
428
- const env: any = {};
429
-
430
- // ServiceNow settings
431
- if (process.env.SNOW_INSTANCE) {
432
- env.servicenow = env.servicenow || {};
433
- env.servicenow.instance = process.env.SNOW_INSTANCE;
434
- }
435
- if (process.env.SNOW_CLIENT_ID) {
436
- env.servicenow = env.servicenow || {};
437
- env.servicenow.clientId = process.env.SNOW_CLIENT_ID;
438
- }
439
- if (process.env.SNOW_CLIENT_SECRET) {
440
- env.servicenow = env.servicenow || {};
441
- env.servicenow.clientSecret = process.env.SNOW_CLIENT_SECRET;
442
- }
443
- if (process.env.SNOW_USERNAME) {
444
- env.servicenow = env.servicenow || {};
445
- env.servicenow.username = process.env.SNOW_USERNAME;
446
- }
447
- if (process.env.SNOW_PASSWORD) {
448
- env.servicenow = env.servicenow || {};
449
- env.servicenow.password = process.env.SNOW_PASSWORD;
450
- }
451
- if (process.env.SNOW_AUTH_TYPE) {
452
- env.servicenow = env.servicenow || {};
453
- env.servicenow.authType = process.env.SNOW_AUTH_TYPE;
454
- }
455
- if (process.env.SNOW_API_VERSION) {
456
- env.servicenow = env.servicenow || {};
457
- env.servicenow.apiVersion = process.env.SNOW_API_VERSION;
458
- }
459
- if (process.env.SNOW_REQUEST_TIMEOUT) {
460
- env.servicenow = env.servicenow || {};
461
- const value = parseInt(process.env.SNOW_REQUEST_TIMEOUT);
462
- if (!isNaN(value)) {
463
- env.servicenow.timeout = value;
464
- }
465
- }
466
- if (process.env.SNOW_MAX_RETRIES) {
467
- env.servicenow = env.servicenow || {};
468
- env.servicenow.retryConfig = env.servicenow.retryConfig || {};
469
- const value = parseInt(process.env.SNOW_MAX_RETRIES);
470
- if (!isNaN(value)) {
471
- env.servicenow.retryConfig.maxRetries = value;
472
- }
473
- }
474
- if (process.env.SNOW_RETRY_DELAY) {
475
- env.servicenow = env.servicenow || {};
476
- env.servicenow.retryConfig = env.servicenow.retryConfig || {};
477
- const value = parseInt(process.env.SNOW_RETRY_DELAY);
478
- if (!isNaN(value)) {
479
- env.servicenow.retryConfig.retryDelay = value;
480
- }
481
- }
482
- if (process.env.SNOW_REDIRECT_HOST) {
483
- env.servicenow = env.servicenow || {};
484
- env.servicenow.oauth = env.servicenow.oauth || {};
485
- env.servicenow.oauth.redirectHost = process.env.SNOW_REDIRECT_HOST;
486
- }
487
- if (process.env.SNOW_REDIRECT_PORT) {
488
- env.servicenow = env.servicenow || {};
489
- env.servicenow.oauth = env.servicenow.oauth || {};
490
- const value = parseInt(process.env.SNOW_REDIRECT_PORT);
491
- if (!isNaN(value)) {
492
- env.servicenow.oauth.redirectPort = value;
493
- }
494
- }
495
- if (process.env.SNOW_REDIRECT_PATH) {
496
- env.servicenow = env.servicenow || {};
497
- env.servicenow.oauth = env.servicenow.oauth || {};
498
- env.servicenow.oauth.redirectPath = process.env.SNOW_REDIRECT_PATH;
499
- }
500
-
501
- // System settings
502
- if (process.env.SNOW_FLOW_ENV) {
503
- env.system = env.system || {};
504
- env.system.environment = process.env.SNOW_FLOW_ENV;
505
- }
506
- if (process.env.SNOW_FLOW_LOG_LEVEL) {
507
- env.system = env.system || {};
508
- env.system.logLevel = process.env.SNOW_FLOW_LOG_LEVEL;
509
- }
510
- if (process.env.SNOW_FLOW_DATA_DIR) {
511
- env.system = env.system || {};
512
- env.system.dataDir = process.env.SNOW_FLOW_DATA_DIR;
513
- }
514
- if (process.env.SNOW_FLOW_MAX_CONCURRENT_OPS) {
515
- env.system = env.system || {};
516
- const value = parseInt(process.env.SNOW_FLOW_MAX_CONCURRENT_OPS);
517
- if (!isNaN(value)) {
518
- env.system.maxConcurrentOperations = value;
519
- }
520
- }
521
- if (process.env.SNOW_FLOW_SESSION_TIMEOUT) {
522
- env.system = env.system || {};
523
- const value = parseInt(process.env.SNOW_FLOW_SESSION_TIMEOUT);
524
- if (!isNaN(value)) {
525
- env.system.sessionTimeout = value;
526
- }
527
- }
528
-
529
- // Agent configuration
530
- if (process.env.SNOW_FLOW_MAX_WORKER_AGENTS) {
531
- env.agents = env.agents || {};
532
- env.agents.queen = env.agents.queen || {};
533
- const value = parseInt(process.env.SNOW_FLOW_MAX_WORKER_AGENTS);
534
- if (!isNaN(value)) {
535
- env.agents.queen.maxWorkerAgents = value;
536
- }
537
- }
538
- if (process.env.SNOW_FLOW_SPAWN_TIMEOUT) {
539
- env.agents = env.agents || {};
540
- env.agents.queen = env.agents.queen || {};
541
- const value = parseInt(process.env.SNOW_FLOW_SPAWN_TIMEOUT);
542
- if (!isNaN(value)) {
543
- env.agents.queen.spawnTimeout = value;
544
- }
545
- }
546
- if (process.env.SNOW_FLOW_COORDINATION_INTERVAL) {
547
- env.agents = env.agents || {};
548
- env.agents.queen = env.agents.queen || {};
549
- const value = parseInt(process.env.SNOW_FLOW_COORDINATION_INTERVAL);
550
-
551
- if (!isNaN(value)) {
552
- env.agents.queen.coordinationInterval = value;
553
- }
554
- }
555
- if (process.env.SNOW_FLOW_RETRY_ATTEMPTS) {
556
- env.agents = env.agents || {};
557
- env.agents.queen = env.agents.queen || {};
558
- const value = parseInt(process.env.SNOW_FLOW_RETRY_ATTEMPTS);
559
-
560
- if (!isNaN(value)) {
561
- env.agents.queen.retryAttempts = value;
562
- }
563
- }
564
- if (process.env.SNOW_FLOW_HEARTBEAT_INTERVAL) {
565
- env.agents = env.agents || {};
566
- env.agents.worker = env.agents.worker || {};
567
- const value = parseInt(process.env.SNOW_FLOW_HEARTBEAT_INTERVAL);
568
-
569
- if (!isNaN(value)) {
570
- env.agents.worker.heartbeatInterval = value;
571
- }
572
- }
573
- if (process.env.SNOW_FLOW_TASK_TIMEOUT) {
574
- env.agents = env.agents || {};
575
- env.agents.worker = env.agents.worker || {};
576
- const value = parseInt(process.env.SNOW_FLOW_TASK_TIMEOUT);
577
-
578
- if (!isNaN(value)) {
579
- env.agents.worker.taskTimeout = value;
580
- }
581
- }
582
- if (process.env.SNOW_FLOW_MAX_MEMORY_USAGE) {
583
- env.agents = env.agents || {};
584
- env.agents.worker = env.agents.worker || {};
585
- const value = parseInt(process.env.SNOW_FLOW_MAX_MEMORY_USAGE);
586
-
587
- if (!isNaN(value)) {
588
- env.agents.worker.maxMemoryUsage = value;
589
- }
590
- }
591
- if (process.env.SNOW_FLOW_AUTO_SHUTDOWN_IDLE) {
592
- env.agents = env.agents || {};
593
- env.agents.worker = env.agents.worker || {};
594
- const value = parseInt(process.env.SNOW_FLOW_AUTO_SHUTDOWN_IDLE);
595
-
596
- if (!isNaN(value)) {
597
- env.agents.worker.autoShutdownIdle = value;
598
- }
599
- }
600
-
601
- // MCP server configuration
602
- if (process.env.MCP_DEPLOYMENT_PORT) {
603
- env.mcp = env.mcp || {};
604
- env.mcp.servers = env.mcp.servers || {};
605
- env.mcp.servers.deployment = env.mcp.servers.deployment || {};
606
- const value = parseInt(process.env.MCP_DEPLOYMENT_PORT);
607
-
608
- if (!isNaN(value)) {
609
- env.mcp.servers.deployment.port = value;
610
- }
611
- }
612
- if (process.env.MCP_INTELLIGENT_PORT) {
613
- env.mcp = env.mcp || {};
614
- env.mcp.servers = env.mcp.servers || {};
615
- env.mcp.servers.intelligent = env.mcp.servers.intelligent || {};
616
- const value = parseInt(process.env.MCP_INTELLIGENT_PORT);
617
-
618
- if (!isNaN(value)) {
619
- env.mcp.servers.intelligent.port = value;
620
- }
621
- }
622
- if (process.env.MCP_OPERATIONS_PORT) {
623
- env.mcp = env.mcp || {};
624
- env.mcp.servers = env.mcp.servers || {};
625
- env.mcp.servers.operations = env.mcp.servers.operations || {};
626
- const value = parseInt(process.env.MCP_OPERATIONS_PORT);
627
-
628
- if (!isNaN(value)) {
629
- env.mcp.servers.operations.port = value;
630
- }
631
- }
632
- if (process.env.MCP_FLOW_COMPOSER_PORT) {
633
- env.mcp = env.mcp || {};
634
- env.mcp.servers = env.mcp.servers || {};
635
- env.mcp.servers.flowComposer = env.mcp.servers.flowComposer || {};
636
- const value = parseInt(process.env.MCP_FLOW_COMPOSER_PORT);
637
-
638
- if (!isNaN(value)) {
639
- env.mcp.servers.flowComposer.port = value;
640
- }
641
- }
642
- if (process.env.MCP_PLATFORM_DEV_PORT) {
643
- env.mcp = env.mcp || {};
644
- env.mcp.servers = env.mcp.servers || {};
645
- env.mcp.servers.platformDevelopment = env.mcp.servers.platformDevelopment || {};
646
- const value = parseInt(process.env.MCP_PLATFORM_DEV_PORT);
647
-
648
- if (!isNaN(value)) {
649
- env.mcp.servers.platformDevelopment.port = value;
650
- }
651
- }
652
- if (process.env.MCP_HOST) {
653
- env.mcp = env.mcp || {};
654
- env.mcp.servers = env.mcp.servers || {};
655
- // Apply to all servers
656
- ['deployment', 'intelligent', 'operations', 'flowComposer', 'platformDevelopment'].forEach(
657
- (server) => {
658
- env.mcp.servers[server] = env.mcp.servers[server] || {};
659
- env.mcp.servers[server].host = process.env.MCP_HOST;
660
- }
661
- );
662
- }
663
- if (process.env.MCP_TIMEOUT) {
664
- env.mcp = env.mcp || {};
665
- env.mcp.transport = env.mcp.transport || {};
666
- const value = parseInt(process.env.MCP_TIMEOUT);
667
-
668
- if (!isNaN(value)) {
669
- env.mcp.transport.timeout = value;
670
- }
671
- }
672
- if (process.env.MCP_RETRY_ATTEMPTS) {
673
- env.mcp = env.mcp || {};
674
- env.mcp.transport = env.mcp.transport || {};
675
- const value = parseInt(process.env.MCP_RETRY_ATTEMPTS);
676
-
677
- if (!isNaN(value)) {
678
- env.mcp.transport.retryAttempts = value;
679
- }
680
- }
681
- if (process.env.MCP_RETRY_DELAY) {
682
- env.mcp = env.mcp || {};
683
- env.mcp.transport = env.mcp.transport || {};
684
- const value = parseInt(process.env.MCP_RETRY_DELAY);
685
-
686
- if (!isNaN(value)) {
687
- env.mcp.transport.retryDelay = value;
688
- }
689
- }
690
- if (process.env.MCP_AUTH_TOKEN_EXPIRY) {
691
- env.mcp = env.mcp || {};
692
- env.mcp.authentication = env.mcp.authentication || {};
693
- const value = parseInt(process.env.MCP_AUTH_TOKEN_EXPIRY);
694
-
695
- if (!isNaN(value)) {
696
- env.mcp.authentication.tokenExpiry = value;
697
- }
698
- }
699
-
700
- // Memory system configuration
701
- if (process.env.SNOW_FLOW_DB_PATH) {
702
- env.memory = env.memory || {};
703
- env.memory.dbPath = process.env.SNOW_FLOW_DB_PATH;
704
- }
705
- if (process.env.SNOW_FLOW_CACHE_ENABLED) {
706
- env.memory = env.memory || {};
707
- env.memory.cache = env.memory.cache || {};
708
- env.memory.cache.enabled = process.env.SNOW_FLOW_CACHE_ENABLED === 'true';
709
- }
710
- if (process.env.SNOW_FLOW_CACHE_MAX_SIZE) {
711
- env.memory = env.memory || {};
712
- env.memory.cache = env.memory.cache || {};
713
- const value = parseInt(process.env.SNOW_FLOW_CACHE_MAX_SIZE);
714
-
715
- if (!isNaN(value)) {
716
- env.memory.cache.maxSize = value;
717
- }
718
- }
719
- if (process.env.SNOW_FLOW_CACHE_TTL) {
720
- env.memory = env.memory || {};
721
- env.memory.cache = env.memory.cache || {};
722
- const value = parseInt(process.env.SNOW_FLOW_CACHE_TTL);
723
-
724
- if (!isNaN(value)) {
725
- env.memory.cache.ttl = value;
726
- }
727
- }
728
- if (process.env.SNOW_FLOW_DEFAULT_TTL) {
729
- env.memory = env.memory || {};
730
- env.memory.ttl = env.memory.ttl || {};
731
- const value = parseInt(process.env.SNOW_FLOW_DEFAULT_TTL);
732
-
733
- if (!isNaN(value)) {
734
- env.memory.ttl.default = value;
735
- }
736
- }
737
- if (process.env.SNOW_FLOW_SESSION_TTL) {
738
- env.memory = env.memory || {};
739
- env.memory.ttl = env.memory.ttl || {};
740
- const value = parseInt(process.env.SNOW_FLOW_SESSION_TTL);
741
-
742
- if (!isNaN(value)) {
743
- env.memory.ttl.session = value;
744
- }
745
- }
746
- if (process.env.SNOW_FLOW_ARTIFACT_TTL) {
747
- env.memory = env.memory || {};
748
- env.memory.ttl = env.memory.ttl || {};
749
- const value = parseInt(process.env.SNOW_FLOW_ARTIFACT_TTL);
750
-
751
- if (!isNaN(value)) {
752
- env.memory.ttl.artifact = value;
753
- }
754
- }
755
- if (process.env.SNOW_FLOW_METRIC_TTL) {
756
- env.memory = env.memory || {};
757
- env.memory.ttl = env.memory.ttl || {};
758
- const value = parseInt(process.env.SNOW_FLOW_METRIC_TTL);
759
-
760
- if (!isNaN(value)) {
761
- env.memory.ttl.metric = value;
762
- }
763
- }
764
- if (process.env.SNOW_FLOW_CLEANUP_INTERVAL) {
765
- env.memory = env.memory || {};
766
- env.memory.cleanup = env.memory.cleanup || {};
767
- const value = parseInt(process.env.SNOW_FLOW_CLEANUP_INTERVAL);
768
-
769
- if (!isNaN(value)) {
770
- env.memory.cleanup.interval = value;
771
- }
772
- }
773
- if (process.env.SNOW_FLOW_RETENTION_DAYS) {
774
- env.memory = env.memory || {};
775
- env.memory.cleanup = env.memory.cleanup || {};
776
- const value = parseInt(process.env.SNOW_FLOW_RETENTION_DAYS);
777
-
778
- if (!isNaN(value)) {
779
- env.memory.cleanup.retentionDays = value;
780
- }
781
- }
782
-
783
- // Monitoring configuration
784
- if (process.env.SNOW_FLOW_PERFORMANCE_ENABLED) {
785
- env.monitoring = env.monitoring || {};
786
- env.monitoring.performance = env.monitoring.performance || {};
787
- env.monitoring.performance.enabled = process.env.SNOW_FLOW_PERFORMANCE_ENABLED === 'true';
788
- }
789
- if (process.env.SNOW_FLOW_SAMPLE_RATE) {
790
- env.monitoring = env.monitoring || {};
791
- env.monitoring.performance = env.monitoring.performance || {};
792
- const floatValue = parseFloat(process.env.SNOW_FLOW_SAMPLE_RATE);
793
-
794
- if (!isNaN(floatValue)) {
795
- env.monitoring.performance.sampleRate = floatValue;
796
- }
797
- }
798
- if (process.env.SNOW_FLOW_METRICS_RETENTION) {
799
- env.monitoring = env.monitoring || {};
800
- env.monitoring.performance = env.monitoring.performance || {};
801
- const value = parseInt(process.env.SNOW_FLOW_METRICS_RETENTION);
802
-
803
- if (!isNaN(value)) {
804
- env.monitoring.performance.metricsRetention = value;
805
- }
806
- }
807
- if (process.env.SNOW_FLOW_AGGREGATION_INTERVAL) {
808
- env.monitoring = env.monitoring || {};
809
- env.monitoring.performance = env.monitoring.performance || {};
810
- const value = parseInt(process.env.SNOW_FLOW_AGGREGATION_INTERVAL);
811
-
812
- if (!isNaN(value)) {
813
- env.monitoring.performance.aggregationInterval = value;
814
- }
815
- }
816
- if (process.env.SNOW_FLOW_HEALTH_CHECK_INTERVAL) {
817
- env.monitoring = env.monitoring || {};
818
- env.monitoring.health = env.monitoring.health || {};
819
- const value = parseInt(process.env.SNOW_FLOW_HEALTH_CHECK_INTERVAL);
820
-
821
- if (!isNaN(value)) {
822
- env.monitoring.health.checkInterval = value;
823
- }
824
- }
825
- if (process.env.SNOW_FLOW_MEMORY_THRESHOLD) {
826
- env.monitoring = env.monitoring || {};
827
- env.monitoring.health = env.monitoring.health || {};
828
- env.monitoring.health.thresholds = env.monitoring.health.thresholds || {};
829
- const floatValue = parseFloat(process.env.SNOW_FLOW_MEMORY_THRESHOLD);
830
-
831
- if (!isNaN(floatValue)) {
832
- env.monitoring.health.thresholds.memoryUsage = floatValue;
833
- }
834
- }
835
- if (process.env.SNOW_FLOW_CPU_THRESHOLD) {
836
- env.monitoring = env.monitoring || {};
837
- env.monitoring.health = env.monitoring.health || {};
838
- env.monitoring.health.thresholds = env.monitoring.health.thresholds || {};
839
- const floatValue = parseFloat(process.env.SNOW_FLOW_CPU_THRESHOLD);
840
-
841
- if (!isNaN(floatValue)) {
842
- env.monitoring.health.thresholds.cpuUsage = floatValue;
843
- }
844
- }
845
- if (process.env.SNOW_FLOW_ERROR_RATE_THRESHOLD) {
846
- env.monitoring = env.monitoring || {};
847
- env.monitoring.health = env.monitoring.health || {};
848
- env.monitoring.health.thresholds = env.monitoring.health.thresholds || {};
849
- const floatValue = parseFloat(process.env.SNOW_FLOW_ERROR_RATE_THRESHOLD);
850
-
851
- if (!isNaN(floatValue)) {
852
- env.monitoring.health.thresholds.errorRate = floatValue;
853
- }
854
- }
855
- if (process.env.SNOW_FLOW_WEBHOOK_URL) {
856
- env.monitoring = env.monitoring || {};
857
- env.monitoring.alerts = env.monitoring.alerts || {};
858
- env.monitoring.alerts.webhookUrl = process.env.SNOW_FLOW_WEBHOOK_URL;
859
- }
860
- if (process.env.SNOW_FLOW_ALERT_SEVERITY) {
861
- env.monitoring = env.monitoring || {};
862
- env.monitoring.alerts = env.monitoring.alerts || {};
863
- env.monitoring.alerts.severityThreshold = process.env.SNOW_FLOW_ALERT_SEVERITY;
864
- }
865
-
866
- // Health check thresholds
867
- if (process.env.SNOW_FLOW_RESPONSE_TIME_THRESHOLD) {
868
- env.health = env.health || {};
869
- env.health.thresholds = env.health.thresholds || {};
870
- const value = parseInt(process.env.SNOW_FLOW_RESPONSE_TIME_THRESHOLD);
871
-
872
- if (!isNaN(value)) {
873
- env.health.thresholds.responseTime = value;
874
- }
875
- }
876
- if (process.env.SNOW_FLOW_HEALTH_MEMORY_THRESHOLD) {
877
- env.health = env.health || {};
878
- env.health.thresholds = env.health.thresholds || {};
879
- const value = parseInt(process.env.SNOW_FLOW_HEALTH_MEMORY_THRESHOLD);
880
-
881
- if (!isNaN(value)) {
882
- env.health.thresholds.memoryUsage = value;
883
- }
884
- }
885
- if (process.env.SNOW_FLOW_QUEUE_SIZE_THRESHOLD) {
886
- env.health = env.health || {};
887
- env.health.thresholds = env.health.thresholds || {};
888
- const value = parseInt(process.env.SNOW_FLOW_QUEUE_SIZE_THRESHOLD);
889
-
890
- if (!isNaN(value)) {
891
- env.health.thresholds.queueSize = value;
892
- }
893
- }
894
-
895
- // Feature flags
896
- if (process.env.SNOW_FLOW_AUTO_PERMISSIONS) {
897
- env.features = env.features || {};
898
- env.features.autoPermissions = process.env.SNOW_FLOW_AUTO_PERMISSIONS === 'true';
899
- }
900
- if (process.env.SNOW_FLOW_SMART_DISCOVERY) {
901
- env.features = env.features || {};
902
- env.features.smartDiscovery = process.env.SNOW_FLOW_SMART_DISCOVERY === 'true';
903
- }
904
- if (process.env.SNOW_FLOW_LIVE_TESTING) {
905
- env.features = env.features || {};
906
- env.features.liveTesting = process.env.SNOW_FLOW_LIVE_TESTING === 'true';
907
- }
908
- if (process.env.SNOW_FLOW_AUTO_DEPLOY) {
909
- env.features = env.features || {};
910
- env.features.autoDeploy = process.env.SNOW_FLOW_AUTO_DEPLOY === 'true';
911
- }
912
- if (process.env.SNOW_FLOW_AUTO_ROLLBACK) {
913
- env.features = env.features || {};
914
- env.features.autoRollback = process.env.SNOW_FLOW_AUTO_ROLLBACK === 'true';
915
- }
916
- if (process.env.SNOW_FLOW_SHARED_MEMORY) {
917
- env.features = env.features || {};
918
- env.features.sharedMemory = process.env.SNOW_FLOW_SHARED_MEMORY === 'true';
919
- }
920
- if (process.env.SNOW_FLOW_PROGRESS_MONITORING) {
921
- env.features = env.features || {};
922
- env.features.progressMonitoring = process.env.SNOW_FLOW_PROGRESS_MONITORING === 'true';
923
- }
924
- if (process.env.SNOW_FLOW_NEURAL_PATTERNS) {
925
- env.features = env.features || {};
926
- env.features.neuralPatterns = process.env.SNOW_FLOW_NEURAL_PATTERNS === 'true';
927
- }
928
- if (process.env.SNOW_FLOW_COGNITIVE_ANALYSIS) {
929
- env.features = env.features || {};
930
- env.features.cognitiveAnalysis = process.env.SNOW_FLOW_COGNITIVE_ANALYSIS === 'true';
931
- }
932
-
933
- return env;
934
- }
935
-
936
- /**
937
- * Get default configuration
938
- */
939
- private getDefaults(): ISnowFlowConfig {
940
- return ConfigSchema.parse({});
941
- }
942
-
943
- /**
944
- * Merge multiple configuration objects
945
- */
946
- private mergeConfigs(...configs: Array<Partial<ISnowFlowConfig>>): ISnowFlowConfig {
947
- const merged: any = {};
948
-
949
- for (const config of configs) {
950
- this.deepMerge(merged, config);
951
- }
952
-
953
- return merged as ISnowFlowConfig;
954
- }
955
-
956
- /**
957
- * Deep merge objects
958
- */
959
- private deepMerge(target: any, source: any): void {
960
- for (const key in source) {
961
- if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
962
- if (!target[key] || typeof target[key] !== 'object') {
963
- target[key] = {};
964
- }
965
- this.deepMerge(target[key], source[key]);
966
- } else {
967
- target[key] = source[key];
968
- }
969
- }
970
- }
971
-
972
- /**
973
- * Ensure required directories exist
974
- */
975
- private ensureDirectories(): void {
976
- const dirs = [
977
- this.config.system.dataDir,
978
- path.join(this.config.system.dataDir, 'memory'),
979
- path.join(this.config.system.dataDir, 'logs'),
980
- path.join(this.config.system.dataDir, 'cache'),
981
- path.join(this.config.system.dataDir, 'sessions'),
982
- ];
983
-
984
- for (const dir of dirs) {
985
- if (!fs.existsSync(dir)) {
986
- fs.mkdirSync(dir, { recursive: true });
987
- }
988
- }
989
- }
990
-
991
- // Convenience getters
992
- get system() {
993
- return this.config.system;
994
- }
995
- get agents() {
996
- return this.config.agents;
997
- }
998
- get memory() {
999
- return this.config.memory;
1000
- }
1001
- get mcp() {
1002
- return this.config.mcp;
1003
- }
1004
- get servicenow() {
1005
- return this.config.servicenow;
1006
- }
1007
- get monitoring() {
1008
- return this.config.monitoring;
1009
- }
1010
- get health() {
1011
- return this.config.health;
1012
- }
1013
- get features() {
1014
- return this.config.features;
1015
- }
1016
- }
1017
-
1018
- // Export singleton instance
1019
- export const snowFlowConfig = new SnowFlowConfig();