snow-flow 1.3.14 → 1.3.16

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 CHANGED
@@ -287,179 +287,17 @@ program
287
287
  started_at: new Date().toISOString(),
288
288
  is_authenticated: isAuthenticated
289
289
  });
290
- // Check if this is a Flow Designer flow request - ALWAYS use XML-first for flows!
290
+ // Check if this is a Flow Designer flow request
291
291
  const isFlowDesignerTask = taskAnalysis.taskType === 'flow_development' ||
292
292
  taskAnalysis.primaryAgent === 'flow-builder' ||
293
293
  (objective.toLowerCase().includes('flow') &&
294
294
  !objective.toLowerCase().includes('workflow') &&
295
295
  !objective.toLowerCase().includes('data flow'));
296
296
  let xmlFlowResult = null;
297
- if (isFlowDesignerTask) {
298
- cliLogger.info('\nšŸ”§ Flow Designer detected - generating XML...');
299
- try {
300
- // Import IMPROVED XML flow generator (fixes "too small to work" issue!)
301
- const { generateImprovedFlowXML } = await Promise.resolve().then(() => __importStar(require('./utils/improved-flow-xml-generator.js')));
302
- // Parse instruction to determine activities
303
- const activities = [];
304
- const objectiveLower = objective.toLowerCase();
305
- // Auto-detect activities from objective
306
- if (objectiveLower.includes('approval') || objectiveLower.includes('approve')) {
307
- activities.push({
308
- name: 'Request Approval',
309
- type: 'approval',
310
- order: 100,
311
- inputs: {
312
- table: taskAnalysis.serviceNowArtifacts.includes('sc_request') ? 'sc_request' : 'incident',
313
- record: '{{trigger.current.sys_id}}',
314
- approver: '{{trigger.current.requested_for.manager}}',
315
- approval_field: 'approval',
316
- message: `Please approve: {{trigger.current.number}}`
317
- },
318
- outputs: {
319
- state: 'string',
320
- approver_sys_id: 'string',
321
- comments: 'string'
322
- }
323
- });
324
- }
325
- if (objectiveLower.includes('notification') || objectiveLower.includes('email') || objectiveLower.includes('notify')) {
326
- activities.push({
327
- name: 'Send Notification',
328
- type: 'notification',
329
- order: activities.length > 0 ? 200 : 100,
330
- inputs: {
331
- notification_id: (0, servicenow_id_generator_js_1.getNotificationTemplateSysId)('generic_notification'),
332
- recipients: '{{trigger.current.requested_for}}',
333
- values: {
334
- request_number: '{{trigger.current.number}}',
335
- status: 'Notification sent'
336
- }
337
- }
338
- });
339
- }
340
- if (objectiveLower.includes('create') || objectiveLower.includes('task')) {
341
- activities.push({
342
- name: 'Create Task',
343
- type: 'create_record',
344
- order: activities.length > 0 ? (activities.length + 1) * 100 : 100,
345
- inputs: {
346
- table: 'task',
347
- field_values: {
348
- short_description: '{{trigger.current.short_description}} - Follow-up',
349
- assigned_to: '{{trigger.current.assigned_to}}',
350
- priority: '{{trigger.current.priority}}'
351
- }
352
- },
353
- outputs: {
354
- record_id: 'string',
355
- number: 'string'
356
- }
357
- });
358
- }
359
- // Build flow definition
360
- const flowName = objective.substring(0, 50).replace(/[^a-zA-Z0-9]/g, '_');
361
- const flowDef = {
362
- name: `Flow_${flowName}`,
363
- description: objective,
364
- table: taskAnalysis.serviceNowArtifacts.find(a => ['incident', 'sc_request', 'change_request', 'problem'].includes(a)) || 'incident',
365
- trigger_type: 'record_created',
366
- trigger_condition: '',
367
- activities: activities.length > 0 ? activities : [{
368
- name: 'Log Flow Start',
369
- type: 'script',
370
- order: 100,
371
- inputs: {
372
- script: `gs.info('Flow started for: ' + current.number, 'XMLFlow');\\nreturn { started: true };`
373
- },
374
- outputs: { started: 'boolean' }
375
- }]
376
- };
377
- // Generate IMPROVED XML with enhanced structure
378
- if (options.verbose) {
379
- cliLogger.info('šŸ—ļø Generating IMPROVED production XML...');
380
- }
381
- // Convert to improved flow definition
382
- const improvedFlowDef = {
383
- ...flowDef,
384
- run_as: 'user',
385
- accessible_from: 'package_private',
386
- category: 'custom',
387
- tags: ['auto-generated'],
388
- activities: flowDef.activities.map((act) => ({
389
- ...act,
390
- description: act.description || act.name
391
- }))
392
- };
393
- const result = generateImprovedFlowXML(improvedFlowDef);
394
- xmlFlowResult = { ...result, flowDefinition: flowDef };
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
- }
408
- // Store result in memory
409
- memorySystem.storeLearning(`xml_flow_${sessionId}`, {
410
- objective,
411
- flow_definition: flowDef,
412
- xml_file: result.filePath,
413
- generated_at: new Date().toISOString()
414
- });
415
- // Check if auto-deploy is enabled
416
- if (options.autoDeploy !== false) { // Default is true from swarm command
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
- }
443
- }
444
- else {
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
- }
451
- }
452
- // Continue to Queen Agent orchestration
453
- }
454
- catch (error) {
455
- cliLogger.error('āŒ XML flow generation failed:', error instanceof Error ? error.message : String(error));
456
- cliLogger.info('šŸ’” Falling back to regular swarm orchestration...\n');
457
- }
458
- }
459
297
  // Start real Claude Code orchestration
