snow-flow 2.0.2 → 2.0.4

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