snow-flow-test 10.0.1-test.200 → 10.0.1-test.202

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "10.0.1-test.200",
3
+ "version": "10.0.1-test.202",
4
4
  "name": "snow-flow-test",
5
5
  "description": "Snow-Flow Test - ServiceNow Multi-Agent Development Framework",
6
6
  "license": "Elastic-2.0",
@@ -2505,9 +2505,11 @@ export const toolDefinition: MCPToolDefinition = {
2505
2505
  'add_trigger', 'update_trigger', 'delete_trigger',
2506
2506
  'add_action', 'update_action', 'delete_action',
2507
2507
  'add_flow_logic', 'update_flow_logic', 'delete_flow_logic',
2508
- 'add_subflow', 'update_subflow', 'delete_subflow'
2508
+ 'add_subflow', 'update_subflow', 'delete_subflow',
2509
+ 'open_flow', 'close_flow'
2509
2510
  ],
2510
- description: 'Action to perform. add_*/update_*/delete_* for triggers, actions, flow_logic, subflows. update_trigger replaces the trigger type. update_action/update_flow_logic/update_subflow change input values. delete_* removes elements by element_id.'
2511
+ description: 'Action to perform. EDITING WORKFLOW: create_flow keeps the editing lock open — you can immediately call add_action, add_flow_logic, etc. without open_flow. For editing EXISTING flows: call open_flow first to acquire the lock. Always call close_flow as the LAST step to release the lock so users can edit in the UI. ' +
2512
+ 'add_*/update_*/delete_* for triggers, actions, flow_logic, subflows. update_trigger replaces the trigger type. delete_* removes elements by element_id.'
2511
2513
  },
2512
2514
 
2513
2515
  flow_id: {
@@ -3093,11 +3095,8 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
3093
3095
  }
3094
3096
  }
3095
3097
 
3096
- // Release Flow Designer editing lock (safeEdit delete) so users can edit the flow in the UI
3097
- if (flowSysId) {
3098
- var lockReleased = await releaseFlowEditingLock(client, flowSysId);
3099
- diagnostics.editing_lock_released = lockReleased;
3100
- }
3098
+ // NOTE: Do NOT release the editing lock here. The agent may need to add more elements
3099
+ // (flow logic, actions, etc.) after creation. The agent must call close_flow when done.
3101
3100
 
3102
3101
  return createSuccessResult({
3103
3102
  created: true,
@@ -3480,7 +3479,6 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
3480
3479
  addTrigSummary.error('Failed to add trigger: ' + (addTrigResult.error || 'unknown'));
3481
3480
  }
3482
3481
 
3483
- await releaseFlowEditingLock(client, addTrigFlowId);
3484
3482
  return addTrigResult.success
3485
3483
  ? createSuccessResult({ action: 'add_trigger', ...addTrigResult }, {}, addTrigSummary.build())
3486
3484
  : createErrorResult(addTrigResult.error || 'Failed to add trigger');
@@ -3544,7 +3542,6 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
3544
3542
  updTrigSummary.error('Failed to update trigger: ' + (updTrigResult.error || 'unknown'));
3545
3543
  }
3546
3544
 
3547
- await releaseFlowEditingLock(client, updTrigFlowId);
3548
3545
  return updTrigResult.success
3549
3546
  ? createSuccessResult({ action: 'update_trigger', steps: updTrigSteps }, {}, updTrigSummary.build())
3550
3547
  : createErrorResult(updTrigResult.error || 'Failed to update trigger');
@@ -3576,7 +3573,6 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
3576
3573
  addActSummary.error('Failed to add action: ' + (addActResult.error || 'unknown'));
3577
3574
  }
3578
3575
 
3579
- await releaseFlowEditingLock(client, addActFlowId);
3580
3576
  return addActResult.success
3581
3577
  ? createSuccessResult({ action: 'add_action', ...addActResult }, {}, addActSummary.build())
3582
3578
  : createErrorResult(addActResult.error || 'Failed to add action');
@@ -3613,7 +3609,6 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
3613
3609
  addLogicSummary.error('Failed to add flow logic: ' + (addLogicResult.error || 'unknown'));
3614
3610
  }
3615
3611
 
3616
- await releaseFlowEditingLock(client, addLogicFlowId);
3617
3612
  return addLogicResult.success
