snow-flow 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/snow-flow-config.d.ts +1492 -0
- package/dist/config/snow-flow-config.js +938 -0
- package/dist/coordination/coordination-engine.d.ts +41 -0
- package/dist/coordination/coordination-engine.js +324 -0
- package/dist/coordination/coordination.test.d.ts +6 -0
- package/dist/coordination/example.d.ts +31 -0
- package/dist/coordination/example.js +394 -0
- package/dist/coordination/execution-patterns.d.ts +43 -0
- package/dist/coordination/execution-patterns.js +507 -0
- package/dist/coordination/factory.d.ts +94 -0
- package/dist/coordination/factory.js +433 -0
- package/dist/coordination/index.d.ts +71 -0
- package/dist/coordination/index.js +135 -0
- package/dist/coordination/progress-monitor.d.ts +71 -0
- package/dist/coordination/progress-monitor.js +505 -0
- package/dist/coordination/quality-gates.d.ts +124 -0
- package/dist/coordination/quality-gates.js +577 -0
- package/dist/coordination/shared-memory.d.ts +39 -0
- package/dist/coordination/shared-memory.js +289 -0
- package/dist/coordination/task-dependencies.d.ts +50 -0
- package/dist/coordination/task-dependencies.js +407 -0
- package/dist/coordination/team-coordinator.d.ts +59 -0
- package/dist/coordination/team-coordinator.js +550 -0
- package/dist/coordination/types.d.ts +152 -0
- package/dist/coordination/types.js +3 -0
- package/dist/memory/memory-system.d.ts +1 -0
- package/dist/memory/memory-system.js +21 -2
- package/memory/claude-flow-data.json +5 -0
- package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +30 -0
- package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +36 -0
- package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +30 -0
- package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +30 -0
- package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +55 -0
- package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +55 -0
- package/memory/sessions/README.md +32 -0
- package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +9 -0
- package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +9 -0
- package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +8 -0
- package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +9 -0
- package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +9 -0
- package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +9 -0
- package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +58 -0
- package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +9 -0
- package/package.json +1 -1
- package/reports/swarm-auto-centralized-1752649029776.json +13 -0
- package/servicenow/widgets/openai_incident_classifier/client_controller.js +284 -0
- package/servicenow/widgets/openai_incident_classifier/server_script.js +314 -0
- package/servicenow/widgets/openai_incident_classifier/style.css +354 -0
- package/servicenow/widgets/openai_incident_classifier/template.html +167 -0
- package/servicenow/widgets/openai_incident_classifier/widget.json +86 -0
- package/intelligent-mcp.db-shm +0 -0
- package/intelligent-mcp.db-wal +0 -0
|
@@ -0,0 +1,938 @@
|
|
|
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
|