snow-flow 1.3.11 → 1.3.14
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/cli.js +300 -213
- package/dist/utils/agent-detector.js +3 -2
- package/dist/version.js +25 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -61,6 +61,118 @@ program
|
|
|
61
61
|
.name('snow-flow')
|
|
62
62
|
.description('ServiceNow Multi-Agent Development Framework')
|
|
63
63
|
.version(version_js_1.VERSION);
|
|
64
|
+
// Helper function to deploy XML to ServiceNow
|
|
65
|
+
async function deployXMLToServiceNow(xmlFile, options = {}) {
|
|
66
|
+
const oauth = new snow_oauth_js_1.ServiceNowOAuth();
|
|
67
|
+
const isAuthenticated = await oauth.getStoredTokens() !== null;
|
|
68
|
+
if (!isAuthenticated) {
|
|
69
|
+
cliLogger.error('❌ Not authenticated. Please run: snow-flow auth login');
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
// Initialize ServiceNow client
|
|
74
|
+
const client = new servicenow_client_js_1.ServiceNowClient();
|
|
75
|
+
// Read XML file
|
|
76
|
+
if (!(0, fs_2.existsSync)(xmlFile)) {
|
|
77
|
+
cliLogger.error(`❌ XML file not found: ${xmlFile}`);
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
cliLogger.info('📄 Reading XML file...');
|
|
81
|
+
const xmlContent = await fs_1.promises.readFile(xmlFile, 'utf-8');
|
|
82
|
+
// Import XML as remote update set
|
|
83
|
+
cliLogger.info('📤 Importing XML to ServiceNow...');
|
|
84
|
+
const importResponse = await client.makeRequest({
|
|
85
|
+
method: 'POST',
|
|
86
|
+
url: '/api/now/table/sys_remote_update_set',
|
|
87
|
+
headers: {
|
|
88
|
+
'Content-Type': 'application/xml',
|
|
89
|
+
'Accept': 'application/json'
|
|
90
|
+
},
|
|
91
|
+
data: xmlContent
|
|
92
|
+
});
|
|
93
|
+
if (!importResponse.result || !importResponse.result.sys_id) {
|
|
94
|
+
throw new Error('Failed to import XML update set');
|
|
95
|
+
}
|
|
96
|
+
const remoteUpdateSetId = importResponse.result.sys_id;
|
|
97
|
+
cliLogger.info(`✅ XML imported successfully (sys_id: ${remoteUpdateSetId})`);
|
|
98
|
+
// Load the update set
|
|
99
|
+
cliLogger.info('🔄 Loading update set...');
|
|
100
|
+
await client.makeRequest({
|
|
101
|
+
method: 'PUT',
|
|
102
|
+
url: `/api/now/table/sys_remote_update_set/${remoteUpdateSetId}`,
|
|
103
|
+
data: {
|
|
104
|
+
state: 'loaded'
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
// Find the loaded update set
|
|
108
|
+
const loadedResponse = await client.makeRequest({
|
|
109
|
+
method: 'GET',
|
|
110
|
+
url: '/api/now/table/sys_update_set',
|
|
111
|
+
params: {
|
|
112
|
+
sysparm_query: `remote_sys_id=${remoteUpdateSetId}`,
|
|
113
|
+
sysparm_limit: 1
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
if (!loadedResponse.result || loadedResponse.result.length === 0) {
|
|
117
|
+
throw new Error('Failed to find loaded update set');
|
|
118
|
+
}
|
|
119
|
+
const updateSetId = loadedResponse.result[0].sys_id;
|
|
120
|
+
const updateSetName = loadedResponse.result[0].name;
|
|
121
|
+
cliLogger.info(`✅ Update set loaded: ${updateSetName}`);
|
|
122
|
+
// Preview if requested
|
|
123
|
+
if (options.preview !== false) {
|
|
124
|
+
cliLogger.info('🔍 Previewing update set...');
|
|
125
|
+
await client.makeRequest({
|
|
126
|
+
method: 'POST',
|
|
127
|
+
url: `/api/now/table/sys_update_set/${updateSetId}/preview`
|
|
128
|
+
});
|
|
129
|
+
// Check preview results
|
|
130
|
+
const previewProblems = await client.makeRequest({
|
|
131
|
+
method: 'GET',
|
|
132
|
+
url: '/api/now/table/sys_update_preview_problem',
|
|
133
|
+
params: {
|
|
134
|
+
sysparm_query: `update_set=${updateSetId}`,
|
|
135
|
+
sysparm_limit: 100
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
if (previewProblems.result && previewProblems.result.length > 0) {
|
|
139
|
+
cliLogger.warn('\n⚠️ Preview found problems:');
|
|
140
|
+
previewProblems.result.forEach((p) => {
|
|
141
|
+
cliLogger.warn(` - ${p.type}: ${p.description}`);
|
|
142
|
+
});
|
|
143
|
+
if (options.commit !== false) {
|
|
144
|
+
cliLogger.warn('\n⚠️ Skipping auto-commit due to preview problems');
|
|
145
|
+
cliLogger.info('📋 Review and resolve problems in ServiceNow, then commit manually');
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
cliLogger.info('✅ Preview successful - no problems found');
|
|
151
|
+
}
|
|
152
|
+
// Commit if clean and requested
|
|
153
|
+
if (options.commit !== false && (!previewProblems.result || previewProblems.result.length === 0)) {
|
|
154
|
+
cliLogger.info('🚀 Committing update set...');
|
|
155
|
+
await client.makeRequest({
|
|
156
|
+
method: 'POST',
|
|
157
|
+
url: `/api/now/table/sys_update_set/${updateSetId}/commit`
|
|
158
|
+
});
|
|
159
|
+
cliLogger.info('\n✅ Update Set committed successfully!');
|
|
160
|
+
cliLogger.info('📍 Navigate to Flow Designer > Designer to see your flow');
|
|
161
|
+
cliLogger.info('\n🎉 Deployment complete!');
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
cliLogger.error('\n❌ Deployment failed:', error instanceof Error ? error.message : String(error));
|
|
169
|
+
cliLogger.info('\n💡 Troubleshooting tips:');
|
|
170
|
+
cliLogger.info(' 1. Check your authentication: snow-flow auth status');
|
|
171
|
+
cliLogger.info(' 2. Verify XML file format is correct');
|
|
172
|
+
cliLogger.info(' 3. Ensure you have required permissions in ServiceNow');
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
64
176
|
// Swarm command - the main orchestration command with EVERYTHING
|
|
65
177
|
program
|
|
66
178
|
.command('swarm <objective>')
|
|
@@ -85,60 +197,88 @@ program
|
|
|
85
197
|
.option('--no-progress-monitoring', 'Disable progress monitoring')
|
|
86
198
|
.option('--xml-first', 'Use XML-first approach for flow creation (MOST RELIABLE!)')
|
|
87
199
|
.option('--xml-output <path>', 'Save generated XML to specific path (with --xml-first)')
|
|
200
|
+
.option('--verbose', 'Show detailed execution information')
|
|
88
201
|
.action(async (objective, options) => {
|
|
89
|
-
|
|
202
|
+
// Always show essential info
|
|
203
|
+
cliLogger.info(`\n🚀 Snow-Flow v${version_js_1.VERSION}`);
|
|
90
204
|
cliLogger.info(`📋 Objective: ${objective}`);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
205
|
+
// Only show detailed config in verbose mode
|
|
206
|
+
if (options.verbose) {
|
|
207
|
+
cliLogger.info(`⚙️ Strategy: ${options.strategy} | Mode: ${options.mode} | Max Agents: ${options.maxAgents}`);
|
|
208
|
+
cliLogger.info(`🔄 Parallel: ${options.parallel ? 'Yes' : 'No'} | Monitor: ${options.monitor ? 'Yes' : 'No'}`);
|
|
209
|
+
// Show new intelligent features
|
|
210
|
+
cliLogger.info(`\n🧠 Intelligent Features:`);
|
|
211
|
+
cliLogger.info(` 🔐 Auto Permissions: ${options.autoPermissions ? '✅ Yes' : '❌ No'}`);
|
|
212
|
+
cliLogger.info(` 🔍 Smart Discovery: ${options.smartDiscovery ? '✅ Yes' : '❌ No'}`);
|
|
213
|
+
cliLogger.info(` 🧪 Live Testing: ${options.liveTesting ? '✅ Yes' : '❌ No'}`);
|
|
214
|
+
cliLogger.info(` 🚀 Auto Deploy: ${options.autoDeploy ? '✅ DEPLOYMENT MODE - WILL CREATE REAL ARTIFACTS' : '❌ PLANNING MODE - ANALYSIS ONLY'}`);
|
|
215
|
+
cliLogger.info(` 🔄 Auto Rollback: ${options.autoRollback ? '✅ Yes' : '❌ No'}`);
|
|
216
|
+
cliLogger.info(` 💾 Shared Memory: ${options.sharedMemory ? '✅ Yes' : '❌ No'}`);
|
|
217
|
+
cliLogger.info(` 📊 Progress Monitoring: ${options.progressMonitoring ? '✅ Yes' : '❌ No'}\n`);
|
|
218
|
+
}
|
|
219
|
+
else if (options.autoDeploy) {
|
|
220
|
+
// In non-verbose mode, only show critical deployment warning
|
|
221
|
+
cliLogger.info(`🚀 Auto-Deploy: ENABLED - Will create real artifacts in ServiceNow`);
|
|
222
|
+
}
|
|
102
223
|
// Analyze the objective using intelligent agent detection
|
|
103
224
|
const taskAnalysis = analyzeObjective(objective, parseInt(options.maxAgents));
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
cliLogger.info(
|
|
225
|
+
// Debug logging to understand task type detection
|
|
226
|
+
if (process.env.DEBUG || options.verbose) {
|
|
227
|
+
if (process.env.DEBUG) {
|
|
228
|
+
cliLogger.info(`🔍 DEBUG - Detected artifacts: [${taskAnalysis.serviceNowArtifacts.join(', ')}]`);
|
|
229
|
+
cliLogger.info(`🔍 DEBUG - Flow keywords in objective: ${objective.toLowerCase().includes('flow')}`);
|
|
230
|
+
cliLogger.info(`🔍 DEBUG - Widget keywords in objective: ${objective.toLowerCase().includes('widget')}`);
|
|
231
|
+
}
|
|
232
|
+
cliLogger.info(`\n📊 Task Analysis:`);
|
|
233
|
+
cliLogger.info(` 🎯 Task Type: ${taskAnalysis.taskType}`);
|
|
234
|
+
cliLogger.info(` 🧠 Primary Agent: ${taskAnalysis.primaryAgent}`);
|
|
235
|
+
cliLogger.info(` 👥 Supporting Agents: ${taskAnalysis.supportingAgents.join(', ')}`);
|
|
236
|
+
cliLogger.info(` 📊 Complexity: ${taskAnalysis.complexity} | Estimated Agents: ${taskAnalysis.estimatedAgentCount}`);
|
|
237
|
+
cliLogger.info(` 🔧 ServiceNow Artifacts: ${taskAnalysis.serviceNowArtifacts.join(', ')}`);
|
|
238
|
+
cliLogger.info(` 📦 Auto Update Set: ${taskAnalysis.requiresUpdateSet ? '✅ Yes' : '❌ No'}`);
|
|
239
|
+
cliLogger.info(` 🏗️ Auto Application: ${taskAnalysis.requiresApplication ? '✅ Yes' : '❌ No'}`);
|
|
115
240
|
}
|
|
116
|
-
|
|
117
|
-
|
|
241
|
+
// Show timeout configuration only in verbose mode
|
|
242
|
+
const timeoutMinutes = process.env.SNOW_FLOW_TIMEOUT_MINUTES ? parseInt(process.env.SNOW_FLOW_TIMEOUT_MINUTES) : 60;
|
|
243
|
+
if (options.verbose) {
|
|
244
|
+
if (timeoutMinutes > 0) {
|
|
245
|
+
cliLogger.info(`⏱️ Timeout: ${timeoutMinutes} minutes`);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
cliLogger.info('⏱️ Timeout: Disabled (infinite execution time)');
|
|
249
|
+
}
|
|
118
250
|
}
|
|
119
251
|
// Check ServiceNow authentication
|
|
120
252
|
const oauth = new snow_oauth_js_1.ServiceNowOAuth();
|
|
121
253
|
const isAuthenticated = await oauth.isAuthenticated();
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
254
|
+
if (options.verbose) {
|
|
255
|
+
if (isAuthenticated) {
|
|
256
|
+
cliLogger.info('🔗 ServiceNow connection: ✅ Authenticated');
|
|
257
|
+
// Test ServiceNow connection
|
|
258
|
+
const client = new servicenow_client_js_1.ServiceNowClient();
|
|
259
|
+
const testResult = await client.testConnection();
|
|
260
|
+
if (testResult.success) {
|
|
261
|
+
cliLogger.info(`👤 Connected as: ${testResult.data.name} (${testResult.data.user_name})`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
cliLogger.warn('🔗 ServiceNow connection: ❌ Not authenticated');
|
|
266
|
+
cliLogger.info('💡 Run "snow-flow auth login" to enable live ServiceNow integration');
|
|
129
267
|
}
|
|
130
268
|
}
|
|
131
|
-
else {
|
|
132
|
-
|
|
133
|
-
cliLogger.
|
|
269
|
+
else if (!isAuthenticated) {
|
|
270
|
+
// In non-verbose mode, only warn if not authenticated
|
|
271
|
+
cliLogger.warn('⚠️ Not authenticated. Run "snow-flow auth login" for ServiceNow integration');
|
|
134
272
|
}
|
|
135
273
|
// Initialize Queen Agent memory system
|
|
136
|
-
|
|
274
|
+
if (options.verbose) {
|
|
275
|
+
cliLogger.info('\n💾 Initializing swarm memory system...');
|
|
276
|
+
}
|
|
137
277
|
const { QueenMemorySystem } = await Promise.resolve().then(() => __importStar(require('./queen/queen-memory.js')));
|
|
138
278
|
const memorySystem = new QueenMemorySystem();
|
|
139
279
|
// Generate swarm session ID
|
|
140
280
|
const sessionId = `swarm_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
141
|
-
cliLogger.info(
|
|
281
|
+
cliLogger.info(`\n🔖 Session: ${sessionId}`);
|
|
142
282
|
// Store swarm session in memory
|
|
143
283
|
memorySystem.storeLearning(`session_${sessionId}`, {
|
|
144
284
|
objective,
|
|
@@ -155,9 +295,7 @@ program
|
|
|
155
295
|
!objective.toLowerCase().includes('data flow'));
|
|
156
296
|
let xmlFlowResult = null;
|
|
157
297
|
if (isFlowDesignerTask) {
|
|
158
|
-
cliLogger.info('\n🔧 Flow Designer
|
|
159
|
-
cliLogger.info('📋 Creating production-ready ServiceNow flow XML...');
|
|
160
|
-
cliLogger.info('💡 Reason: Flow Designer flows are most reliable with XML-first approach\n');
|
|
298
|
+
cliLogger.info('\n🔧 Flow Designer detected - generating XML...');
|
|
161
299
|
try {
|
|
162
300
|
// Import IMPROVED XML flow generator (fixes "too small to work" issue!)
|
|
163
301
|
const { generateImprovedFlowXML } = await Promise.resolve().then(() => __importStar(require('./utils/improved-flow-xml-generator.js')));
|
|
@@ -237,7 +375,9 @@ program
|
|
|
237
375
|
}]
|
|
238
376
|
};
|
|
239
377
|
// Generate IMPROVED XML with enhanced structure
|
|
240
|
-
|
|
378
|
+
if (options.verbose) {
|
|
379
|
+
cliLogger.info('🏗️ Generating IMPROVED production XML...');
|
|
380
|
+
}
|
|
241
381
|
// Convert to improved flow definition
|
|
242
382
|
const improvedFlowDef = {
|
|
243
383
|
...flowDef,
|
|
@@ -252,18 +392,19 @@ program
|
|
|
252
392
|
};
|
|
253
393
|
const result = generateImprovedFlowXML(improvedFlowDef);
|
|
254
394
|
xmlFlowResult = { ...result, flowDefinition: flowDef };
|
|
255
|
-
cliLogger.info(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
395
|
+
cliLogger.info(`✅ XML generated: ${result.filePath}`);
|
|
396
|
+
if (options.verbose) {
|
|
397
|
+
cliLogger.info(`🔥 IMPROVEMENTS: Uses v2 tables, Base64+gzip encoding, complete label_cache!`);
|
|
398
|
+
cliLogger.info(`📊 Flow structure:`);
|
|
399
|
+
cliLogger.info(` - Name: ${flowDef.name}`);
|
|
400
|
+
cliLogger.info(` - Table: ${flowDef.table}`);
|
|
401
|
+
cliLogger.info(` - Trigger: ${flowDef.trigger_type}`);
|
|
402
|
+
cliLogger.info(` - Activities: ${flowDef.activities.length}`);
|
|
403
|
+
// Show import instructions
|
|
404
|
+
cliLogger.info('\n' + '='.repeat(60));
|
|
405
|
+
cliLogger.info(result.instructions);
|
|
406
|
+
cliLogger.info('='.repeat(60));
|
|
407
|
+
}
|
|
267
408
|
// Store result in memory
|
|
268
409
|
memorySystem.storeLearning(`xml_flow_${sessionId}`, {
|
|
269
410
|
objective,
|
|
@@ -271,19 +412,44 @@ program
|
|
|
271
412
|
xml_file: result.filePath,
|
|
272
413
|
generated_at: new Date().toISOString()
|
|
273
414
|
});
|
|
274
|
-
cliLogger.info('\n🎯 XML Flow generated successfully!');
|
|
275
415
|
// Check if auto-deploy is enabled
|
|
276
416
|
if (options.autoDeploy !== false) { // Default is true from swarm command
|
|
277
|
-
cliLogger.info('
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
417
|
+
cliLogger.info('🚀 Deploying to ServiceNow...');
|
|
418
|
+
try {
|
|
419
|
+
// Automatically deploy the XML file
|
|
420
|
+
const deploySuccess = await deployXMLToServiceNow(result.filePath, {
|
|
421
|
+
preview: true,
|
|
422
|
+
commit: true
|
|
423
|
+
});
|
|
424
|
+
if (deploySuccess) {
|
|
425
|
+
cliLogger.info('✅ Flow deployed to ServiceNow!');
|
|
426
|
+
// Store deployment success in memory
|
|
427
|
+
memorySystem.storeLearning(`deployment_${sessionId}`, {
|
|
428
|
+
success: true,
|
|
429
|
+
xml_file: result.filePath,
|
|
430
|
+
deployed_at: new Date().toISOString(),
|
|
431
|
+
flow_name: flowDef.name
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
cliLogger.warn('⚠️ Deployment encountered issues');
|
|
436
|
+
cliLogger.info(`💡 Manual deploy: snow-flow deploy-xml "${result.filePath}"`);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
catch (deployError) {
|
|
440
|
+
cliLogger.error('❌ Deployment failed:', deployError instanceof Error ? deployError.message : String(deployError));
|
|
441
|
+
cliLogger.info(`💡 Manual deploy: snow-flow deploy-xml "${result.filePath}"`);
|
|
442
|
+
}
|
|
281
443
|
}
|
|
282
444
|
else {
|
|
283
|
-
|
|
445
|
+
if (options.verbose) {
|
|
446
|
+
cliLogger.info('📋 Use the import instructions above to deploy to ServiceNow');
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
cliLogger.info(`📋 Manual deploy: snow-flow deploy-xml "${result.filePath}"`);
|
|
450
|
+
}
|
|
284
451
|
}
|
|
285
|
-
|
|
286
|
-
// DO NOT RETURN HERE - Continue to Queen Agent orchestration!
|
|
452
|
+
// Continue to Queen Agent orchestration
|
|
287
453
|
}
|
|
288
454
|
catch (error) {
|
|
289
455
|
cliLogger.error('❌ XML flow generation failed:', error instanceof Error ? error.message : String(error));
|
|
@@ -294,17 +460,22 @@ program
|
|
|
294
460
|
try {
|
|
295
461
|
// Generate the Queen Agent orchestration prompt
|
|
296
462
|
const orchestrationPrompt = buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated, sessionId, xmlFlowResult);
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
463
|
+
if (options.verbose) {
|
|
464
|
+
cliLogger.info('\n👑 Initializing Queen Agent orchestration...');
|
|
465
|
+
cliLogger.info('🎯 Queen Agent will coordinate the following:');
|
|
466
|
+
cliLogger.info(` - Analyze objective: "${objective}"`);
|
|
467
|
+
cliLogger.info(` - Spawn ${taskAnalysis.estimatedAgentCount} specialized agents`);
|
|
468
|
+
cliLogger.info(` - Coordinate through shared memory (session: ${sessionId})`);
|
|
469
|
+
cliLogger.info(` - Monitor progress and adapt strategy`);
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
cliLogger.info('\n👑 Launching Queen Agent...');
|
|
473
|
+
}
|
|
303
474
|
// Check if intelligent features are enabled
|
|
304
475
|
const hasIntelligentFeatures = options.autoPermissions || options.smartDiscovery ||
|
|
305
476
|
options.liveTesting || options.autoDeploy || options.autoRollback ||
|
|
306
477
|
options.sharedMemory || options.progressMonitoring;
|
|
307
|
-
if (hasIntelligentFeatures && isAuthenticated) {
|
|
478
|
+
if (options.verbose && hasIntelligentFeatures && isAuthenticated) {
|
|
308
479
|
cliLogger.info('\n🧠 INTELLIGENT ORCHESTRATION MODE ENABLED!');
|
|
309
480
|
cliLogger.info('✨ Queen Agent will use advanced features:');
|
|
310
481
|
if (options.autoPermissions) {
|
|
@@ -329,26 +500,30 @@ program
|
|
|
329
500
|
cliLogger.info(' 📊 Real-time progress monitoring');
|
|
330
501
|
}
|
|
331
502
|
}
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
503
|
+
if (options.verbose) {
|
|
504
|
+
if (isAuthenticated) {
|
|
505
|
+
cliLogger.info('\n🔗 Live ServiceNow integration: ✅ Enabled');
|
|
506
|
+
cliLogger.info('📝 Artifacts will be created directly in ServiceNow');
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
cliLogger.info('\n🔗 Live ServiceNow integration: ❌ Disabled');
|
|
510
|
+
cliLogger.info('📝 Artifacts will be saved to servicenow/ directory');
|
|
511
|
+
}
|
|
339
512
|
}
|
|
340
|
-
cliLogger.info('
|
|
513
|
+
cliLogger.info('🚀 Launching Claude Code...');
|
|
341
514
|
// Try to execute Claude Code directly with the prompt
|
|
342
515
|
const success = await executeClaudeCode(orchestrationPrompt);
|
|
343
516
|
if (success) {
|
|
344
|
-
cliLogger.info('
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
517
|
+
cliLogger.info('✅ Claude Code launched successfully!');
|
|
518
|
+
if (options.verbose) {
|
|
519
|
+
cliLogger.info('👑 Queen Agent is now coordinating your swarm');
|
|
520
|
+
cliLogger.info(`💾 Monitor progress with session ID: ${sessionId}`);
|
|
521
|
+
if (isAuthenticated && options.autoDeploy) {
|
|
522
|
+
cliLogger.info('🚀 Real artifacts will be created in ServiceNow');
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
cliLogger.info('📋 Planning mode - analysis and recommendations only');
|
|
526
|
+
}
|
|
352
527
|
}
|
|
353
528
|
// Store successful launch in memory
|
|
354
529
|
memorySystem.storeLearning(`launch_${sessionId}`, {
|
|
@@ -357,33 +532,43 @@ program
|
|
|
357
532
|
});
|
|
358
533
|
}
|
|
359
534
|
else {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
535
|
+
if (options.verbose) {
|
|
536
|
+
cliLogger.info('\n🚀 SNOW-FLOW ORCHESTRATION COMPLETE!');
|
|
537
|
+
cliLogger.info('🤖 Now it\'s time for Claude Code agents to do the work...\n');
|
|
538
|
+
cliLogger.info('👑 QUEEN AGENT ORCHESTRATION PROMPT FOR CLAUDE CODE:');
|
|
539
|
+
cliLogger.info('='.repeat(80));
|
|
540
|
+
cliLogger.info(orchestrationPrompt);
|
|
541
|
+
cliLogger.info('='.repeat(80));
|
|
542
|
+
cliLogger.info('\n✅ Snow-Flow has prepared the orchestration!');
|
|
543
|
+
cliLogger.info('📊 CRITICAL NEXT STEPS:');
|
|
544
|
+
cliLogger.info(' 1. Copy the ENTIRE prompt above');
|
|
545
|
+
cliLogger.info(' 2. Paste it into Claude Code (the AI assistant)');
|
|
546
|
+
cliLogger.info(' 3. Claude Code will spawn multiple specialized agents as workhorses');
|
|
547
|
+
cliLogger.info(' 4. These agents will implement your flow with all required logic');
|
|
548
|
+
cliLogger.info(' 5. Agents will enhance the basic XML template with real functionality');
|
|
549
|
+
cliLogger.info('\n🎯 Remember:');
|
|
550
|
+
cliLogger.info(' - Snow-Flow = Orchestrator (coordinates the work)');
|
|
551
|
+
cliLogger.info(' - Claude Code = Workhorses (implement the solution)');
|
|
552
|
+
if (xmlFlowResult) {
|
|
553
|
+
cliLogger.info(`\n📁 XML template saved at: ${xmlFlowResult.filePath}`);
|
|
554
|
+
cliLogger.info(' ⚠️ This is just a BASIC template - agents must enhance it!');
|
|
555
|
+
}
|
|
556
|
+
if (isAuthenticated && options.autoDeploy) {
|
|
557
|
+
cliLogger.info('\n🚀 Deployment Mode: Agents will create REAL artifacts in ServiceNow');
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
cliLogger.info('\n📋 Planning Mode: Analysis and recommendations only');
|
|
561
|
+
}
|
|
562
|
+
cliLogger.info(`\n💾 Session ID for monitoring: ${sessionId}`);
|
|
382
563
|
}
|
|
383
564
|
else {
|
|
384
|
-
|
|
565
|
+
// Non-verbose mode - just show the essential info
|
|
566
|
+
cliLogger.info('\n📋 Manual Claude Code execution required');
|
|
567
|
+
cliLogger.info('💡 Run with --verbose to see the full orchestration prompt');
|
|
568
|
+
if (xmlFlowResult) {
|
|
569
|
+
cliLogger.info(`📁 XML generated: ${xmlFlowResult.filePath}`);
|
|
570
|
+
}
|
|
385
571
|
}
|
|
386
|
-
cliLogger.info(`\n💾 Session ID for monitoring: ${sessionId}`);
|
|
387
572
|
}
|
|
388
573
|
}
|
|
389
574
|
catch (error) {
|
|
@@ -1725,111 +1910,13 @@ program
|
|
|
1725
1910
|
.action(async (xmlFile, options) => {
|
|
1726
1911
|
console.log(`\n📦 Deploying XML Update Set: ${xmlFile}`);
|
|
1727
1912
|
console.log('='.repeat(60));
|
|
1728
|
-
|
|
1729
|
-
const
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
// Initialize ServiceNow client
|
|
1736
|
-
const client = new servicenow_client_js_1.ServiceNowClient();
|
|
1737
|
-
// Read XML file
|
|
1738
|
-
if (!(0, fs_2.existsSync)(xmlFile)) {
|
|
1739
|
-
console.error(`❌ XML file not found: ${xmlFile}`);
|
|
1740
|
-
return;
|
|
1741
|
-
}
|
|
1742
|
-
console.log('📄 Reading XML file...');
|
|
1743
|
-
const xmlContent = await fs_1.promises.readFile(xmlFile, 'utf-8');
|
|
1744
|
-
// Import XML as remote update set
|
|
1745
|
-
console.log('📤 Importing XML to ServiceNow...');
|
|
1746
|
-
const importResponse = await client.makeRequest({
|
|
1747
|
-
method: 'POST',
|
|
1748
|
-
url: '/api/now/table/sys_remote_update_set',
|
|
1749
|
-
headers: {
|
|
1750
|
-
'Content-Type': 'application/xml',
|
|
1751
|
-
'Accept': 'application/json'
|
|
1752
|
-
},
|
|
1753
|
-
data: xmlContent
|
|
1754
|
-
});
|
|
1755
|
-
if (!importResponse.result || !importResponse.result.sys_id) {
|
|
1756
|
-
throw new Error('Failed to import XML update set');
|
|
1757
|
-
}
|
|
1758
|
-
const remoteUpdateSetId = importResponse.result.sys_id;
|
|
1759
|
-
console.log(`✅ XML imported successfully (sys_id: ${remoteUpdateSetId})`);
|
|
1760
|
-
// Load the update set
|
|
1761
|
-
console.log('🔄 Loading update set...');
|
|
1762
|
-
await client.makeRequest({
|
|
1763
|
-
method: 'PUT',
|
|
1764
|
-
url: `/api/now/table/sys_remote_update_set/${remoteUpdateSetId}`,
|
|
1765
|
-
data: {
|
|
1766
|
-
state: 'loaded'
|
|
1767
|
-
}
|
|
1768
|
-
});
|
|
1769
|
-
// Find the loaded update set
|
|
1770
|
-
const loadedResponse = await client.makeRequest({
|
|
1771
|
-
method: 'GET',
|
|
1772
|
-
url: '/api/now/table/sys_update_set',
|
|
1773
|
-
params: {
|
|
1774
|
-
sysparm_query: `remote_sys_id=${remoteUpdateSetId}`,
|
|
1775
|
-
sysparm_limit: 1
|
|
1776
|
-
}
|
|
1777
|
-
});
|
|
1778
|
-
if (!loadedResponse.result || loadedResponse.result.length === 0) {
|
|
1779
|
-
throw new Error('Failed to find loaded update set');
|
|
1780
|
-
}
|
|
1781
|
-
const updateSetId = loadedResponse.result[0].sys_id;
|
|
1782
|
-
const updateSetName = loadedResponse.result[0].name;
|
|
1783
|
-
console.log(`✅ Update set loaded: ${updateSetName}`);
|
|
1784
|
-
// Preview if requested
|
|
1785
|
-
if (options.preview !== false) {
|
|
1786
|
-
console.log('🔍 Previewing update set...');
|
|
1787
|
-
await client.makeRequest({
|
|
1788
|
-
method: 'POST',
|
|
1789
|
-
url: `/api/now/table/sys_update_set/${updateSetId}/preview`
|
|
1790
|
-
});
|
|
1791
|
-
// Check preview results
|
|
1792
|
-
const previewProblems = await client.makeRequest({
|
|
1793
|
-
method: 'GET',
|
|
1794
|
-
url: '/api/now/table/sys_update_preview_problem',
|
|
1795
|
-
params: {
|
|
1796
|
-
sysparm_query: `update_set=${updateSetId}`,
|
|
1797
|
-
sysparm_limit: 100
|
|
1798
|
-
}
|
|
1799
|
-
});
|
|
1800
|
-
if (previewProblems.result && previewProblems.result.length > 0) {
|
|
1801
|
-
console.log('\n⚠️ Preview found problems:');
|
|
1802
|
-
previewProblems.result.forEach((p) => {
|
|
1803
|
-
console.log(` - ${p.type}: ${p.description}`);
|
|
1804
|
-
});
|
|
1805
|
-
if (options.commit !== false) {
|
|
1806
|
-
console.log('\n⚠️ Skipping auto-commit due to preview problems');
|
|
1807
|
-
console.log('📋 Review and resolve problems in ServiceNow, then commit manually');
|
|
1808
|
-
return;
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
else {
|
|
1812
|
-
console.log('✅ Preview successful - no problems found');
|
|
1813
|
-
}
|
|
1814
|
-
// Commit if clean and requested
|
|
1815
|
-
if (options.commit !== false && (!previewProblems.result || previewProblems.result.length === 0)) {
|
|
1816
|
-
console.log('🚀 Committing update set...');
|
|
1817
|
-
await client.makeRequest({
|
|
1818
|
-
method: 'POST',
|
|
1819
|
-
url: `/api/now/table/sys_update_set/${updateSetId}/commit`
|
|
1820
|
-
});
|
|
1821
|
-
console.log('\n✅ Update Set committed successfully!');
|
|
1822
|
-
console.log('📍 Navigate to Flow Designer > Designer to see your flow');
|
|
1823
|
-
console.log('\n🎉 Deployment complete!');
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
catch (error) {
|
|
1828
|
-
console.error('\n❌ Deployment failed:', error instanceof Error ? error.message : String(error));
|
|
1829
|
-
console.log('\n💡 Troubleshooting tips:');
|
|
1830
|
-
console.log(' 1. Check your authentication: snow-flow auth status');
|
|
1831
|
-
console.log(' 2. Verify XML file format is correct');
|
|
1832
|
-
console.log(' 3. Ensure you have required permissions in ServiceNow');
|
|
1913
|
+
// Use the shared deploy function
|
|
1914
|
+
const success = await deployXMLToServiceNow(xmlFile, {
|
|
1915
|
+
preview: options.preview,
|
|
1916
|
+
commit: options.commit
|
|
1917
|
+
});
|
|
1918
|
+
if (!success) {
|
|
1919
|
+
process.exit(1);
|
|
1833
1920
|
}
|
|
1834
1921
|
});
|
|
1835
1922
|
// Help command
|
|
@@ -266,10 +266,11 @@ class AgentDetector {
|
|
|
266
266
|
}
|
|
267
267
|
static determineTaskType(objective, artifacts) {
|
|
268
268
|
// Determine based on detected artifacts and keywords
|
|
269
|
-
|
|
270
|
-
return 'widget_development';
|
|
269
|
+
// Check flow FIRST as it's often confused with widget when both are present
|
|
271
270
|
if (artifacts.includes('flow') || artifacts.includes('workflow'))
|
|
272
271
|
return 'flow_development';
|
|
272
|
+
if (artifacts.includes('widget'))
|
|
273
|
+
return 'widget_development';
|
|
273
274
|
if (artifacts.includes('application'))
|
|
274
275
|
return 'application_development';
|
|
275
276
|
if (artifacts.includes('script') || artifacts.includes('business_rule'))
|
package/dist/version.js
CHANGED
|
@@ -7,12 +7,36 @@ exports.VERSION_INFO = exports.VERSION = void 0;
|
|
|
7
7
|
exports.getVersionString = getVersionString;
|
|
8
8
|
exports.getLatestFeatures = getLatestFeatures;
|
|
9
9
|
exports.isLatestVersion = isLatestVersion;
|
|
10
|
-
exports.VERSION = '1.3.
|
|
10
|
+
exports.VERSION = '1.3.14';
|
|
11
11
|
exports.VERSION_INFO = {
|
|
12
12
|
version: exports.VERSION,
|
|
13
13
|
name: 'Snow-Flow',
|
|
14
14
|
description: 'ServiceNow Queen Agent - Hive-Mind Intelligence for ServiceNow Development',
|
|
15
15
|
features: {
|
|
16
|
+
'1.3.14': [
|
|
17
|
+
'🎯 CLEANER OUTPUT: Dramatically reduced verbose logging in swarm command',
|
|
18
|
+
'🚀 FOCUSED UI: Only essential information shown by default',
|
|
19
|
+
'📊 --verbose FLAG: Added flag to see detailed execution information',
|
|
20
|
+
'✨ STREAMLINED: No more walls of text before anything happens',
|
|
21
|
+
'💡 SMART DEFAULTS: Shows objective, session ID, and actual progress only',
|
|
22
|
+
'🔧 BETTER UX: Clean, professional output focused on what matters'
|
|
23
|
+
],
|
|
24
|
+
'1.3.13': [
|
|
25
|
+
'🐛 FIX ERROR MESSAGES: Separated XML generation and deployment error handling',
|
|
26
|
+
'✅ CORRECT ERRORS: "XML flow generation failed" no longer shows for deployment issues',
|
|
27
|
+
'🎯 FLOW DETECTION FIX: Flow tasks now correctly detected instead of widget_development',
|
|
28
|
+
'🔧 BETTER ERROR HANDLING: Deployment errors show specific failure reasons',
|
|
29
|
+
'📊 DEBUG LOGGING: Added artifact detection debugging with DEBUG env var',
|
|
30
|
+
'⚡ IMPROVED RELIABILITY: Better error recovery and clearer user feedback'
|
|
31
|
+
],
|
|
32
|
+
'1.3.12': [
|
|
33
|
+
'🚀 AUTO-DEPLOY XML: Swarm command now automatically deploys flow XML to ServiceNow',
|
|
34
|
+
'✨ ZERO MANUAL STEPS: Generate → Import → Preview → Commit all automatic',
|
|
35
|
+
'🎯 SMART ERROR HANDLING: Falls back to manual deployment if issues occur',
|
|
36
|
+
'🔧 SHARED DEPLOYMENT: Both swarm and deploy-xml use same deployment logic',
|
|
37
|
+
'💾 DEPLOYMENT TRACKING: Successful deployments tracked in memory system',
|
|
38
|
+
'✅ COMPLETE AUTOMATION: No more manual "deploy-xml" command needed'
|
|
39
|
+
],
|
|
16
40
|
'1.3.11': [
|
|
17
41
|
'🔥 IMPROVED FLOW GENERATOR: Complete rewrite fixing "too small to work" issue',
|
|
18
42
|
'✅ V2 TABLE STRUCTURES: Uses sys_hub_action_instance_v2 and sys_hub_trigger_instance_v2',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.14",
|
|
4
4
|
"description": "ServiceNow Queen Agent - Hive-Mind Intelligence for ServiceNow Development inspired by claude-flow. Transform complex workflows into elegant one-command orchestration.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|