3618
3613
  ? createSuccessResult({ action: 'add_flow_logic', ...addLogicResult }, {}, addLogicSummary.build())
3619
3614
  : createErrorResult(addLogicResult.error || 'Failed to add flow logic');
@@ -3648,7 +3643,6 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
3648
3643
  addSubSummary.error('Failed to add subflow call: ' + (addSubResult.error || 'unknown'));
3649
3644
  }
3650
3645
 
3651
- await releaseFlowEditingLock(client, addSubFlowId);
3652
3646
  return addSubResult.success
3653
3647
  ? createSuccessResult({ action: 'add_subflow', ...addSubResult }, {}, addSubSummary.build())
3654
3648
  : createErrorResult(addSubResult.error || 'Failed to add subflow call');
@@ -3674,7 +3668,6 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
3674
3668
  } else {
3675
3669
  updElemSummary.error('Failed to update element: ' + (updElemResult.error || 'unknown'));
3676
3670
  }
3677
- await releaseFlowEditingLock(client, updElemFlowId);
3678
3671
  return updElemResult.success
3679
3672
  ? createSuccessResult({ action, ...updElemResult }, {}, updElemSummary.build())
3680
3673
  : createErrorResult(updElemResult.error || 'Failed to update element');
@@ -3706,12 +3699,47 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
3706
3699
  } else {
3707
3700
  delSummary.error('Failed to delete element: ' + (delResult.error || 'unknown'));
3708
3701
  }
3709
- await releaseFlowEditingLock(client, delElemFlowId);
3710
3702
  return delResult.success
3711
3703
  ? createSuccessResult({ action, ...delResult }, {}, delSummary.build())
3712
3704
  : createErrorResult(delResult.error || 'Failed to delete element');
3713
3705
  }
3714
3706
 
3707
+ // ────────────────────────────────────────────────────────────────
3708
+ // OPEN_FLOW — acquire Flow Designer editing lock (processflow GET)
3709
+ // ────────────────────────────────────────────────────────────────
3710
+ case 'open_flow': {
3711
+ if (!args.flow_id) throw new SnowFlowError(ErrorType.VALIDATION_ERROR, 'flow_id is required for open_flow');
3712
+ var openFlowId = await resolveFlowId(client, args.flow_id);
3713
+ var openSummary = summary();
3714
+ try {
3715
+ // The processflow GET is what the Flow Designer UI calls when opening a flow for editing.
3716
+ // This acquires the editing lock so subsequent GraphQL mutations can work.
3717
+ await client.get('/api/now/processflow/flow/' + openFlowId);
3718
+ openSummary.success('Flow opened for editing').field('Flow', openFlowId)
3719
+ .line('You can now use add_action, add_flow_logic, etc. Call close_flow when done.');
3720
+ return createSuccessResult({ action: 'open_flow', flow_id: openFlowId, editing_session: true }, {}, openSummary.build());
3721
+ } catch (e: any) {
3722
+ openSummary.error('Failed to open flow for editing: ' + (e.message || 'unknown')).field('Flow', openFlowId);
3723
+ return createErrorResult('Failed to open flow for editing: ' + (e.message || 'unknown'));
3724
+ }
3725
+ }
3726
+
3727
+ // ────────────────────────────────────────────────────────────────
3728
+ // CLOSE_FLOW — release Flow Designer editing lock (safeEdit)
3729
+ // ────────────────────────────────────────────────────────────────
3730
+ case 'close_flow': {
3731
+ if (!args.flow_id) throw new SnowFlowError(ErrorType.VALIDATION_ERROR, 'flow_id is required for close_flow');
3732
+ var closeFlowId = await resolveFlowId(client, args.flow_id);
3733
+ var closed = await releaseFlowEditingLock(client, closeFlowId);
3734
+ var closeSummary = summary();
3735
+ if (closed) {
3736
+ closeSummary.success('Flow editing lock released').field('Flow', closeFlowId);
3737
+ } else {
3738
+ closeSummary.warning('Lock release returned false (flow may not have been locked)').field('Flow', closeFlowId);
3739
+ }
3740
+ return createSuccessResult({ action: 'close_flow', flow_id: closeFlowId, lock_released: closed }, {}, closeSummary.build());
3741
+ }
3742
+
3715
3743
  default:
3716
3744
  throw new SnowFlowError(ErrorType.VALIDATION_ERROR, 'Unknown action: ' + action);
3717
3745
  }