460
298
  try {
461
299
  // Generate the Queen Agent orchestration prompt
462
- const orchestrationPrompt = buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated, sessionId, xmlFlowResult);
300
+ const orchestrationPrompt = buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated, sessionId, isFlowDesignerTask);
463
301
  if (options.verbose) {
464
302
  cliLogger.info('\nšŸ‘‘ Initializing Queen Agent orchestration...');
465
303
  cliLogger.info('šŸŽÆ Queen Agent will coordinate the following:');
@@ -758,7 +596,7 @@ async function executeWithClaude(claudeCommand, prompt, resolve) {
758
596
  });
759
597
  }
760
598
  // Helper function to build Queen Agent orchestration prompt
761
- function buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated = false, sessionId, xmlFlowResult = null) {
599
+ function buildQueenAgentPrompt(objective, taskAnalysis, options, isAuthenticated = false, sessionId, isFlowDesignerTask = false) {
762
600
  // Check if intelligent features are enabled
763
601
  const hasIntelligentFeatures = options.autoPermissions || options.smartDiscovery ||
764
602
  options.liveTesting || options.autoDeploy || options.autoRollback ||
@@ -779,21 +617,26 @@ You are the Queen Agent, master coordinator of the Snow-Flow hive-mind. Your mis
779
617
  - **Estimated Total Agents**: ${taskAnalysis.estimatedAgentCount}
780
618
  - **ServiceNow Artifacts**: ${taskAnalysis.serviceNowArtifacts.join(', ')}
781
619
 
782
- ${xmlFlowResult ? `## šŸ”§ Flow Designer XML Template Generated
783
- An initial XML template has been created as a starting point:
784
- - **File Path**: ${xmlFlowResult.filePath}
785
- - **Flow Name**: ${xmlFlowResult.flowDefinition.name}
786
- - **Table**: ${xmlFlowResult.flowDefinition.table}
787
- - **Activities**: ${xmlFlowResult.flowDefinition.activities.length}
788
-
789
- **IMPORTANT**: This is just a basic template! You must spawn Claude Code agents to:
790
- 1. Analyze the detailed requirements from the objective
791
- 2. Design the complete flow logic with all activities
792
- 3. Add approval steps, notifications, conditions, etc.
793
- 4. Test the flow implementation
794
- 5. Deploy to ServiceNow
795
-
796
- The XML template is saved but needs significant enhancement by your agents!
620
+ ${isFlowDesignerTask ? `## šŸ”§ Flow Designer Task Detected
621
+ You need to create a ServiceNow Flow Designer flow. Follow these steps:
622
+
623
+ 1. **Analyze Requirements**: Parse the objective to understand all required activities
624
+ 2. **Design Flow Structure**: Plan the flow with triggers, activities, and logic
625
+ 3. **Generate XML**: Use the improved flow XML generator to create production-ready XML
626
+ 4. **Deploy to ServiceNow**: Use snow-flow deploy-xml or MCP tools to deploy
627
+
628
+ **Important Flow Development Instructions**:
629
+ - Use \`generateImprovedFlowXML\` from './utils/improved-flow-xml-generator.js'
630
+ - This generator follows EXACT patterns extracted from real ServiceNow Flow Designer XML examples
631
+ - CRITICAL: Use v2 tables (sys_hub_action_instance_v2), Base64+gzip encoding, complete label_cache
632
+ - The generator creates production-ready XML that ServiceNow can actually import (not "too small to work")
633
+ - Include appropriate activities based on the objective:
634
+ - Approval activities for approval workflows
635
+ - Notification activities for email/messaging
636
+ - Create record activities for task creation
637
+ - Script activities for custom logic
638
+ - Save generated XML to flow-update-sets directory
639
+ - Deploy using: \`snow-flow deploy-xml "path/to/flow.xml"\`
797
640
  ` : ''}
798
641
  - **Recommended Team**: ${getTeamRecommendation(taskAnalysis.taskType)}
799
642
 
package/dist/version.js CHANGED
@@ -7,12 +7,25 @@ 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.14';
10
+ exports.VERSION = '1.3.16';
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.16': [
17
+ 'šŸ”„ VERSION BUMP: Clean version update for npm publish',
18
+ '✨ INCLUDES: All improvements from v1.3.15',
19
+ 'šŸ“¦ READY: Package prepared for npm distribution'
20
+ ],
21
+ '1.3.15': [
22
+ 'šŸŽÆ SWARM SIMPLIFIED: Removed XML generation from swarm command',
23
+ '✨ ORCHESTRATION ONLY: Swarm now only launches Claude Code',
24
+ 'šŸ¤– AGENT RESPONSIBILITY: XML generation moved to Claude Code agents',
25
+ 'šŸš€ CLEANER ARCHITECTURE: Better separation of orchestration vs implementation',
26
+ 'šŸ“‹ FLOW INSTRUCTIONS: Claude Code gets clear instructions for flow tasks',
27
+ 'šŸ”§ NO PREMATURE WORK: No more generating/deploying before agents start'
28
+ ],
16
29
  '1.3.14': [
17
30
  'šŸŽÆ CLEANER OUTPUT: Dramatically reduced verbose logging in swarm command',
18
31
  'šŸš€ FOCUSED UI: Only essential information shown by default',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-flow",
3
- "version": "1.3.14",
3
+ "version": "1.3.16",
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",